Skip to content

Commit c18bfbe

Browse files
authored
Merge pull request #327 from mulkieran/issue-testing-326
Add tests for starting pool without cache
2 parents 7030ce6 + 8667020 commit c18bfbe

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

stratisd_cert.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,49 @@ def test_get_keys_permissions(self):
12751275
"""
12761276
self._test_permissions(StratisDbus.get_keys, [], False)
12771277

1278+
@skip(_skip_condition(1))
1279+
def test_pool_start_without_cache(self):
1280+
"""
1281+
Test starting a stopped pool by its name without cache.
1282+
"""
1283+
pool_name = p_n()
1284+
make_test_pool(pool_name, StratisCertify.DISKS[0:1])
1285+
1286+
self._unittest_command(
1287+
StratisDbus.pool_stop(pool_name, "name"),
1288+
dbus.UInt16(0),
1289+
)
1290+
1291+
self._unittest_command(
1292+
StratisDbus.pool_start(pool_name, "name", remove_cache=True),
1293+
dbus.UInt16(0),
1294+
)
1295+
1296+
@skip(_skip_condition(1))
1297+
def test_pool_start_without_cache_encrypted(self):
1298+
"""
1299+
Test starting an encrypted stopped pool by its name without cache.
1300+
"""
1301+
pool_name = p_n()
1302+
1303+
with KernelKey("test-password") as key_desc:
1304+
make_test_pool(pool_name, StratisCertify.DISKS[0:1], key_desc=key_desc)
1305+
1306+
self._unittest_command(
1307+
StratisDbus.pool_stop(pool_name, "name"),
1308+
dbus.UInt16(0),
1309+
)
1310+
1311+
self._unittest_command(
1312+
StratisDbus.pool_start(
1313+
pool_name,
1314+
"name",
1315+
unlock_method=(True, (False, 0)),
1316+
remove_cache=True,
1317+
),
1318+
dbus.UInt16(0),
1319+
)
1320+
12781321

12791322
class StratisdManPageCertify(StratisCertify):
12801323
"""

testlib/dbus.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,21 @@ def get_keys():
248248
return iface.ListKeys(timeout=StratisDbus._TIMEOUT)
249249

250250
@staticmethod
251-
def pool_start(id_string, id_type):
251+
def pool_start(id_string, id_type, *, unlock_method=None, remove_cache=False):
252252
"""
253253
Start a pool
254254
:param str id: The identifier of the pool to start
255255
:param str type: The type of identifier ("uuid" or "name")
256256
"""
257+
258+
unlock_method = (False, (False, 0)) if unlock_method is None else unlock_method
257259
manager_iface = dbus.Interface(
258260
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, StratisDbus._TOP_OBJECT),
259261
StratisDbus._MNGR_IFACE,
260262
)
261263

262264
return manager_iface.StartPool(
263-
id_string, id_type, (False, (False, 0)), (False, 0), False
265+
id_string, id_type, unlock_method, (False, 0), remove_cache
264266
)
265267

266268
@staticmethod

testlib/infra.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,16 @@ def __init__(self, *, test_id=None):
667667
"""
668668
self.dbus_monitor = DbusMonitor()
669669
# See: https://github.com/stratis-storage/project/issues/741
670-
if test_id is None or not test_id.endswith("test_pool_add_data_init_cache"):
670+
if test_id is None or all(
671+
not test_id.endswith(test_name)
672+
for test_name in [
673+
"test_pool_add_data_init_cache",
674+
"test_pool_start_by_name",
675+
"test_pool_start_stopped",
676+
"test_pool_start_without_cache",
677+
"test_pool_start_without_cache_encrypted",
678+
]
679+
):
671680
self.dbus_monitor.setUp()
672681

673682
def teardown(self):

0 commit comments

Comments
 (0)