Skip to content

Commit 870cbf6

Browse files
qa/cephfs: add tests for "subvolume snapshot getpath" cmd
Signed-off-by: Rishabh Dave <[email protected]>
1 parent 50d2899 commit 870cbf6

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

qa/tasks/cephfs/test_volumes.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5111,6 +5111,123 @@ def test_subvolume_snapshot_create_idempotence(self):
51115111
# verify trash dir is clean
51125112
self._wait_for_trash_empty()
51135113

5114+
def get_subvol_uuid(self, subvol_name, group_name=None):
5115+
'''
5116+
Return the UUID directory component obtained from the path of
5117+
subvolume.
5118+
'''
5119+
if group_name:
5120+
cmd = (f'fs subvolume getpath {self.volname} {subvol_name} '
5121+
f'{group_name}')
5122+
else:
5123+
cmd = f'fs subvolume getpath {self.volname} {subvol_name}'
5124+
5125+
subvol_path = self.get_ceph_cmd_stdout(cmd).strip()
5126+
5127+
subvol_uuid = os.path.basename(subvol_path)
5128+
return subvol_uuid
5129+
5130+
def test_snapshot_getpath(self):
5131+
'''
5132+
Test that "ceph fs subvolume snapshot getpath" command returns path to
5133+
the specified snapshot in the specified subvolume.
5134+
'''
5135+
subvol_name = self._gen_subvol_name()
5136+
snap_name = self._gen_subvol_snap_name()
5137+
5138+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
5139+
sv_uuid = self.get_subvol_uuid(subvol_name)
5140+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5141+
f'{subvol_name} {snap_name}')
5142+
5143+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5144+
f'{self.volname} {subvol_name} '
5145+
f'{snap_name}').strip()
5146+
# expected snapshot path
5147+
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
5148+
'.snap', snap_name, sv_uuid)
5149+
self.assertEqual(snap_path, exp_snap_path)
5150+
5151+
def test_snapshot_getpath_in_group(self):
5152+
'''
5153+
Test that "ceph fs subvolume snapshot getpath" command returns path to
5154+
the specified snapshot in the specified subvolume in the specified
5155+
group.
5156+
'''
5157+
subvol_name = self._gen_subvol_name()
5158+
group_name = self._gen_subvol_grp_name()
5159+
snap_name = self._gen_subvol_snap_name()
5160+
5161+
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
5162+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
5163+
f'{group_name}')
5164+
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
5165+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5166+
f'{subvol_name} {snap_name} {group_name}')
5167+
5168+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5169+
f'{self.volname} {subvol_name} '
5170+
f'{snap_name} {group_name}')\
5171+
.strip()
5172+
# expected snapshot path
5173+
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
5174+
'.snap', snap_name, sv_uuid)
5175+
self.assertEqual(snap_path, exp_snap_path)
5176+
5177+
def test_snapshot_getpath_on_retained_subvol(self):
5178+
'''
5179+
Test that "ceph fs subvolume snapshot getpath" command returns path to
5180+
the specified snapshot in the specified subvolume that was deleted but
5181+
snapshots on which is retained.
5182+
'''
5183+
subvol_name = self._gen_subvol_name()
5184+
snap_name = self._gen_subvol_snap_name()
5185+
5186+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name}')
5187+
sv_uuid = self.get_subvol_uuid(subvol_name)
5188+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5189+
f'{subvol_name} {snap_name}')
5190+
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
5191+
'--retain-snapshots')
5192+
5193+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5194+
f'{self.volname} {subvol_name} '
5195+
f'{snap_name}').strip()
5196+
5197+
# expected snapshot path
5198+
exp_snap_path = os.path.join('/volumes', '_nogroup', subvol_name,
5199+
'.snap', snap_name, sv_uuid)
5200+
self.assertEqual(snap_path, exp_snap_path)
5201+
5202+
def test_snapshot_getpath_on_retained_subvol_in_group(self):
5203+
'''
5204+
Test that "ceph fs subvolume snapshot getpath" command returns path to
5205+
the specified snapshot in the specified subvolume that was deleted but
5206+
snapshots on which is retained. And the deleted subvolume is located on
5207+
a non-default group.
5208+
'''
5209+
subvol_name = self._gen_subvol_name()
5210+
group_name = self._gen_subvol_grp_name()
5211+
snap_name = self._gen_subvol_snap_name()
5212+
5213+
self.run_ceph_cmd(f'fs subvolumegroup create {self.volname} {group_name}')
5214+
self.run_ceph_cmd(f'fs subvolume create {self.volname} {subvol_name} '
5215+
f'{group_name}')
5216+
sv_uuid = self.get_subvol_uuid(subvol_name, group_name)
5217+
self.run_ceph_cmd(f'fs subvolume snapshot create {self.volname} '
5218+
f'{subvol_name} {snap_name} {group_name}')
5219+
self.run_ceph_cmd(f'fs subvolume rm {self.volname} {subvol_name} '
5220+
f'{group_name} --retain-snapshots')
5221+
5222+
snap_path = self.get_ceph_cmd_stdout(f'fs subvolume snapshot getpath '
5223+
f'{self.volname} {subvol_name} '
5224+
f'{snap_name} {group_name}')\
5225+
.strip()
5226+
# expected snapshot path
5227+
exp_snap_path = os.path.join('/volumes', group_name, subvol_name,
5228+
'.snap', snap_name, sv_uuid)
5229+
self.assertEqual(snap_path, exp_snap_path)
5230+
51145231
def test_subvolume_snapshot_info(self):
51155232

51165233
"""

0 commit comments

Comments
 (0)