test(scanner): exercise unfinished checkpoint traversals

This commit is contained in:
overtrue
2026-12-03 03:58:45 +08:00
parent bacd330baf
commit be13e5b76b
2 changed files with 18 additions and 8 deletions
@@ -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,
@@ -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();