Skip to content

Commit

Permalink
Merge pull request #285 from mulkieran/reapply
Browse files Browse the repository at this point in the history
Reapply
  • Loading branch information
mulkieran authored Oct 4, 2024
2 parents d0d636d + 70e6ed4 commit 8adc5bc
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
pylint
python3-dbus
python3-dbus-python-client-gen
python3-justbytes
python3-gobject
python3-psutil
image: fedora:40 # CURRENT DEVELOPMENT ENVIRONMENT
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
python3-dbus
python3-dbus-python-client-gen
python3-gobject
python3-justbytes
python3-psutil
task: PYTHONPATH=./src make -f Makefile lint
- dependencies: black python3-isort
Expand Down
16 changes: 15 additions & 1 deletion testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def pool_start(id_string, id_type):
StratisDbus._MNGR_IFACE,
)

return manager_iface.StartPool(id_string, id_type, (False, ""))
return manager_iface.StartPool(id_string, id_type, (False, ""), (False, 0))

@staticmethod
def pool_stop(id_string, id_type):
Expand All @@ -285,6 +285,20 @@ def pool_uuid(pool_path):

return iface.Get(StratisDbus._POOL_IFACE, "Uuid", timeout=StratisDbus._TIMEOUT)

@staticmethod
def pool_encrypted(pool_path):
"""
Find a pool Encrypted value given an object path.
"""
iface = dbus.Interface(
StratisDbus._BUS.get_object(StratisDbus._BUS_NAME, pool_path),
dbus.PROPERTIES_IFACE,
)

return iface.Get(
StratisDbus._POOL_IFACE, "Encrypted", timeout=StratisDbus._TIMEOUT
)

@staticmethod
def pool_create(
pool_name,
Expand Down
76 changes: 76 additions & 0 deletions testlib/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

# isort: THIRDPARTY
import dbus
from justbytes import Range

from .dbus import StratisDbus, manager_interfaces
from .utils import exec_command, process_exists, terminate_traces
Expand All @@ -44,6 +45,7 @@
MOUNT_POINT_SUFFIX = "_stratisd_mounts"
UMOUNT = "umount"
MOUNT = "mount"
STRATIS_METADATA_LEN = Range(8192, 512)


def clean_up(): # pylint: disable=too-many-branches
Expand Down Expand Up @@ -240,6 +242,73 @@ def _check_thin_meta_allocations(self, metadata):
"total size of thin meta spare device.",
)

def _check_encryption_information_consistency(self, pool_object_path, metadata):
"""
Check whether D-Bus and metadata agree about encryption state of pool.
"""
encrypted = bool(StratisDbus.pool_encrypted(pool_object_path))
features = metadata.get("features")

if encrypted:
self.assertIsNotNone(features)
self.assertIn("Encryption", metadata["features"])
elif features is not None:
self.assertNotIn("Encryption", metadata["features"])

def _check_crypt_meta_allocs(self, metadata):
"""
Check that all crypt metadata allocs exist and have non-zero length.
"""
crypt_meta_allocs = metadata["backstore"]["cap"].get("crypt_meta_allocs")
self.assertIsNotNone(crypt_meta_allocs)
self.assertIsInstance(crypt_meta_allocs, list)
self.assertGreater(len(crypt_meta_allocs), 0)

crypt_meta_allocs = crypt_meta_allocs[0]
self.assertIsInstance(crypt_meta_allocs, list)
self.assertEqual(crypt_meta_allocs[0], 0)
self.assertGreater(crypt_meta_allocs[1], 0)

def _check_raid_meta_allocs(self, metadata):
"""
Check that all raid_meta_allocs exist and have non-zero length.
RAID meta_allocs should start immediately after Stratis metadata ends.
"""
for raid_meta_allocs in [
a["raid_meta_allocs"]
for a in metadata["backstore"]["data_tier"]["blockdev"]["devs"]
]:
self.assertIsNotNone(raid_meta_allocs)
self.assertIsInstance(raid_meta_allocs, list)
self.assertEqual(len(raid_meta_allocs), 1)

raid_meta_allocs = raid_meta_allocs[0]
self.assertIsInstance(raid_meta_allocs, list)

raid_meta_alloc_start = Range(raid_meta_allocs[0], 512)
raid_meta_alloc_len = Range(raid_meta_allocs[1], 512)

self.assertEqual(raid_meta_alloc_start, STRATIS_METADATA_LEN)
self.assertGreater(raid_meta_alloc_len, Range(0))

def _check_integrity_meta_allocs(self, metadata):
"""
Check that all integrity_meta_allocs exist and have non-zero length.
"""
for integrity_meta_allocs in [
a["integrity_meta_allocs"]
for a in metadata["backstore"]["data_tier"]["blockdev"]["devs"]
]:
self.assertIsNotNone(integrity_meta_allocs)
self.assertIsInstance(integrity_meta_allocs, list)
self.assertGreater(len(integrity_meta_allocs), 0)

for alloc in integrity_meta_allocs:
start, length = Range(alloc[0], 512), Range(alloc[1], 512)
self.assertGreater(start, Range(0))
self.assertEqual(length % Range(8, 512), Range(0))

def run_check(self, stop_time):
"""
Run the check.
Expand Down Expand Up @@ -270,6 +339,13 @@ def run_check(self, stop_time):

self._check_thin_meta_allocations(written)

self._check_encryption_information_consistency(object_path, written)
self._check_crypt_meta_allocs(written)

self._check_raid_meta_allocs(written)

self._check_integrity_meta_allocs(written)

else:
current_message = (
"" if current_return_code == _OK else current_message
Expand Down

0 comments on commit 8adc5bc

Please sign in to comment.