mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
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:
@@ -150,7 +150,6 @@ async fn data_movement_put_object_marks_dirty_disks_for_capacity_manager() {
|
||||
.expect("data movement put_object should succeed");
|
||||
|
||||
let dirty_disks = manager.get_dirty_disks().await;
|
||||
assert_eq!(dirty_disks.len(), disk_paths.len());
|
||||
|
||||
let actual_paths: HashSet<_> = dirty_disks
|
||||
.into_iter()
|
||||
@@ -160,7 +159,12 @@ async fn data_movement_put_object_marks_dirty_disks_for_capacity_manager() {
|
||||
.iter()
|
||||
.map(|path| stdfs::canonicalize(path).unwrap().to_string_lossy().into_owned())
|
||||
.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]
|
||||
|
||||
Reference in New Issue
Block a user