qa/tasks: do not random.choice(a_view)

use `random.sample()` instead of `random.choice(list(a_view))` for better performance.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2020-04-02 13:29:45 +08:00
parent 0930652318
commit 9ca45bd942
2 changed files with 2 additions and 2 deletions

View 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):
"""

View 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)