From f9e7ab182b7ece40def235b15765438f69412534 Mon Sep 17 00:00:00 2001 From: Abhijat Malviya Date: Fri, 23 Aug 2024 11:28:10 +0530 Subject: [PATCH] ducktape: Copy segment to debug if parse failed When parse fails in compute_storage we emit a special JSON which has the segment path. This segment is then copied to test results for analysis. --- tests/rptest/services/redpanda.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/rptest/services/redpanda.py b/tests/rptest/services/redpanda.py index f8dfe2157fdbd..cebf0022ec078 100644 --- a/tests/rptest/services/redpanda.py +++ b/tests/rptest/services/redpanda.py @@ -4396,7 +4396,18 @@ def node_storage(self, output = node.account.ssh_output(shlex.join(cmd), combine_stderr=False, timeout_sec=10) - namespaces = json.loads(output) + json_output = json.loads(output) + if "parse_failed" in json_output: + self.logger.error(f"segment parsing failed: {json_output}") + segment_src = json_output["segment"] + segment_destination = os.path.join( + TestContext.results_dir(self._context, + self._context.test_index), segment_src) + self.logger.info( + f"copying segment from {segment_src} to {segment_destination}") + node.account.copy_from(segment_src, segment_destination) + raise AssertionError + namespaces = json_output for ns, topics in namespaces.items(): ns_path = os.path.join(store.data_dir, ns) ns = store.add_namespace(ns, ns_path)