diff --git a/testlib/dbus.py b/testlib/dbus.py index 72af0fa..2101a4b 100644 --- a/testlib/dbus.py +++ b/testlib/dbus.py @@ -363,14 +363,15 @@ def pool_destroy(pool_name): def fs_list(): """ Query the file systems - :return: A dict, Key being the fs name, the value being the pool name - :rtype: dict mapping str to str + :return: A dict; key being a tuple of the object path, the fs name, + and the origin D-Bus; the value being the pool name + :rtype: A dict of str * str * tuple -> str """ objects = StratisDbus.get_managed_objects().items() fs_objects = [ - obj_data[StratisDbus._FS_IFACE] - for _, obj_data in objects + (obj_path, obj_data[StratisDbus._FS_IFACE]) + for obj_path, obj_data in objects if StratisDbus._FS_IFACE in obj_data and obj_data[StratisDbus._FS_IFACE]["Name"].startswith(_TEST_PREF) ] @@ -383,8 +384,10 @@ def fs_list(): } return { - fs_object["Name"]: pool_path_to_name[fs_object["Pool"]] - for fs_object in fs_objects + (obj_path, fs_object["Name"], fs_object["Origin"]): pool_path_to_name[ + fs_object["Pool"] + ] + for obj_path, fs_object in fs_objects } @staticmethod diff --git a/testlib/infra.py b/testlib/infra.py index 30b4deb..87354fa 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -48,7 +48,7 @@ STRATIS_METADATA_LEN = Range(8192, 512) -def clean_up(): # pylint: disable=too-many-branches +def clean_up(): # pylint: disable=too-many-branches,too-many-locals """ Try to clean up after a test failure. @@ -78,7 +78,7 @@ def check_result(result, format_str, format_str_args): # Unmount FS for mountpoint_dir in fnmatch.filter(os.listdir(VAR_TMP), f"*{MOUNT_POINT_SUFFIX}"): - for name, _ in StratisDbus.fs_list().items(): + for (_, name, _), _ in StratisDbus.fs_list().items(): try: subprocess.check_call( [UMOUNT, os.path.join(VAR_TMP, mountpoint_dir, name)] @@ -89,8 +89,23 @@ def check_result(result, format_str, format_str_args): f"{os.path.join(VAR_TMP, mountpoint_dir, name)}: {err}" ) + # Unset MergeScheduled + + for (fs_path, name, origin), pool_name in StratisDbus.fs_list().items(): + if origin[0] is True: + check_result( + StratisDbus.set_property( + fs_path, + StratisDbus.FS_IFACE, + "MergeScheduled", + dbus.Boolean("False"), + ), + "failed to set MergeScheduled to False", + (name, pool_name), + ) + # Remove FS - for name, pool_name in StratisDbus.fs_list().items(): + for (_, name, _), pool_name in StratisDbus.fs_list().items(): check_result( StratisDbus.fs_destroy(pool_name, name), "failed to destroy filesystem %s in pool %s",