Skip to content

Commit a4cc1cd

Browse files
committed
Add cache removing tests
Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 585963f commit a4cc1cd

3 files changed

Lines changed: 110 additions & 1 deletion

File tree

‎stratis_cli_cert.py‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,73 @@ def test_pool_add_data_init_cache(self):
829829
True,
830830
)
831831

832+
@skip(_skip_condition(3))
833+
def test_pool_remove_cache(self):
834+
"""
835+
Test removing a previously added cache from a pool.
836+
"""
837+
838+
pool_name = make_test_pool(StratisCliCertify.DISKS[0:1])
839+
840+
self._unittest_command(
841+
[
842+
_STRATIS_CLI,
843+
"filesystem",
844+
"create",
845+
pool_name,
846+
fs_n(),
847+
],
848+
0,
849+
True,
850+
True,
851+
)
852+
853+
self._unittest_command(
854+
[
855+
_STRATIS_CLI,
856+
"pool",
857+
"add-data",
858+
pool_name,
859+
StratisCliCertify.DISKS[1],
860+
],
861+
0,
862+
True,
863+
True,
864+
)
865+
866+
self._unittest_command(
867+
[
868+
_STRATIS_CLI,
869+
"pool",
870+
"init-cache",
871+
pool_name,
872+
StratisCliCertify.DISKS[2],
873+
],
874+
0,
875+
True,
876+
True,
877+
)
878+
879+
self._unittest_command(
880+
[
881+
_STRATIS_CLI,
882+
"filesystem",
883+
"create",
884+
pool_name,
885+
fs_n(),
886+
],
887+
0,
888+
True,
889+
True,
890+
)
891+
892+
self._unittest_command(
893+
[_STRATIS_CLI, "pool", "remove-cache", f"--name={pool_name}"],
894+
0,
895+
True,
896+
True,
897+
)
898+
832899
@skip(_skip_condition(1))
833900
def test_pool_stop_started(self):
834901
"""

‎stratisd_cert.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,33 @@ def test_pool_add_data_init_cache(self):
698698
dbus.UInt16(0),
699699
)
700700

701+
@skip(_skip_condition(3))
702+
def test_pool_remove_cache(self):
703+
"""
704+
Test removing a previously added cache.
705+
"""
706+
pool_name = p_n()
707+
pool_path, _ = make_test_pool(pool_name, StratisCertify.DISKS[0:1])
708+
709+
self._unittest_command(StratisDbus.fs_create(pool_path, fs_n()), dbus.UInt16(0))
710+
711+
self._unittest_command(
712+
StratisDbus.pool_add_data(pool_path, StratisCertify.DISKS[1:2]),
713+
dbus.UInt16(0),
714+
)
715+
716+
self._unittest_command(
717+
StratisDbus.pool_init_cache(pool_path, StratisCertify.DISKS[2:3]),
718+
dbus.UInt16(0),
719+
)
720+
721+
self._unittest_command(StratisDbus.fs_create(pool_path, fs_n()), dbus.UInt16(0))
722+
723+
self._unittest_command(
724+
StratisDbus.pool_remove_cache(pool_path),
725+
dbus.UInt16(0),
726+
)
727+
701728
@skip(_skip_condition(2))
702729
def test_pool_create_with_cache(self):
703730
"""

‎testlib/dbus.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class StratisDbus:
104104
_BUS = dbus.SystemBus()
105105
_BUS_NAME = "org.storage.stratis3"
106106
_TOP_OBJECT = "/org/storage/stratis3"
107-
REVISION_NUMBER = 9
107+
REVISION_NUMBER = 10
108108
_REVISION = f"r{REVISION_NUMBER}"
109109
BUS_NAME = _BUS_NAME
110110
TOP_OBJECT = _TOP_OBJECT
@@ -565,6 +565,21 @@ def pool_rebind_keyring(pool_path, key_desc, *, token_slot=None):
565565
key_desc, (False, 0) if token_slot is None else (True, token_slot)
566566
)
567567

568+
@staticmethod
569+
def pool_remove_cache(pool_path):
570+
"""
571+
Remove a pool's cache.
572+
:param str pool_path: The object path of the pool
573+
:return: results of the call
574+
:rtype: The D-Bus types s, q, and b
575+
:raises dbus.exceptions.DBusException:
576+
"""
577+
iface = dbus.Interface(
578+
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, pool_path),
579+
StratisDbus._POOL_IFACE,
580+
)
581+
return iface.RemoveCache()
582+
568583
@staticmethod
569584
def fs_get_metadata(pool_path, *, fs_name=None, current=True):
570585
"""

0 commit comments

Comments
 (0)