-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TaskCenter][5/n] Introduces restate_core::test macro #2352
Conversation
Test Results 5 files - 2 5 suites - 2 1m 50s ⏱️ - 2m 40s Results for commit 058539c. ± Comparison against base commit c19fcdf. This pull request removes 2 tests.
♻️ This comment has been updated with latest results. |
976c909
to
5b387d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My knowledge about procedural macros is quite limited. So I guess my review is probably not the most profound. The changes look good and I like how our restate_core::test
macro makes the test look a lot nicer :-) +1 for merging.
// questionable. | ||
RocksDbManager::get().shutdown().await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope: Why are we shutting the db manager in some test cases down and others not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In thoery, we should shutdown on every test that init()s rocksdb, but I think historically we only added the shutdown to tests that triggered segfaults on CI
crates/core/derive/src/tc_test.rs
Outdated
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0. | ||
|
||
//! Some parts of this codebase were taken from https://github.com/tokio-rs/tokio/blob/master/tokio-macros/src/entry.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we put the exact commit they were taken from instead of master
?
- Adds `in_tc(&TaskCenter)` and `in_current_tc()` to scope a future to run in a task-center if it'll be dispatched as a task - Introduces a root task (TaskId(0)) in TaskCenter that's used as a default parent/source of task context - Removes unnecessary args from block_on, run_in_scope_sync. (some of those will be changed in future PRs) - Introduces `Metadata::current()` and `Metadata::with_current(F)`
- Improvements to the future extensions (fixing root task context propagation) - A round of removals of explicit task-center reference passing - `try_set_global_metadata` is now an associated function ## Example Before: ```rust task_center().spawn_child( TaskKind::RpcServer, "metadata-store-grpc", None, async move { net_util::run_hyper_server( &bind_address, service, "metadata-store-grpc", || health_status.update(MetadataServerStatus::Ready), || health_status.update(MetadataServerStatus::Unknown), ) .await?; Ok(()) }, )?; ``` After: ```rust TaskCenter::spawn_child(TaskKind::RpcServer, "metadata-store-grpc", async move { net_util::run_hyper_server( &bind_address, service, "metadata-store-grpc", || health_status.update(MetadataServerStatus::Ready), || health_status.update(MetadataServerStatus::Unknown), ) .await?; Ok(()) })?; ```
Also, exercises `in_tc()` in some tests. Those will be swapped with `restate_core::test` in next PRs. Example of impact: ```rust let bifrost = node_env .tc .run_in_scope( "bifrost init", None, Bifrost::init_in_memory(node_env.metadata.clone()), ) .await; ``` Becomes: ```rust let bifrost = Bifrost::init_in_memory().in_tc(&node_env.tc).await; ```
Introduces a new macro that creates a default TaskCenter in tests. This should replace usage of `tokio::test` (the code is mostly based on it) and it provides access to `TaskCenter::current()` within the test code. This also introduces a transitional type `TestCoreEnv2`, a clone of `TestCoreEnv` but without TaskCenter. After migration, this will be renamed to `TestCoreEnv` again.
Introduces a new macro that creates a default TaskCenter in tests. This should replace usage of
tokio::test
(the code is mostly based on it) and it provides access toTaskCenter::current()
within the test code.This also introduces a transitional type
TestCoreEnv2
, a clone ofTestCoreEnv
but without TaskCenter. After migration, this will be renamed toTestCoreEnv
again.Stack created with Sapling. Best reviewed with ReviewStack.