From 7048a9a3ed85f2d4633c247a7f54c7cd40088daa Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 8 Jul 2026 23:42:59 +0800 Subject: [PATCH] test(ecstore): run shard_read_costs empty test under a Tokio runtime (#4496) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shard_read_costs_for_empty_disk_set_are_empty was a plain sync #[test], but shard_read_costs_for_disks consults process-global topology state (local_endpoint_hosts_for_shard_costs) whose fast-lock manager lazily spawns a background cleanup task on first access. When this test was the first in a process to touch that global — as under nextest's per-test isolation — the tokio::spawn panicked with a TryCurrentError because no runtime was present, making the test order-dependent flaky in CI (it passes only when some sibling tokio test initializes the manager first). Run it under a Tokio runtime like the sibling reservation tests (#[tokio::test]), so the lazy init's spawn always has a runtime. Test-only change; no production behavior change. Verified failing before the change and passing after under both `cargo test` and `cargo nextest run` in isolation. Co-authored-by: heihutu --- crates/ecstore/src/set_disk/core/io_primitives.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ecstore/src/set_disk/core/io_primitives.rs b/crates/ecstore/src/set_disk/core/io_primitives.rs index 6f2d109c6..f56c5fab9 100644 --- a/crates/ecstore/src/set_disk/core/io_primitives.rs +++ b/crates/ecstore/src/set_disk/core/io_primitives.rs @@ -4008,8 +4008,15 @@ mod tests { assert!(part.etag.is_empty()); } - #[test] - fn shard_read_costs_for_empty_disk_set_are_empty() { + // Runs under a Tokio runtime like the sibling reservation tests: + // shard_read_costs_for_disks consults process-global topology state + // (local_endpoint_hosts_for_shard_costs), whose fast-lock manager lazily + // spawns a background cleanup task on first access. As a plain sync #[test] + // this panicked with a TryCurrentError whenever it was the first test in a + // process to touch that global (e.g. under nextest's per-test isolation), + // making it order-dependent flaky in CI. + #[tokio::test] + async fn shard_read_costs_for_empty_disk_set_are_empty() { assert!(shard_read_costs_for_disks(&[]).is_empty()); }