From 65849740f548204fa7b558d0dfd4f9cf87cf21ac Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Fri, 3 Jul 2026 08:19:32 +0800 Subject: [PATCH] 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. --- rustfs/src/app/capacity_dirty_scope_test.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rustfs/src/app/capacity_dirty_scope_test.rs b/rustfs/src/app/capacity_dirty_scope_test.rs index 92a364444..6bff49992 100644 --- a/rustfs/src/app/capacity_dirty_scope_test.rs +++ b/rustfs/src/app/capacity_dirty_scope_test.rs @@ -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]