Skip to content

Commit

Permalink
Add Unset MergeScheduled section to clean_up()
Browse files Browse the repository at this point in the history
Also refine the StratisDbus.fs_list() method to return the object path,
which is used to unset the MergeScheduled field for filesystems being
torn down after a test.

Signed-off-by: Bryan Gurney <[email protected]>
  • Loading branch information
bgurney-rh committed Sep 5, 2024
1 parent 5158b48 commit 358dc63
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
15 changes: 9 additions & 6 deletions testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
Expand All @@ -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
Expand Down
21 changes: 18 additions & 3 deletions testlib/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)]
Expand All @@ -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",
Expand Down

0 comments on commit 358dc63

Please sign in to comment.