Skip to content

Commit

Permalink
qa: Fix name collisions
Browse files Browse the repository at this point in the history
Addresses the name collisions of volumes, subvolumes,
clones, subvolume groups and snapshots within the tests.

Fixes: https://tracker.ceph.com/issues/43517
Signed-off-by: Kotresh HR <[email protected]>
  • Loading branch information
kotreshhr committed Jul 14, 2020
1 parent 1ac5c74 commit 3b6f6f1
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions qa/tasks/cephfs/test_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,33 @@ def _verify_clone(self, subvolume, clone, source_group=None, clone_group=None, t
self._verify_clone_attrs(subvolume, clone, source_group=source_group, clone_group=clone_group)

def _generate_random_volume_name(self, count=1):
r = random.sample(range(10000), count)
volumes = ["{0}_{1}".format(TestVolumes.TEST_VOLUME_PREFIX, c) for c in r]
n = self.volume_start
volumes = [f"{TestVolumes.TEST_VOLUME_PREFIX}_{i:016}" for i in range(n, n+count)]
self.volume_start += count
return volumes[0] if count == 1 else volumes

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]
n = self.subvolume_start
subvolumes = [f"{TestVolumes.TEST_SUBVOLUME_PREFIX}_{i:016}" for i in range(n, n+count)]
self.subvolume_start += count
return subvolumes[0] if count == 1 else subvolumes

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]
n = self.group_start
groups = [f"{TestVolumes.TEST_GROUP_PREFIX}_{i:016}" for i in range(n, n+count)]
self.group_start += count
return groups[0] if count == 1 else groups

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]
n = self.snapshot_start
snaps = [f"{TestVolumes.TEST_SNAPSHOT_PREFIX}_{i:016}" for i in range(n, n+count)]
self.snapshot_start += count
return snaps[0] if count == 1 else snaps

def _generate_random_clone_name(self, count=1):
r = random.sample(range(1000), count)
clones = ["{0}_{1}".format(TestVolumes.TEST_CLONE_PREFIX, c) for c in r]
n = self.clone_start
clones = [f"{TestVolumes.TEST_CLONE_PREFIX}_{i:016}" for i in range(n, n+count)]
self.clone_start += count
return clones[0] if count == 1 else clones

def _enable_multi_fs(self):
Expand Down Expand Up @@ -228,6 +233,11 @@ def setUp(self):
self._enable_multi_fs()
self._create_or_reuse_test_volume()
self.config_set('mon', 'mon_allow_pool_delete', True)
self.volume_start = random.randint(1, (1<<20))
self.subvolume_start = random.randint(1, (1<<20))
self.group_start = random.randint(1, (1<<20))
self.snapshot_start = random.randint(1, (1<<20))
self.clone_start = random.randint(1, (1<<20))

def tearDown(self):
if self.vol_created:
Expand Down Expand Up @@ -666,8 +676,8 @@ def test_subvolumegroup_pin_distributed(self):
self._fs_cmd("subvolumegroup", "pin", self.volname, group, "distributed", "True")
# (no effect on distribution) pin the group directory to 0 so rank 0 has all subtree bounds visible
self._fs_cmd("subvolumegroup", "pin", self.volname, group, "export", "0")
for i in range(10):
subvolume = self._generate_random_subvolume_name()
subvolumes = self._generate_random_subvolume_name(10)
for subvolume in subvolumes:
self._fs_cmd("subvolume", "create", self.volname, subvolume, "--group_name", group)
self._wait_distributed_subtrees(10, status=status)

Expand Down Expand Up @@ -1001,8 +1011,7 @@ def test_subvolume_create_and_rm_in_group(self):
self._fs_cmd("subvolumegroup", "rm", self.volname, group)

def test_subvolume_group_create_with_desired_data_pool_layout(self):
group1 = self._generate_random_group_name()
group2 = self._generate_random_group_name()
group1, group2 = self._generate_random_group_name(2)

# create group
self._fs_cmd("subvolumegroup", "create", self.volname, group1)
Expand Down Expand Up @@ -1063,8 +1072,7 @@ def test_subvolume_group_create_with_auto_cleanup_on_fail(self):
raise RuntimeError("expected the 'fs subvolumegroup getpath' command to fail")

def test_subvolume_create_with_desired_data_pool_layout_in_group(self):
subvol1 = self._generate_random_subvolume_name()
subvol2 = self._generate_random_subvolume_name()
subvol1, subvol2 = self._generate_random_subvolume_name(2)
group = self._generate_random_group_name()

# create group. this also helps set default pool layout for subvolumes
Expand Down Expand Up @@ -1095,8 +1103,7 @@ def test_subvolume_create_with_desired_data_pool_layout_in_group(self):
self._fs_cmd("subvolumegroup", "rm", self.volname, group)

def test_subvolume_group_create_with_desired_mode(self):
group1 = self._generate_random_group_name()
group2 = self._generate_random_group_name()
group1, group2 = self._generate_random_group_name(2)
# default mode
expected_mode1 = "755"
# desired mode
Expand Down Expand Up @@ -1144,9 +1151,8 @@ def test_subvolume_group_create_with_desired_uid_gid(self):
self._fs_cmd("subvolumegroup", "rm", self.volname, subvolgroupname)

def test_subvolume_create_with_desired_mode_in_group(self):
subvol1 = self._generate_random_subvolume_name()
subvol2 = self._generate_random_subvolume_name()
subvol3 = self._generate_random_subvolume_name()
subvol1, subvol2, subvol3 = self._generate_random_subvolume_name(3)

group = self._generate_random_group_name()
# default mode
expected_mode1 = "755"
Expand Down

0 comments on commit 3b6f6f1

Please sign in to comment.