From: Venky Shankar Date: Tue, 4 Sep 2018 06:20:54 +0000 (-0400) Subject: test: make rank argument mandatory when running journal_tool X-Git-Tag: v12.2.11~96^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d1c74ee51eb67faef23c1dbdc6af16356dce8fa8;p=ceph.git test: make rank argument mandatory when running journal_tool Also, fix a bunch of quirky journal_tool invocations that pass "--rank" argument as the command argument rather than passing it as function argument. Signed-off-by: Venky Shankar (cherry picked from commit f65193d95534dd34b593c92e1848b181737b0561) --- diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 7f9253aabc29..55eaa0477644 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -1166,6 +1166,9 @@ class Filesystem(MDSCluster): """ return "" + def _make_rank(self, rank): + return "{}:{}".format(self.name, rank) + def _run_tool(self, tool, args, rank=None, quiet=False): # Tests frequently have [client] configuration that jacks up # the objecter log level (unlikely to be interesting here) @@ -1176,7 +1179,7 @@ class Filesystem(MDSCluster): base_args = [os.path.join(self._prefix, tool), '--debug-mds=4', '--debug-objecter=1'] if rank is not None: - base_args.extend(["--rank", "%d" % rank]) + base_args.extend(["--rank", "%s" % str(rank)]) t1 = datetime.datetime.now() r = self.tool_remote.run( @@ -1198,11 +1201,12 @@ class Filesystem(MDSCluster): mds_id = self.mds_ids[0] return self.mds_daemons[mds_id].remote - def journal_tool(self, args, rank=None, quiet=False): + def journal_tool(self, args, rank, quiet=False): """ - Invoke cephfs-journal-tool with the passed arguments, and return its stdout + Invoke cephfs-journal-tool with the passed arguments for a rank, and return its stdout """ - return self._run_tool("cephfs-journal-tool", args, rank, quiet) + fs_rank = self._make_rank(rank) + return self._run_tool("cephfs-journal-tool", args, fs_rank, quiet) def table_tool(self, args, quiet=False): """ diff --git a/qa/tasks/cephfs/test_damage.py b/qa/tasks/cephfs/test_damage.py index 380b49c4b658..b2c606785be3 100644 --- a/qa/tasks/cephfs/test_damage.py +++ b/qa/tasks/cephfs/test_damage.py @@ -480,7 +480,7 @@ class TestDamage(CephFSTestCase): # Drop everything from the MDS cache self.mds_cluster.mds_stop() - self.fs.journal_tool(['journal', 'reset']) + self.fs.journal_tool(['journal', 'reset'], 0) self.mds_cluster.mds_fail_restart() self.fs.wait_for_daemons() diff --git a/qa/tasks/cephfs/test_data_scan.py b/qa/tasks/cephfs/test_data_scan.py index a2d315768aa0..1e7745541888 100644 --- a/qa/tasks/cephfs/test_data_scan.py +++ b/qa/tasks/cephfs/test_data_scan.py @@ -362,9 +362,9 @@ class TestDataScan(CephFSTestCase): if False: with self.assertRaises(CommandFailedError): # Normal reset should fail when no objects are present, we'll use --force instead - self.fs.journal_tool(["journal", "reset"]) + self.fs.journal_tool(["journal", "reset"], 0) - self.fs.journal_tool(["journal", "reset", "--force"]) + self.fs.journal_tool(["journal", "reset", "--force"], 0) self.fs.data_scan(["init"]) self.fs.data_scan(["scan_extents", self.fs.get_data_pool_name()], worker_count=workers) self.fs.data_scan(["scan_inodes", self.fs.get_data_pool_name()], worker_count=workers) diff --git a/qa/tasks/cephfs/test_flush.py b/qa/tasks/cephfs/test_flush.py index 1f84e4200a39..ee0b1c92b199 100644 --- a/qa/tasks/cephfs/test_flush.py +++ b/qa/tasks/cephfs/test_flush.py @@ -44,7 +44,7 @@ class TestFlush(CephFSTestCase): # ...and the journal is truncated to just a single subtreemap from the # newly created segment - summary_output = self.fs.journal_tool(["event", "get", "summary"]) + summary_output = self.fs.journal_tool(["event", "get", "summary"], 0) try: self.assertEqual(summary_output, dedent( @@ -72,7 +72,7 @@ class TestFlush(CephFSTestCase): ).strip()) flush_data = self.fs.mds_asok(["flush", "journal"]) self.assertEqual(flush_data['return_code'], 0) - self.assertEqual(self.fs.journal_tool(["event", "get", "summary"]), + self.assertEqual(self.fs.journal_tool(["event", "get", "summary"], 0), dedent( """ Events by type: diff --git a/qa/tasks/cephfs/test_forward_scrub.py b/qa/tasks/cephfs/test_forward_scrub.py index 1f80366af0cf..e165780f31f1 100644 --- a/qa/tasks/cephfs/test_forward_scrub.py +++ b/qa/tasks/cephfs/test_forward_scrub.py @@ -242,10 +242,10 @@ class TestForwardScrub(CephFSTestCase): # is all that will be in the InoTable in memory) self.fs.journal_tool(["event", "splice", - "--inode={0}".format(inos["./file2_sixmegs"]), "summary"]) + "--inode={0}".format(inos["./file2_sixmegs"]), "summary"], 0) self.fs.journal_tool(["event", "splice", - "--inode={0}".format(inos["./file3_sixmegs"]), "summary"]) + "--inode={0}".format(inos["./file3_sixmegs"]), "summary"], 0) # Revert to old inotable. for key, value in inotable_copy.iteritems(): diff --git a/qa/tasks/cephfs/test_journal_migration.py b/qa/tasks/cephfs/test_journal_migration.py index 64fe939804ee..5f956be93aaa 100644 --- a/qa/tasks/cephfs/test_journal_migration.py +++ b/qa/tasks/cephfs/test_journal_migration.py @@ -82,13 +82,14 @@ class TestJournalMigration(CephFSTestCase): )) # Verify that cephfs-journal-tool can now read the rewritten journal - inspect_out = self.fs.journal_tool(["journal", "inspect"]) + inspect_out = self.fs.journal_tool(["journal", "inspect"], 0) if not inspect_out.endswith(": OK"): raise RuntimeError("Unexpected journal-tool result: '{0}'".format( inspect_out )) - self.fs.journal_tool(["event", "get", "json", "--path", "/tmp/journal.json"]) + self.fs.journal_tool(["event", "get", "json", + "--path", "/tmp/journal.json"], 0) p = self.fs.tool_remote.run( args=[ "python", diff --git a/qa/tasks/cephfs/test_journal_repair.py b/qa/tasks/cephfs/test_journal_repair.py index 62cbbb0684a7..9832f91a10ac 100644 --- a/qa/tasks/cephfs/test_journal_repair.py +++ b/qa/tasks/cephfs/test_journal_repair.py @@ -77,7 +77,7 @@ class TestJournalRepair(CephFSTestCase): self.assertEqual(self.fs.list_dirfrag(ROOT_INO), []) # Execute the dentry recovery, this should populate the backing store - self.fs.journal_tool(['event', 'recover_dentries', 'list']) + self.fs.journal_tool(['event', 'recover_dentries', 'list'], 0) # Dentries in ROOT_INO are present self.assertEqual(sorted(self.fs.list_dirfrag(ROOT_INO)), sorted(['rootfile_head', 'subdir_head', 'linkdir_head'])) @@ -87,7 +87,7 @@ class TestJournalRepair(CephFSTestCase): # Now check the MDS can read what we wrote: truncate the journal # and start the mds. - self.fs.journal_tool(['journal', 'reset']) + self.fs.journal_tool(['journal', 'reset'], 0) self.fs.mds_fail_restart() self.fs.wait_for_daemons() @@ -265,10 +265,10 @@ class TestJournalRepair(CephFSTestCase): self.fs.mds_stop(active_mds_names[0]) self.fs.mds_fail(active_mds_names[0]) # Invoke recover_dentries quietly, because otherwise log spews millions of lines - self.fs.journal_tool(["event", "recover_dentries", "summary"], rank=0, quiet=True) - self.fs.journal_tool(["event", "recover_dentries", "summary"], rank=1, quiet=True) + self.fs.journal_tool(["event", "recover_dentries", "summary"], 0, quiet=True) + self.fs.journal_tool(["event", "recover_dentries", "summary"], 1, quiet=True) self.fs.table_tool(["0", "reset", "session"]) - self.fs.journal_tool(["journal", "reset"], rank=0) + self.fs.journal_tool(["journal", "reset"], 0) self.fs.erase_mds_objects(1) self.fs.mon_manager.raw_cluster_cmd('fs', 'reset', self.fs.name, '--yes-i-really-mean-it') diff --git a/qa/tasks/cephfs/test_recovery_pool.py b/qa/tasks/cephfs/test_recovery_pool.py index 097342a9d48b..664da40217e1 100644 --- a/qa/tasks/cephfs/test_recovery_pool.py +++ b/qa/tasks/cephfs/test_recovery_pool.py @@ -153,7 +153,7 @@ class TestRecoveryPool(CephFSTestCase): if False: with self.assertRaises(CommandFailedError): # Normal reset should fail when no objects are present, we'll use --force instead - self.fs.journal_tool(["journal", "reset"]) + self.fs.journal_tool(["journal", "reset"], 0) self.fs.mds_stop() self.fs.data_scan(['scan_extents', '--alternate-pool', @@ -163,22 +163,18 @@ class TestRecoveryPool(CephFSTestCase): recovery_pool, '--filesystem', self.fs.name, '--force-corrupt', '--force-init', self.fs.get_data_pool_name()]) - self.fs.journal_tool(['--rank=' + self.fs.name + ":0", 'event', - 'recover_dentries', 'list', - '--alternate-pool', recovery_pool]) + self.fs.journal_tool(['event', 'recover_dentries', 'list', + '--alternate-pool', recovery_pool], 0) self.fs.data_scan(['init', '--force-init', '--filesystem', self.fs.name]) self.fs.data_scan(['scan_inodes', '--filesystem', self.fs.name, '--force-corrupt', '--force-init', self.fs.get_data_pool_name()]) - self.fs.journal_tool(['--rank=' + self.fs.name + ":0", 'event', - 'recover_dentries', 'list']) + self.fs.journal_tool(['event', 'recover_dentries', 'list'], 0) - self.fs.journal_tool(['--rank=' + recovery_fs + ":0", 'journal', - 'reset', '--force']) - self.fs.journal_tool(['--rank=' + self.fs.name + ":0", 'journal', - 'reset', '--force']) + self.recovery_fs.journal_tool(['journal', 'reset', '--force'], 0) + self.fs.journal_tool(['journal', 'reset', '--force'], 0) self.fs.mon_manager.raw_cluster_cmd('mds', 'repaired', recovery_fs + ":0") diff --git a/qa/workunits/suites/cephfs_journal_tool_smoke.sh b/qa/workunits/suites/cephfs_journal_tool_smoke.sh index 60e91496511f..7e4ad3bd3f5d 100755 --- a/qa/workunits/suites/cephfs_journal_tool_smoke.sh +++ b/qa/workunits/suites/cephfs_journal_tool_smoke.sh @@ -3,7 +3,7 @@ set -e set -x -export BIN="${BIN:-cephfs-journal-tool}" +export BIN="${BIN:-cephfs-journal-tool --rank=cephfs:0}" export JOURNAL_FILE=/tmp/journal.bin export JSON_OUTPUT=/tmp/json.tmp export BINARY_OUTPUT=/tmp/binary.tmp