diff --git a/stratis_cli_cert.py b/stratis_cli_cert.py index c56d59e..90d719b 100644 --- a/stratis_cli_cert.py +++ b/stratis_cli_cert.py @@ -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): """ diff --git a/stratisd_cert.py b/stratisd_cert.py index cbd7ef2..0397d5c 100644 --- a/stratisd_cert.py +++ b/stratisd_cert.py @@ -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): """ diff --git a/testlib/dbus.py b/testlib/dbus.py index 50cb8be..4c9c354 100644 --- a/testlib/dbus.py +++ b/testlib/dbus.py @@ -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 @@ -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): """