Skip to content

Commit

Permalink
Merge pull request #275 from bgurney-rh/tests-fs-debug-getmetadata
Browse files Browse the repository at this point in the history
Add tests for filesystem debug get-metadata
  • Loading branch information
mulkieran authored Aug 6, 2024
2 parents 9f123f3 + 803baee commit 712f2b4
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
21 changes: 21 additions & 0 deletions stratis_cli_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,27 @@ def test_filesystem_mount_and_write(self):
]
)

@skip(_skip_condition(1))
def test_filesystem_debug_get_metadata(self):
"""
Test running "stratis filesystem debug get-metadata" on a pool.
"""
pool_name = make_test_pool(StratisCliCertify.DISKS[0:1])
filesystem_name = make_test_filesystem(pool_name)
self._unittest_command(
[
_STRATIS_CLI,
"filesystem",
"debug",
"get-metadata",
pool_name,
f"--fs-name={filesystem_name}",
],
0,
True,
False,
)

@skip(_skip_condition(1))
def test_pool_stop_stopped(self):
"""
Expand Down
15 changes: 15 additions & 0 deletions stratisd_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,21 @@ def test_filesystem_mount_and_write(self):
]
)

@skip(_skip_condition(1))
def test_filesystem_get_metadata(self):
"""
Test getting filesystem metadata info.
"""
pool_name = p_n()
pool_path, _ = make_test_pool(pool_name, StratisCertify.DISKS[0:1])

fs_name = fs_n()
make_test_filesystem(pool_path, fs_name)

self._unittest_command(
StratisDbus.fs_get_metadata(pool_path, fs_name=fs_name), dbus.UInt16(0)
)

def test_get_report(self):
"""
Test getting a valid and invalid report.
Expand Down
24 changes: 24 additions & 0 deletions testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,30 @@ def pool_get_metadata(pool_path, *, current=True):
)
return iface.Metadata(current, timeout=StratisDbus._TIMEOUT)

@staticmethod
def fs_get_metadata(pool_path, *, fs_name=None, current=True):
"""
Get filesystem-level metadata
:param str pool_path: The object path of the pool
:param str fs_name: The name of the filesystem
:param bool current: Current or most recently written metadata
:return: JSON-format pool-level metadata
:rtype: The D-Bus types s, q, and s
:raises dbus.exceptions.DBusException:
"""
iface = dbus.Interface(
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, pool_path),
StratisDbus._POOL_IFACE,
)

fs_name = (False, "") if fs_name is None else (True, fs_name)

return iface.FilesystemMetadata(
(False, "") if fs_name is None else (True, fs_name),
current,
timeout=StratisDbus._TIMEOUT,
)

@staticmethod
def fs_create(pool_path, fs_name, *, fs_size=None, fs_sizelimit=None):
"""
Expand Down

0 comments on commit 712f2b4

Please sign in to comment.