Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: Wait for array resync in MD tests #1185

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions tests/storage_tests/devices_test/md_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
import os
import time

from contextlib import contextmanager

from ..storagetestcase import StorageTestCase

import blivet


@contextmanager
def wait_for_resync():
try:
yield
finally:
time.sleep(2)
action = True
while action:
with open("/proc/mdstat", "r") as f:
action = "resync" in f.read()
if action:
print("Sleeping")
time.sleep(1)


class MDTestCase(StorageTestCase):

raidname = "blivetTestRAID"
Expand Down Expand Up @@ -57,7 +75,8 @@ def _test_mdraid(self, raid_level, members):
member_devices=members)
self.storage.create_device(array)

self.storage.do_it()
with wait_for_resync():
self.storage.do_it()
self.storage.reset()

array = self.storage.devicetree.get_device_by_name(self.raidname)
Expand Down Expand Up @@ -95,7 +114,8 @@ def test_mdraid_raid0_extra(self):
metadata_version="1.2")
self.storage.create_device(array)

self.storage.do_it()
with wait_for_resync():
self.storage.do_it()
self.storage.reset()

array = self.storage.devicetree.get_device_by_name(self.raidname)
Expand All @@ -111,7 +131,8 @@ def test_mdraid_raid1_spare(self):
member_devices=2)
self.storage.create_device(array)

self.storage.do_it()
with wait_for_resync():
self.storage.do_it()
self.storage.reset()

array = self.storage.devicetree.get_device_by_name(self.raidname)
Expand All @@ -133,7 +154,8 @@ def test_mdraid_members_add_remove(self):
member_devices=2)
self.storage.create_device(array)

self.storage.do_it()
with wait_for_resync():
self.storage.do_it()
self.storage.reset()

array = self.storage.devicetree.get_device_by_name(self.raidname)
Expand All @@ -158,7 +180,9 @@ def test_mdraid_members_add_remove(self):

ac = blivet.deviceaction.ActionAddMember(array, part)
self.storage.devicetree.actions.add(ac)
self.storage.do_it()

with wait_for_resync():
self.storage.do_it()

array = self.storage.devicetree.get_device_by_name(self.raidname)
self.assertIsNotNone(array)
Expand All @@ -171,7 +195,9 @@ def test_mdraid_members_add_remove(self):
# and now remove it from the array
ac = blivet.deviceaction.ActionRemoveMember(array, part)
self.storage.devicetree.actions.add(ac)
self.storage.do_it()

with wait_for_resync():
self.storage.do_it()

array = self.storage.devicetree.get_device_by_name(self.raidname)
self.assertIsNotNone(array)
Expand Down
Loading