Skip to content

Commit

Permalink
chore: fix runtime ut to tokio::time::sleep in async (databendlabs#13963
Browse files Browse the repository at this point in the history
)
  • Loading branch information
BohuTANG authored Dec 9, 2023
1 parent c761101 commit ae9dda9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/common/base/tests/it/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,17 @@ async fn test_runtime() -> Result<()> {
Ok(())
}

#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn test_shutdown_long_run_runtime() -> Result<()> {
let runtime = Runtime::with_default_worker_threads()?;

runtime.spawn(GLOBAL_TASK, async move {
std::thread::sleep(Duration::from_secs(6));
tokio::time::sleep(Duration::from_secs(6)).await;
});

let instant = Instant::now();
drop(runtime);
assert!(instant.elapsed() >= Duration::from_secs(3));
assert!(instant.elapsed() < Duration::from_secs(4));
assert!(instant.elapsed() < Duration::from_secs(6));

Ok(())
}
Expand Down

0 comments on commit ae9dda9

Please sign in to comment.