Skip to content

Commit c176143

Browse files
qa/cephfs: move tests for "snapshot getpath" cmd to a separate class
Signed-off-by: Rishabh Dave <[email protected]>
1 parent 1224fd4 commit c176143

File tree

2 files changed

+121
-117
lines changed

2 files changed

+121
-117
lines changed

qa/suites/fs/volumes/tasks/volumes/test/snapshot.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ tasks:
44
modules:
55
- tasks.cephfs.test_volumes.TestSubvolumeGroupSnapshots
66
- tasks.cephfs.test_volumes.TestSubvolumeSnapshots
7+
- tasks.cephfs.test_volumes.TestSubvolumeSnapshotGetpath

qa/tasks/cephfs/test_volumes.py

Lines changed: 120 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -5214,123 +5214,6 @@ def test_subvolume_snapshot_create_idempotence(self):
52145214
# verify trash dir is clean
52155215
self._wait_for_trash_empty()
52165216

5217-
def get_subvol_uuid(self, subvol_name, group_name=None):
5218-
'''
5219-
Return the UUID directory component obtained from the path of
5220-
subvolume.
5221-
'''
5222-
if group_name:
5223-
cmd = (f'fs subvolume getpath {self.volname} {subvol_name} '
5224-
f'{group_name}')
5225-
else:
5226-
cmd = f'fs subvolume getpath {self.volname} {subvol_name}'
5227-
5228-
subvol_path = self.get_ceph_cmd_stdout(cmd).strip()
5229-
5230-
subvol_uuid = os.path.basename(subvol_path)
5231-
return subvol_uuid
5232-
5233-
def test_snapshot_getpath(self):
5234-
'''
5235-
Test that "ceph fs subvolume snapshot getpath" command returns path to
5236-
the specified snapshot in the specified subvolume.
5237-
'''
5238-
subvol_name = self._gen_subvol_name()
5239-
snap_name = self._gen_subvol_snap_name()
5240-
5241-
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
5242-
sv_uuid = self.get_subvol_uuid(subvol_name)
5243-
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5244-
f'{subvol_name} {snap_name}')
5245-
5246-
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5247-
f'{self.volname} {subvol_name} '
5248-
f'{snap_name}').strip()
5249-
# expected snapshot path
5250-
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
5251-
'.snap', snap_name, sv_uuid)
5252-
self.assertEqual(snap_path, exp_snap_path)
5253-
5254-
def test_snapshot_getpath_in_group(self):
5255-
'''
5256-
Test that "ceph fs subvolume snapshot getpath" command returns path to
5257-
the specified snapshot in the specified subvolume in the specified
5258-
group.
5259-
'''
5260-
subvol_name = self._gen_subvol_name()
5261-
group_name = self._gen_subvol_grp_name()
5262-
snap_name = self._gen_subvol_snap_name()
5263-
5264-
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
5265-
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
5266-
f'{group_name}')
5267-
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
5268-
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5269-
f'{subvol_name} {snap_name} {group_name}')
5270-
5271-
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5272-
f'{self.volname} {subvol_name} '
5273-
f'{snap_name} {group_name}')\
5274-
.strip()
5275-
# expected snapshot path
5276-
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
5277-
'.snap', snap_name, sv_uuid)
5278-
self.assertEqual(snap_path, exp_snap_path)
5279-
5280-
def test_snapshot_getpath_on_retained_subvol(self):
5281-
'''
5282-
Test that "ceph fs subvolume snapshot getpath" command returns path to
5283-
the specified snapshot in the specified subvolume that was deleted but
5284-
snapshots on which is retained.
5285-
'''
5286-
subvol_name = self._gen_subvol_name()
5287-
snap_name = self._gen_subvol_snap_name()
5288-
5289-
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
5290-
sv_uuid = self.get_subvol_uuid(subvol_name)
5291-
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5292-
f'{subvol_name} {snap_name}')
5293-
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
5294-
'--retain-snapshots')
5295-
5296-
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5297-
f'{self.volname} {subvol_name} '
5298-
f'{snap_name}').strip()
5299-
5300-
# expected snapshot path
5301-
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
5302-
'.snap', snap_name, sv_uuid)
5303-
self.assertEqual(snap_path, exp_snap_path)
5304-
5305-
def test_snapshot_getpath_on_retained_subvol_in_group(self):
5306-
'''
5307-
Test that "ceph fs subvolume snapshot getpath" command returns path to
5308-
the specified snapshot in the specified subvolume that was deleted but
5309-
snapshots on which is retained. And the deleted subvolume is located on
5310-
a non-default group.
5311-
'''
5312-
subvol_name = self._gen_subvol_name()
5313-
group_name = self._gen_subvol_grp_name()
5314-
snap_name = self._gen_subvol_snap_name()
5315-
5316-
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
5317-
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
5318-
f'{group_name}')
5319-
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
5320-
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5321-
f'{subvol_name} {snap_name} {group_name}')
5322-
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
5323-
f'{group_name} --retain-snapshots')
5324-
5325-
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5326-
f'{self.volname} {subvol_name} '
5327-
f'{snap_name} {group_name}')\
5328-
.strip()
5329-
# expected snapshot path
5330-
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
5331-
'.snap', snap_name, sv_uuid)
5332-
self.assertEqual(snap_path, exp_snap_path)
5333-
53345217
def test_subvolume_snapshot_info(self):
53355218

53365219
"""
@@ -6603,6 +6486,126 @@ def test_clean_stale_subvolume_snapshot_metadata(self):
66036486
self.mount_a.run_shell(['sudo', 'rm', '-f', tmp_meta_path], omit_sudo=False)
66046487

66056488

6489+
class TestSubvolumeSnapshotGetpath(TestVolumesHelper):
6490+
6491+
def get_subvol_uuid(self, subvol_name, group_name=None):
6492+
'''
6493+
Return the UUID directory component obtained from the path of
6494+
subvolume.
6495+
'''
6496+
if group_name:
6497+
cmd = (f'fs subvolume getpath {self.volname} {subvol_name} '
6498+
f'{group_name}')
6499+
else:
6500+
cmd = f'fs subvolume getpath {self.volname} {subvol_name}'
6501+
6502+
subvol_path = self.get_ceph_cmd_stdout(cmd).strip()
6503+
6504+
subvol_uuid = os.path.basename(subvol_path)
6505+
return subvol_uuid
6506+
6507+
def test_snapshot_getpath(self):
6508+
'''
6509+
Test that "ceph fs subvolume snapshot getpath" command returns path to
6510+
the specified snapshot in the specified subvolume.
6511+
'''
6512+
subvol_name = self._gen_subvol_name()
6513+
snap_name = self._gen_subvol_snap_name()
6514+
6515+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
6516+
sv_uuid = self.get_subvol_uuid(subvol_name)
6517+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
6518+
f'{subvol_name} {snap_name}')
6519+
6520+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
6521+
f'{self.volname} {subvol_name} '
6522+
f'{snap_name}').strip()
6523+
# expected snapshot path
6524+
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
6525+
'.snap', snap_name, sv_uuid)
6526+
self.assertEqual(snap_path, exp_snap_path)
6527+
6528+
def test_snapshot_getpath_in_group(self):
6529+
'''
6530+
Test that "ceph fs subvolume snapshot getpath" command returns path to
6531+
the specified snapshot in the specified subvolume in the specified
6532+
group.
6533+
'''
6534+
subvol_name = self._gen_subvol_name()
6535+
group_name = self._gen_subvol_grp_name()
6536+
snap_name = self._gen_subvol_snap_name()
6537+
6538+
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
6539+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
6540+
f'{group_name}')
6541+
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
6542+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
6543+
f'{subvol_name} {snap_name} {group_name}')
6544+
6545+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
6546+
f'{self.volname} {subvol_name} '
6547+
f'{snap_name} {group_name}')\
6548+
.strip()
6549+
# expected snapshot path
6550+
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
6551+
'.snap', snap_name, sv_uuid)
6552+
self.assertEqual(snap_path, exp_snap_path)
6553+
6554+
def test_snapshot_getpath_on_retained_subvol(self):
6555+
'''
6556+
Test that "ceph fs subvolume snapshot getpath" command returns path to
6557+
the specified snapshot in the specified subvolume that was deleted but
6558+
snapshots on which is retained.
6559+
'''
6560+
subvol_name = self._gen_subvol_name()
6561+
snap_name = self._gen_subvol_snap_name()
6562+
6563+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
6564+
sv_uuid = self.get_subvol_uuid(subvol_name)
6565+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
6566+
f'{subvol_name} {snap_name}')
6567+
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
6568+
'--retain-snapshots')
6569+
6570+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
6571+
f'{self.volname} {subvol_name} '
6572+
f'{snap_name}').strip()
6573+
6574+
# expected snapshot path
6575+
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
6576+
'.snap', snap_name, sv_uuid)
6577+
self.assertEqual(snap_path, exp_snap_path)
6578+
6579+
def test_snapshot_getpath_on_retained_subvol_in_group(self):
6580+
'''
6581+
Test that "ceph fs subvolume snapshot getpath" command returns path to
6582+
the specified snapshot in the specified subvolume that was deleted but
6583+
snapshots on which is retained. And the deleted subvolume is located on
6584+
a non-default group.
6585+
'''
6586+
subvol_name = self._gen_subvol_name()
6587+
group_name = self._gen_subvol_grp_name()
6588+
snap_name = self._gen_subvol_snap_name()
6589+
6590+
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
6591+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
6592+
f'{group_name}')
6593+
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
6594+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
6595+
f'{subvol_name} {snap_name} {group_name}')
6596+
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
6597+
f'{group_name} --retain-snapshots')
6598+
6599+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
6600+
f'{self.volname} {subvol_name} '
6601+
f'{snap_name} {group_name}')\
6602+
.strip()
6603+
# expected snapshot path
6604+
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
6605+
'.snap', snap_name, sv_uuid)
6606+
self.assertEqual(snap_path, exp_snap_path)
6607+
6608+
66066609
class TestSubvolumeSnapshotClones(TestVolumesHelper):
66076610
""" Tests for FS subvolume snapshot clone operations."""
66086611
def test_clone_subvolume_info(self):

0 commit comments

Comments
 (0)