Skip to content

Commit

Permalink
Merge pull request #3455 from mulkieran/swap-wait-for-pools
Browse files Browse the repository at this point in the history
Some improvements to test infrastructure
  • Loading branch information
mulkieran authored Sep 27, 2023
2 parents aed1b8a + 7fe4920 commit 6093669
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 6 additions & 2 deletions tests/client-dbus/tests/udev/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,12 +449,13 @@ def wait_for_pools(self, expected_num, *, name=None):
:return: list of pool information found
:rtype: list of (str * MOPool)
"""
(count, limit, dbus_err, found_num, known_pools) = (
(count, limit, dbus_err, found_num, known_pools, start_time) = (
0,
expected_num + 1,
None,
None,
None,
time.time(),
)
while count < limit and not expected_num == found_num:
try:
Expand All @@ -469,7 +470,10 @@ def wait_for_pools(self, expected_num, *, name=None):
count += 1

if found_num is None and dbus_err is not None:
raise dbus_err
raise RuntimeError(
f"After {time.time() - start_time:.2f} seconds, the only "
"response is a D-Bus exception"
) from dbus_err

self.assertEqual(found_num, expected_num)

Expand Down
9 changes: 3 additions & 6 deletions tests/client-dbus/tests/udev/test_udev.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,9 @@ def _simple_initial_discovery_test(
(_, (pool_object_path, device_object_paths)) = create_pool(
random_string(5), devnodes, key_description=key_description
)
pool_uuid = Pool.Properties.Uuid.Get(get_object(pool_object_path))

self.wait_for_pools(1)

wait_for_udev(STRATIS_FS_TYPE, get_devnodes(device_object_paths))
self.wait_for_pools(1)
pool_uuid = Pool.Properties.Uuid.Get(get_object(pool_object_path))

if take_down_dm:
remove_stratis_dm_devices()
Expand Down Expand Up @@ -345,9 +343,8 @@ def _simple_event_test(self, *, key_spec=None): # pylint: disable=too-many-loca
(_, (pool_object_path, _)) = create_pool(
random_string(5), devnodes, key_description=key_description
)
pool_uuid = Pool.Properties.Uuid.Get(get_object(pool_object_path))

self.wait_for_pools(1)
pool_uuid = Pool.Properties.Uuid.Get(get_object(pool_object_path))

remove_stratis_dm_devices()

Expand Down

0 comments on commit 6093669

Please sign in to comment.