Skip to content

Commit

Permalink
Add additional metadata checks
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Jul 16, 2024
1 parent d8235c9 commit 6e976ef
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
14 changes: 14 additions & 0 deletions testlib/dbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,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
68 changes: 68 additions & 0 deletions testlib/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,67 @@ 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.
"""
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.assertGreater(len(raid_meta_allocs), 0)

raid_meta_allocs = raid_meta_allocs[0]
self.assertIsInstance(raid_meta_allocs, list)
self.assertGreater(raid_meta_allocs[0], 0)
self.assertGreater(raid_meta_allocs[1], 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)

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

def run_check(self, stop_time):
"""
Run the check.
Expand Down Expand Up @@ -270,6 +331,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 6e976ef

Please sign in to comment.