From 2fb8a5a96b7b44cc09bca7a02b088757ac80a849 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 23 May 2024 13:47:15 -0400 Subject: [PATCH] qa: use tell interface for command that may fail The asok interface will mangle stdout if the command actually fails. The reason `flush path` is done via the asok interface is because the tell/asok interfaces were unified after these tests were written and `flush path` was only available via the asok interface. Fixes: https://tracker.ceph.com/issues/66184 Signed-off-by: Patrick Donnelly (cherry picked from commit 715c951c345ae41cf4a5e9a1db85bd98c8b08ab1) --- qa/tasks/cephfs/test_scrub_checks.py | 44 +++++----------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/qa/tasks/cephfs/test_scrub_checks.py b/qa/tasks/cephfs/test_scrub_checks.py index 276da12681b6b..4cd88199db0f9 100644 --- a/qa/tasks/cephfs/test_scrub_checks.py +++ b/qa/tasks/cephfs/test_scrub_checks.py @@ -1,7 +1,6 @@ """ MDS admin socket scrubbing-related tests. """ -import json import logging import errno import time @@ -227,7 +226,7 @@ class TestScrubChecks(CephFSTestCase): success_validator = lambda j, r: self.json_validator(j, r, "return_code", 0) nep = "{test_path}/i/dont/exist".format(test_path=abs_test_path) - self.asok_command(mds_rank, "flush_path {nep}".format(nep=nep), + self.tell_command(mds_rank, "flush_path {nep}".format(nep=nep), lambda j, r: self.json_validator(j, r, "return_code", -errno.ENOENT)) self.tell_command(mds_rank, "scrub start {nep}".format(nep=nep), lambda j, r: self.json_validator(j, r, "return_code", -errno.ENOENT)) @@ -238,7 +237,7 @@ class TestScrubChecks(CephFSTestCase): if run_seq == 0: log.info("First run: flushing {dirpath}".format(dirpath=dirpath)) command = "flush_path {dirpath}".format(dirpath=dirpath) - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) command = "scrub start {dirpath}".format(dirpath=dirpath) self.tell_command(mds_rank, command, success_validator) @@ -247,14 +246,14 @@ class TestScrubChecks(CephFSTestCase): if run_seq == 0: log.info("First run: flushing {filepath}".format(filepath=filepath)) command = "flush_path {filepath}".format(filepath=filepath) - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) command = "scrub start {filepath}".format(filepath=filepath) self.tell_command(mds_rank, command, success_validator) if run_seq == 0: log.info("First run: flushing base dir /") command = "flush_path /" - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) command = "scrub start /" self.tell_command(mds_rank, command, success_validator) @@ -263,7 +262,7 @@ class TestScrubChecks(CephFSTestCase): i=run_seq) self.mount_a.run_shell(["mkdir", new_dir]) command = "flush_path {dir}".format(dir=test_new_dir) - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) new_file = "{repo_path}/new_file_{i}".format(repo_path=repo_path, i=run_seq) @@ -272,7 +271,7 @@ class TestScrubChecks(CephFSTestCase): self.mount_a.write_n_mb(new_file, 1) command = "flush_path {file}".format(file=test_new_file) - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) # check that scrub fails on errors ino = self.mount_a.path_to_ino(new_file) @@ -296,7 +295,7 @@ class TestScrubChecks(CephFSTestCase): self.assertTrue(_check_and_clear_damage(ino, "backtrace")); command = "flush_path /" - self.asok_command(mds_rank, command, success_validator) + self.tell_command(mds_rank, command, success_validator) def scrub_with_stray_evaluation(self, fs, mnt, path, flag, files=2000, _hard_links=3): @@ -472,7 +471,7 @@ class TestScrubChecks(CephFSTestCase): log.info("Running command '{command}'".format(command=command)) command_list = command.split() - jout = self.fs.rank_tell(command_list, rank=mds_rank) + jout = self.fs.rank_tell(command_list, rank=mds_rank, check_status=False) log.info("command '{command}' returned '{jout}'".format( command=command, jout=jout)) @@ -482,33 +481,6 @@ class TestScrubChecks(CephFSTestCase): raise AsokCommandFailedError(command, 0, jout, errstring) return jout - def asok_command(self, mds_rank, command, validator): - log.info("Running command '{command}'".format(command=command)) - - command_list = command.split() - - # we just assume there's an active mds for every rank - mds_id = self.fs.get_active_names()[mds_rank] - proc = self.fs.mon_manager.admin_socket('mds', mds_id, - command_list, check_status=False) - rout = proc.exitstatus - sout = proc.stdout.getvalue() - - if sout.strip(): - jout = json.loads(sout) - else: - jout = None - - log.info("command '{command}' got response code '{rout}' and stdout '{sout}'".format( - command=command, rout=rout, sout=sout)) - - success, errstring = validator(jout, rout) - - if not success: - raise AsokCommandFailedError(command, rout, jout, errstring) - - return jout - @staticmethod def clone_repo(client_mount, path): repo = "ceph-qa-suite" -- 2.39.5