fix(test): deflake capacity dirty scope test global state contamination (#4213)

fix(test): use subset check for capacity dirty scope test to handle global state contamination

The data_movement_put_object_marks_dirty_disks_for_capacity_manager test
asserts exact dirty disk count, but the global dirty scope registry is
process-wide. Other concurrent tests can add entries between the drain
and the assertion, causing flaky failures (8 instead of expected 4).

Use subset assertion to verify the expected disks are present without
being sensitive to entries from other tests.
This commit is contained in:
Zhengchao An
2026-07-03 08:19:32 +08:00
committed by GitHub
parent d1a2dec18e
commit 65849740f5
+6 -2
View File
@@ -150,7 +150,6 @@ async fn data_movement_put_object_marks_dirty_disks_for_capacity_manager() {
.expect("data movement put_object should succeed"); .expect("data movement put_object should succeed");
let dirty_disks = manager.get_dirty_disks().await; let dirty_disks = manager.get_dirty_disks().await;
assert_eq!(dirty_disks.len(), disk_paths.len());
let actual_paths: HashSet<_> = dirty_disks let actual_paths: HashSet<_> = dirty_disks
.into_iter() .into_iter()
@@ -160,7 +159,12 @@ async fn data_movement_put_object_marks_dirty_disks_for_capacity_manager() {
.iter() .iter()
.map(|path| stdfs::canonicalize(path).unwrap().to_string_lossy().into_owned()) .map(|path| stdfs::canonicalize(path).unwrap().to_string_lossy().into_owned())
.collect(); .collect();
assert_eq!(actual_paths, expected_paths); // The global dirty scope registry is process-wide; concurrent tests may
// add extra entries, so we only verify that our expected paths are present.
assert!(
expected_paths.is_subset(&actual_paths),
"expected dirty disks {expected_paths:?} to be a subset of {actual_paths:?}"
);
} }
#[tokio::test] #[tokio::test]