]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: make test_perf_stats_stale_metrics check only the clients created for the tests 45293/head
authorJos Collin <jcollin@redhat.com>
Thu, 24 Mar 2022 04:57:58 +0000 (10:27 +0530)
committerJos Collin <jcollin@redhat.com>
Fri, 10 Jun 2022 15:32:58 +0000 (21:02 +0530)
Uses the client's global id to get the metrics, instead of using the index.
This ensures that test_perf_stats_stale_metrics checks only the clients mounted for
the tests.

Fixes: https://tracker.ceph.com/issues/54971
Signed-off-by: Jos Collin <jcollin@redhat.com>
(cherry picked from commit 1621308214cd18750c8be803fc014bdf73e2218a)

qa/tasks/cephfs/test_mds_metrics.py

index 428cc71944adac566162b3bb18bed03e76498576..0d78e54faf0ae72fc362934f8bf3ebe4e637a633 100644 (file)
@@ -461,16 +461,17 @@ class TestMDSMetrics(CephFSTestCase):
         # validate
         valid, metrics = self._get_metrics(self.verify_mds_metrics(
             active_mds_count=1, client_count=TestMDSMetrics.CLIENTS_REQUIRED), 30)
-        log.debug("metrics={0}".format(metrics))
+        log.debug(f'metrics={metrics}')
         self.assertTrue(valid)
 
-        global_metrics = metrics['global_metrics']
+        #mount_a and mount_b are the clients mounted for TestMDSMetrics. So get their
+        #entries from the global_metrics.
+        client_a_name = f'client.{self.mount_a.get_global_id()}'
+        client_b_name = f'client.{self.mount_b.get_global_id()}'
 
-        #TestMDSMetrics.CLIENTS_REQUIRED clients are mounted here. So they should be
-        #the first two entries in the global_metrics and won't be culled later on.
-        gm_keys_list = list(global_metrics.keys())
-        client1_metrics = global_metrics[gm_keys_list[0]]
-        client2_metrics = global_metrics[gm_keys_list[1]]
+        global_metrics = metrics['global_metrics']
+        client_a_metrics = global_metrics[client_a_name]
+        client_b_metrics = global_metrics[client_b_name]
 
         #fail rank0 mds
         self.fs.rank_fail(rank=0)
@@ -494,16 +495,16 @@ class TestMDSMetrics(CephFSTestCase):
         try:
             valid, metrics_new = self._get_metrics(self.verify_mds_metrics(
                 active_mds_count=1, client_count=TestMDSMetrics.CLIENTS_REQUIRED), 30)
-            log.debug("metrics={0}".format(metrics_new))
+            log.debug(f'metrics={metrics_new}')
             self.assertTrue(valid)
 
             global_metrics = metrics_new['global_metrics']
-            client1_metrics_new = global_metrics[gm_keys_list[0]]
-            client2_metrics_new = global_metrics[gm_keys_list[1]]
+            client_a_metrics_new = global_metrics[client_a_name]
+            client_b_metrics_new = global_metrics[client_b_name]
 
             #the metrics should be different for the test to succeed.
-            self.assertNotEqual(client1_metrics, client1_metrics_new)
-            self.assertNotEqual(client2_metrics, client2_metrics_new)
+            self.assertNotEqual(client_a_metrics, client_a_metrics_new)
+            self.assertNotEqual(client_b_metrics, client_b_metrics_new)
         except MaxWhileTries:
             raise RuntimeError("Failed to fetch `ceph fs perf stats` metrics")
         finally: