From: Venky Shankar Date: Tue, 5 Nov 2019 08:37:41 +0000 (-0500) Subject: test: use distinct subvolume/group/snapshot names X-Git-Tag: v15.1.0~820^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b9cff8af8e8f423c8e2b58de2b4da48842223cf3;p=ceph.git test: use distinct subvolume/group/snapshot names Fixes: http://tracker.ceph.com/issues/42646 Signed-off-by: Venky Shankar --- diff --git a/qa/tasks/cephfs/test_volumes.py b/qa/tasks/cephfs/test_volumes.py index bb042b2cce69..be5d030e40e3 100644 --- a/qa/tasks/cephfs/test_volumes.py +++ b/qa/tasks/cephfs/test_volumes.py @@ -27,14 +27,20 @@ class TestVolumes(CephFSTestCase): def _fs_cmd(self, *args): return self.mgr_cluster.mon_manager.raw_cluster_cmd("fs", *args) - def _generate_random_subvolume_name(self): - return "{0}_{1}".format(TestVolumes.TEST_SUBVOLUME_PREFIX, random.randint(0, 10000)) + def _generate_random_subvolume_name(self, count=1): + r = random.sample(range(10000), count) + subvolumes = ["{0}_{1}".format(TestVolumes.TEST_SUBVOLUME_PREFIX, c) for c in r] + return subvolumes[0] if count == 1 else subvolumes - def _generate_random_group_name(self): - return "{0}_{1}".format(TestVolumes.TEST_GROUP_PREFIX, random.randint(0, 100)) + def _generate_random_group_name(self, count=1): + r = random.sample(range(100), count) + groups = ["{0}_{1}".format(TestVolumes.TEST_GROUP_PREFIX, c) for c in r] + return groups[0] if count == 1 else groups - def _generate_random_snapshot_name(self): - return "{0}_{1}".format(TestVolumes.TEST_SNAPSHOT_PREFIX, random.randint(0, 100)) + def _generate_random_snapshot_name(self, count=1): + r = random.sample(range(100), count) + snaps = ["{0}_{1}".format(TestVolumes.TEST_SNAPSHOT_PREFIX, c) for c in r] + return snaps[0] if count == 1 else snaps def _enable_multi_fs(self): self._fs_cmd("flag", "set", "enable_multiple", "true", "--yes-i-really-mean-it") @@ -464,10 +470,9 @@ class TestVolumes(CephFSTestCase): subvolumes = [] # create subvolumes - for i in range(3): - svname = self._generate_random_subvolume_name() - self._fs_cmd("subvolume", "create", self.volname, svname) - subvolumes.append(svname) + subvolumes = self._generate_random_subvolume_name(3) + for subvolume in subvolumes: + self._fs_cmd("subvolume", "create", self.volname, subvolume) # list subvolumes subvolumels = json.loads(self._fs_cmd('subvolume', 'ls', self.volname)) @@ -693,10 +698,9 @@ class TestVolumes(CephFSTestCase): subvolumegroups = [] #create subvolumegroups - for i in range(3): - groupname = self._generate_random_group_name() + subvolumegroups = self._generate_random_group_name(3) + for groupname in subvolumegroups: self._fs_cmd("subvolumegroup", "create", self.volname, groupname) - subvolumegroups.append(groupname) subvolumegroupls = json.loads(self._fs_cmd('subvolumegroup', 'ls', self.volname)) if len(subvolumegroupls) == 0: @@ -823,10 +827,9 @@ class TestVolumes(CephFSTestCase): self._fs_cmd("subvolume", "create", self.volname, subvolume) # create subvolume snapshots - for i in range(3): - sname = self._generate_random_snapshot_name() - self._fs_cmd("subvolume", "snapshot", "create", self.volname, subvolume, sname) - snapshots.append(sname) + snapshots = self._generate_random_snapshot_name(3) + for snapshot in snapshots: + self._fs_cmd("subvolume", "snapshot", "create", self.volname, subvolume, snapshot) subvolsnapshotls = json.loads(self._fs_cmd('subvolume', 'snapshot', 'ls', self.volname, subvolume)) if len(subvolsnapshotls) == 0: @@ -934,10 +937,9 @@ class TestVolumes(CephFSTestCase): self._fs_cmd("subvolumegroup", "create", self.volname, group) # create subvolumegroup snapshots - for i in range(3): - sname = self._generate_random_snapshot_name() - self._fs_cmd("subvolumegroup", "snapshot", "create", self.volname, group, sname) - snapshots.append(sname) + snapshots = self._generate_random_snapshot_name(3) + for snapshot in snapshots: + self._fs_cmd("subvolumegroup", "snapshot", "create", self.volname, group, snapshot) subvolgrpsnapshotls = json.loads(self._fs_cmd('subvolumegroup', 'snapshot', 'ls', self.volname, group)) if len(subvolgrpsnapshotls) == 0: