From 4109067136f188d7be7bb8baf552a110404cc435 Mon Sep 17 00:00:00 2001 From: Ruslan Kossak Date: Fri, 6 Nov 2026 11:11:34 +0100 Subject: [PATCH] tests: Fix race condition in test_set_bitmap_location MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Setting the bitmap location to "internal" triggers a background kernel resync to populate the bitmap. Without waiting for this resync to complete, subsequent bitmap location changes can fail with: mdadm: Cannot add bitmap while array is resyncing or reshaping etc. Wrap set_bitmap_location calls that set "internal" with wait_for_action("resync") to ensure the resync completes before the next bitmap operation, matching the pattern already used for md_create. Since the race condition was the reason for the UNSTABLE tag (added in 67b959fa), remove it — the test should now be reliable. Co-Authored-By: Claude Opus 4.6 --- tests/mdraid_test.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/mdraid_test.py b/tests/mdraid_test.py index a00ebccd9..5a4e24afb 100644 --- a/tests/mdraid_test.py +++ b/tests/mdraid_test.py @@ -478,7 +478,7 @@ def test_name_node_bijection(self): class MDTestSetBitmapLocation(MDTestCase): - @tag_test(TestTags.SLOW, TestTags.UNSTABLE) + @tag_test(TestTags.SLOW) def test_set_bitmap_location(self): """Verify we can change bitmap location for an existing MD array""" @@ -508,8 +508,9 @@ def test_set_bitmap_location(self): loc = BlockDev.md_get_bitmap_location("bd_test_md") self.assertEqual(loc, "none") - succ = BlockDev.md_set_bitmap_location("bd_test_md", "internal") - self.assertTrue(succ) + with wait_for_action("resync"): + succ = BlockDev.md_set_bitmap_location("bd_test_md", "internal") + self.assertTrue(succ) loc = BlockDev.md_get_bitmap_location("bd_test_md") self.assertIn(loc, ("+8", "+2")) @@ -523,8 +524,9 @@ def test_set_bitmap_location(self): node = BlockDev.md_node_from_name("bd_test_md") self.assertIsNotNone(node) - succ = BlockDev.md_set_bitmap_location(node, "internal") - self.assertTrue(succ) + with wait_for_action("resync"): + succ = BlockDev.md_set_bitmap_location(node, "internal") + self.assertTrue(succ) succ = BlockDev.md_set_bitmap_location("/dev/%s" % node, "none") self.assertTrue(succ)