From aa537a5b4d9beb611794af262bd95f11ce7615be Mon Sep 17 00:00:00 2001 From: Maxim Deb Natkh Date: Mon, 5 Feb 2024 13:55:01 +0100 Subject: [PATCH] NEBDUTY-504: save dmesg -T on the tear_down of blockstore loadtest (#309) * save dmesg -T on the tear_down of blockstore loadtest * save dmesg -T on the tear_down of blockstore loadtest * save dmesg -T on the tear_down of blockstore loadtest * save dmesg -T on the tear_down of blockstore loadtest * wrap nbs/kikimr stop() in try block * fix flake8... --------- Co-authored-by: Maxim Deb Natkh --- .../tests/python/lib/loadtest_env.py | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/cloud/blockstore/tests/python/lib/loadtest_env.py b/cloud/blockstore/tests/python/lib/loadtest_env.py index bbde58d06d1..f43d54c4245 100644 --- a/cloud/blockstore/tests/python/lib/loadtest_env.py +++ b/cloud/blockstore/tests/python/lib/loadtest_env.py @@ -15,6 +15,7 @@ import logging import os +import subprocess logger = logging.getLogger(__name__) @@ -129,12 +130,26 @@ def __init__( wait_for_nbs_server(self.nbs.nbs_port) def tear_down(self): - self.nbs.stop() - self.kikimr_cluster.stop() - - for d in self.__devices: - d.handle.close() - os.unlink(d.path) + try: + self.nbs.stop() + self.kikimr_cluster.stop() + + for d in self.__devices: + d.handle.close() + os.unlink(d.path) + finally: + # It may be beneficial to save dmesg output for debugging purposes. + try: + with open(yatest_common.output_path() + "/dmesg.txt", "w") as dmesg_output: + subprocess.run( + ["sudo", "dmesg", "-T"], + stdout=dmesg_output, + stderr=dmesg_output, + timeout=10 + ) + except Exception as dmesg_error: + logging.info(f"Failed to save dmesg output: {dmesg_error}") + pass @property def endpoint(self):