From 7945a4ddec58118e374c0a677ee381683ee2fe8f Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 11 Dec 2024 10:54:56 -0500 Subject: [PATCH] Use stratisd-tools stratis-checkmetadata Use this executable to verify properties of the Stratis pool-level metadata. Signed-off-by: mulhern --- testlib/infra.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/testlib/infra.py b/testlib/infra.py index 33d851c..9bc22b5 100644 --- a/testlib/infra.py +++ b/testlib/infra.py @@ -258,6 +258,8 @@ def run_check(self, stop_time): :param int stop_time: the time the test completed """ + stratisd_tools = "stratisd-tools" + if PoolMetadataMonitor.verify: # pylint: disable=no-member # Wait for D-Bus to settle, so D-Bus and metadata can be compared @@ -281,6 +283,25 @@ def run_check(self, stop_time): ) self._check_encryption_information_consistency(object_path, written) + with NamedTemporaryFile(mode="w") as temp_file: + temp_file.write(json.dumps(written)) + temp_file.flush() + + try: + with subprocess.Popen( + [ + stratisd_tools, + "stratis-checkmetadata", + temp_file.name, + ], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) as proc: + (stdoutdata, _) = proc.communicate() + self.assertEqual(proc.returncode, 0, stdoutdata) + except FileNotFoundError as err: + raise RuntimeError(f"{stratisd_tools} not found") from err + else: current_message = ( "" if current_return_code == _OK else current_message