wait_until_i_am_the_last_task() - num_alive should be 0, not 1

This commit is contained in:
Igor Katson 2024-11-06 16:05:58 +00:00
parent 78363d65ca
commit 87e09a60f7
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
2 changed files with 6 additions and 5 deletions

View file

@ -23,6 +23,8 @@ use crate::{
#[tokio::test(flavor = "multi_thread", worker_threads = 64)]
async fn test_e2e_download() {
wait_until_i_am_the_last_task().await.unwrap();
let timeout = std::env::var("E2E_TIMEOUT")
.ok()
.and_then(|v| v.parse().ok())
@ -38,7 +40,7 @@ async fn test_e2e_download() {
.unwrap();
// Wait to ensure everything is dropped.
wait_until_i_am_the_last_task().await;
wait_until_i_am_the_last_task().await.unwrap();
drop_checks.check().unwrap();
}

View file

@ -196,13 +196,13 @@ pub async fn wait_until(
Ok(())
}
pub async fn wait_until_i_am_the_last_task() {
pub async fn wait_until_i_am_the_last_task() -> anyhow::Result<()> {
let metrics = tokio::runtime::Handle::current().metrics();
wait_until(
|| {
let num_alive = metrics.num_alive_tasks();
if num_alive != 1 {
bail!("metrics.num_alive_tasks() = {num_alive}, expected 1")
if num_alive != 0 {
bail!("metrics.num_alive_tasks() = {num_alive}, expected 0")
}
Ok(())
},
@ -210,5 +210,4 @@ pub async fn wait_until_i_am_the_last_task() {
Duration::from_secs(6),
)
.await
.unwrap();
}