]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks: do not random.choice(a_view)
authorKefu Chai <kchai@redhat.com>
Thu, 2 Apr 2020 05:29:45 +0000 (13:29 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 14 Jun 2020 08:34:51 +0000 (16:34 +0800)
use `random.sample()` instead of `random.choice(list(a_view))` for better performance.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 9ca45bd942ef1ed0d7ed61d87caffdfc97e54e5e)

qa/tasks/ceph_manager.py
qa/tasks/cephfs/test_dump_tree.py

index 5742cff7528662386d3f6ca22ffb9a1f186ea0ba..3d0b4845e8498880faeac95f2536676153a59aa6 100644 (file)
@@ -1965,7 +1965,7 @@ class CephManager:
         """
         with self.lock:
             if self.pools:
-                return random.choice(self.pools.keys())
+                return random.sample(self.pools.keys(), 1)[0]
 
     def get_pool_pg_num(self, pool_name):
         """
index 6d943f9dd2ff337b13ac72cd84d8d8198833bb82..48a2c6f00acb55753f06b34ad48a128100334441 100644 (file)
@@ -39,7 +39,7 @@ class TestDumpTree(CephFSTestCase):
 
         self.populate()
         inos = self.get_paths_to_ino()
-        target = random.choice(inos.keys())
+        target = random.sample(inos.keys(), 1)[0]
 
         if target != "./":
             target = os.path.dirname(target)