Skip to content
Merged
Show file tree
Hide file tree
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
67 changes: 67 additions & 0 deletions stratis_cli_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,73 @@ def test_pool_add_data_init_cache(self):
True,
)

@skip(_skip_condition(3))
def test_pool_remove_cache(self):
"""
Test removing a previously added cache from a pool.
"""

pool_name = make_test_pool(StratisCliCertify.DISKS[0:1])

self._unittest_command(
[
_STRATIS_CLI,
"filesystem",
"create",
pool_name,
fs_n(),
],
0,
True,
True,
)

self._unittest_command(
[
_STRATIS_CLI,
"pool",
"add-data",
pool_name,
StratisCliCertify.DISKS[1],
],
0,
True,
True,
)

self._unittest_command(
[
_STRATIS_CLI,
"pool",
"init-cache",
pool_name,
StratisCliCertify.DISKS[2],
],
0,
True,
True,
)

self._unittest_command(
[
_STRATIS_CLI,
"filesystem",
"create",
pool_name,
fs_n(),
],
0,
True,
True,
)

self._unittest_command(
[_STRATIS_CLI, "pool", "remove-cache", f"--name={pool_name}"],
0,
True,
True,
)

@skip(_skip_condition(1))
def test_pool_stop_started(self):
"""
Expand Down
27 changes: 27 additions & 0 deletions stratisd_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,33 @@ def test_pool_add_data_init_cache(self):
dbus.UInt16(0),
)

@skip(_skip_condition(3))
def test_pool_remove_cache(self):
"""
Test removing a previously added cache.
"""
pool_name = p_n()
pool_path, _ = make_test_pool(pool_name, StratisCertify.DISKS[0:1])

self._unittest_command(StratisDbus.fs_create(pool_path, fs_n()), dbus.UInt16(0))

self._unittest_command(
StratisDbus.pool_add_data(pool_path, StratisCertify.DISKS[1:2]),
dbus.UInt16(0),
)

self._unittest_command(
StratisDbus.pool_init_cache(pool_path, StratisCertify.DISKS[2:3]),
dbus.UInt16(0),
)

self._unittest_command(StratisDbus.fs_create(pool_path, fs_n()), dbus.UInt16(0))

self._unittest_command(
StratisDbus.pool_remove_cache(pool_path),
dbus.UInt16(0),
)

@skip(_skip_condition(2))
def test_pool_create_with_cache(self):
"""
Expand Down
17 changes: 16 additions & 1 deletion testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class StratisDbus:
_BUS = dbus.SystemBus()
_BUS_NAME = "org.storage.stratis3"
_TOP_OBJECT = "/org/storage/stratis3"
REVISION_NUMBER = 9
REVISION_NUMBER = 10
_REVISION = f"r{REVISION_NUMBER}"
BUS_NAME = _BUS_NAME
TOP_OBJECT = _TOP_OBJECT
Expand Down Expand Up @@ -565,6 +565,21 @@ def pool_rebind_keyring(pool_path, key_desc, *, token_slot=None):
key_desc, (False, 0) if token_slot is None else (True, token_slot)
)

@staticmethod
def pool_remove_cache(pool_path):
"""
Remove a pool's cache.
:param str pool_path: The object path of the pool
:return: results of the call
:rtype: The D-Bus types s, q, and b
:raises dbus.exceptions.DBusException:
"""
iface = dbus.Interface(
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, pool_path),
StratisDbus._POOL_IFACE,
)
return iface.RemoveCache()

@staticmethod
def fs_get_metadata(pool_path, *, fs_name=None, current=True):
"""
Expand Down
Loading