From 9b956c15ccd620ef6fbbee1d417f38a3f152392a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:20:16 +0000 Subject: [PATCH 1/2] Initial plan From cecd75041f3178694d44a27b7b59908547eee7c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:23:03 +0000 Subject: [PATCH 2/2] Stabilize L1 TTL tests with wider timing windows Co-authored-by: schmitch <1641401+schmitch@users.noreply.github.com> --- crates/cache/tests/l1_unit.rs | 22 +++++++++++----------- docs/changes/2.0.0/471.fixed.md | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 docs/changes/2.0.0/471.fixed.md diff --git a/crates/cache/tests/l1_unit.rs b/crates/cache/tests/l1_unit.rs index 8d5f7efc..6163c18b 100644 --- a/crates/cache/tests/l1_unit.rs +++ b/crates/cache/tests/l1_unit.rs @@ -69,7 +69,7 @@ async fn ttl_expiry_forces_rerun() { .get_or_try_insert_with::( "ns", "ttl", - Duration::from_millis(100), + Duration::from_secs(1), || async move { let n = calls.fetch_add(1, Ordering::SeqCst); Ok(n as u64) @@ -88,7 +88,7 @@ async fn ttl_expiry_forces_rerun() { assert_eq!(calls.load(Ordering::SeqCst), 1); // Let the entry expire, then it must re-run the factory. - tokio::time::sleep(Duration::from_millis(150)).await; + tokio::time::sleep(Duration::from_millis(1500)).await; let after = run().await; assert_eq!(after, 1, "expired entry must trigger a fresh factory run"); assert_eq!(calls.load(Ordering::SeqCst), 2); @@ -502,7 +502,7 @@ async fn custom_tag_invalidation_expires_only_matching_entries() { #[tokio::test] async fn a_factory_chosen_lifetime_shortens_the_ttl() { // A value copied from a record that expires in 1 s lives 1 s, not the - // caller's 60 s; a longer factory lifetime never extends the TTL. + // caller's 3 s; a longer factory lifetime never extends the TTL. let cache = Cache::l1_only(100); let calls = Arc::new(AtomicUsize::new(0)); let load = |lifetime: Duration| { @@ -513,19 +513,19 @@ async fn a_factory_chosen_lifetime_shortens_the_ttl() { "ns", "expiring", &[], - Duration::from_millis(500), + Duration::from_secs(3), || async move { Ok((calls.fetch_add(1, Ordering::SeqCst) + 1, lifetime)) }, ) .await .unwrap() } }; - assert_eq!(load(Duration::from_millis(100)).await, 1); - assert_eq!(load(Duration::from_millis(100)).await, 1, "still live"); - tokio::time::sleep(Duration::from_millis(200)).await; - assert_eq!(load(Duration::from_secs(60)).await, 2, "expired at 100 ms"); - tokio::time::sleep(Duration::from_millis(300)).await; + assert_eq!(load(Duration::from_secs(1)).await, 1); + assert_eq!(load(Duration::from_secs(1)).await, 1, "still live"); + tokio::time::sleep(Duration::from_millis(1500)).await; + assert_eq!(load(Duration::from_secs(60)).await, 2, "expired at 1 s"); + tokio::time::sleep(Duration::from_secs(1)).await; assert_eq!(load(Duration::from_secs(60)).await, 2, "capped at the TTL"); - tokio::time::sleep(Duration::from_millis(300)).await; - assert_eq!(load(Duration::from_secs(60)).await, 3, "expired at 500 ms"); + tokio::time::sleep(Duration::from_millis(2500)).await; + assert_eq!(load(Duration::from_secs(60)).await, 3, "expired at 3 s"); } diff --git a/docs/changes/2.0.0/471.fixed.md b/docs/changes/2.0.0/471.fixed.md new file mode 100644 index 00000000..faef839e --- /dev/null +++ b/docs/changes/2.0.0/471.fixed.md @@ -0,0 +1 @@ +Widen the L1 cache TTL tests' timing windows to avoid spurious failures on busy CI runners while preserving their cache reuse and expiry checks.