mirror of
https://github.com/rustfs/rustfs.git
synced 2026-09-07 04:25:54 +00:00
test(scanner): cover overflow service cohort rotation
Assert that a stable overflow inventory rotates every bucket through the bounded scanner service cohort instead of proving only the currently tracked waiters. Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com>
This commit is contained in:
@@ -863,6 +863,41 @@ mod tests {
|
|||||||
assert_eq!(cohort.members[&source].len(), 1);
|
assert_eq!(cohort.members[&source].len(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[serial_test::serial]
|
||||||
|
fn service_cohort_overflow_eventually_services_every_stable_member() {
|
||||||
|
let source = DataUsageCacheSource::new(0, 0);
|
||||||
|
let inventory = cohort_inventory(&["aa", "bb", "cc", "dd", "ee", "ff"]);
|
||||||
|
let mut cohort = ScannerServiceCohort {
|
||||||
|
max_members: 2,
|
||||||
|
max_name_bytes: 4,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let mut admitted = HashSet::new();
|
||||||
|
for _ in 0..3 {
|
||||||
|
cohort.refresh(&inventory);
|
||||||
|
let mut buckets = inventory[&source].clone();
|
||||||
|
cohort.order_buckets(source, &mut buckets);
|
||||||
|
for bucket in buckets.iter().take(2) {
|
||||||
|
admitted.insert(bucket.name.clone());
|
||||||
|
cohort.record_admitted(source, &bucket.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert_eq!(
|
||||||
|
admitted,
|
||||||
|
HashSet::from([
|
||||||
|
"aa".to_string(),
|
||||||
|
"bb".to_string(),
|
||||||
|
"cc".to_string(),
|
||||||
|
"dd".to_string(),
|
||||||
|
"ee".to_string(),
|
||||||
|
"ff".to_string(),
|
||||||
|
]),
|
||||||
|
"stable overflow inventory must rotate every member through the tracked window"
|
||||||
|
);
|
||||||
|
assert!(cohort.overflowed);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[serial_test::serial]
|
#[serial_test::serial]
|
||||||
fn service_cohort_bounds_names_and_does_not_reset_duplicate_dirty_age() {
|
fn service_cohort_bounds_names_and_does_not_reset_duplicate_dirty_age() {
|
||||||
|
|||||||
Reference in New Issue
Block a user