Skip to content

Commit ae9dda9

Browse files
authored
chore: fix runtime ut to tokio::time::sleep in async (#13963)
1 parent c761101 commit ae9dda9

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/common/base/tests/it/runtime.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,17 @@ async fn test_runtime() -> Result<()> {
6969
Ok(())
7070
}
7171

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

7676
runtime.spawn(GLOBAL_TASK, async move {
77-
std::thread::sleep(Duration::from_secs(6));
77+
tokio::time::sleep(Duration::from_secs(6)).await;
7878
});
7979

8080
let instant = Instant::now();
8181
drop(runtime);
82-
assert!(instant.elapsed() >= Duration::from_secs(3));
83-
assert!(instant.elapsed() < Duration::from_secs(4));
82+
assert!(instant.elapsed() < Duration::from_secs(6));
8483

8584
Ok(())
8685
}

0 commit comments

Comments
 (0)