From be13e5b76bc5b0b85d1ac72b947698cc8def1ffa Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 3 Dec 2026 03:58:45 +0800 Subject: [PATCH] test(scanner): exercise unfinished checkpoint traversals --- .../scanner_folder/tests/fair_prefix_quantum.rs | 11 ++++++----- .../src/scanner_io/tests/service_cohort.rs | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/crates/scanner/src/scanner_folder/tests/fair_prefix_quantum.rs b/crates/scanner/src/scanner_folder/tests/fair_prefix_quantum.rs index 7aa0d42cb6..561fcd1601 100644 --- a/crates/scanner/src/scanner_folder/tests/fair_prefix_quantum.rs +++ b/crates/scanner/src/scanner_folder/tests/fair_prefix_quantum.rs @@ -673,20 +673,21 @@ async fn cold_linked_prefixes_resume_their_own_replica_coverage() { max_objects: Some(6), ..Default::default() }; - let tier_registry_generation = crate::runtime_tier_registry_for_cycle(1, 0).await.generation; // Six turns per disk leave one final B quantum. Each cold process must // recover that disk's linked tree as well as its complete child coverage. for round in 0..(2 * 40_usize.div_ceil(6) + 1) { let (root, peer) = if round < 12 && round % 2 == 0 { (&a, &b) } else { (&b, &a) }; + let round = u64::try_from(round).expect("bounded round"); + let (cycle, epoch) = (round + 2, round + 1); let identity = crate::DataUsageScanIdentity { - publication_epoch: u64::try_from(round).expect("bounded round") + 10, - tier_registry_generation, + tier_registry_generation: crate::runtime_tier_registry_for_cycle(cycle, epoch).await.generation, + publication_epoch: round + 10, ..cache.info.scan_identity.expect("retained bucket identity") }; cache.prepare_bucket_checkpoint( "bucket", - u64::try_from(round).expect("bounded cycle") + 2, - u64::try_from(round).expect("bounded epoch") + 1, + cycle, + epoch, crate::DataUsageCacheSource::new(0, 0), crate::DataUsageScanPlanDigest([31; 32]), identity, diff --git a/crates/scanner/src/scanner_io/tests/service_cohort.rs b/crates/scanner/src/scanner_io/tests/service_cohort.rs index edb3db418a..77ebb8db5d 100644 --- a/crates/scanner/src/scanner_io/tests/service_cohort.rs +++ b/crates/scanner/src/scanner_io/tests/service_cohort.rs @@ -147,7 +147,7 @@ async fn service_cohort_production_dispatch_services_waiters_across_sources_case clear_dirty_usage_buckets_for_tests(); let hot = format!("a-hot-{}", Uuid::new_v4().simple()); let bootstrap = format!("z-bootstrap-{}", Uuid::new_v4().simple()); - create_cohort_bucket(&store, &hot).await; + create_cohort_bucket_objects(&store, &hot, 2).await; create_cohort_bucket(&store, &bootstrap).await; let cohort = Arc::new(StdMutex::new(ScannerServiceCohort::default())); let expected = store @@ -200,6 +200,15 @@ async fn service_cohort_production_dispatch_services_waiters_across_sources_case "ongoing dirty/new bootstrap must not displace the original cohort" ); + // Both sources must have a real unfinished traversal before the next write. + for set in store.all_set_disks() { + let mut partial = DataUsageCache::default(); + partial + .load(set, &path_join_buf(&[&hot, DATA_USAGE_CACHE_NAME])) + .await + .expect("partial hot prefix"); + assert!(partial.has_scan_position(), "each hot source must retain a traversal position"); + } // Admission fairness is not completed coverage: once the hot bucket // mutates under an active producer usage watch, cycle 5 produces a // complete observation while its primary remains uncertified. @@ -218,8 +227,8 @@ async fn service_cohort_production_dispatch_services_waiters_across_sources_case .usage_snapshot_bucket_observations .get(&hot) .expect("all-source hot observation"); - assert_eq!(observed.usage.objects_count, 2); - assert_eq!(observed.usage.size, 12); + assert_eq!(observed.usage.objects_count, 4); + assert_eq!(observed.usage.size, 24); assert!(observed.usage.usage_certification.is_none()); for set in store.all_set_disks() { let mut cache = DataUsageCache::default();