@@ -5175,6 +5175,123 @@ def test_subvolume_snapshot_create_idempotence(self):
51755175 # verify trash dir is clean
51765176 self ._wait_for_trash_empty ()
51775177
5178+ def get_subvol_uuid (self , subvol_name , group_name = None ):
5179+ '''
5180+ Return the UUID directory component obtained from the path of
5181+ subvolume.
5182+ '''
5183+ if group_name :
5184+ cmd = (f'fs subvolume getpath { self .volname } { subvol_name } '
5185+ f'{ group_name } ' )
5186+ else :
5187+ cmd = f'fs subvolume getpath { self .volname } { subvol_name } '
5188+
5189+ subvol_path = self .get_ceph_cmd_stdout (cmd ).strip ()
5190+
5191+ subvol_uuid = os .path .basename (subvol_path )
5192+ return subvol_uuid
5193+
5194+ def test_snapshot_getpath (self ):
5195+ '''
5196+ Test that "ceph fs subvolume snapshot getpath" command returns path to
5197+ the specified snapshot in the specified subvolume.
5198+ '''
5199+ subvol_name = self ._gen_subvol_name ()
5200+ snap_name = self ._gen_subvol_snap_name ()
5201+
5202+ self .run_ceph_cmd (f'fs subvolume create { self .volname } { subvol_name } ' )
5203+ sv_uuid = self .get_subvol_uuid (subvol_name )
5204+ self .run_ceph_cmd (f'fs subvolume snapshot create { self .volname } '
5205+ f'{ subvol_name } { snap_name } ' )
5206+
5207+ snap_path = self .get_ceph_cmd_stdout (f'fs subvolume snapshot getpath '
5208+ f'{ self .volname } { subvol_name } '
5209+ f'{ snap_name } ' ).strip ()
5210+ # expected snapshot path
5211+ exp_snap_path = os .path .join ('/volumes' , '_nogroup' , subvol_name ,
5212+ '.snap' , snap_name , sv_uuid )
5213+ self .assertEqual (snap_path , exp_snap_path )
5214+
5215+ def test_snapshot_getpath_in_group (self ):
5216+ '''
5217+ Test that "ceph fs subvolume snapshot getpath" command returns path to
5218+ the specified snapshot in the specified subvolume in the specified
5219+ group.
5220+ '''
5221+ subvol_name = self ._gen_subvol_name ()
5222+ group_name = self ._gen_subvol_grp_name ()
5223+ snap_name = self ._gen_subvol_snap_name ()
5224+
5225+ self .run_ceph_cmd (f'fs subvolumegroup create { self .volname } { group_name } ' )
5226+ self .run_ceph_cmd (f'fs subvolume create { self .volname } { subvol_name } '
5227+ f'{ group_name } ' )
5228+ sv_uuid = self .get_subvol_uuid (subvol_name , group_name )
5229+ self .run_ceph_cmd (f'fs subvolume snapshot create { self .volname } '
5230+ f'{ subvol_name } { snap_name } { group_name } ' )
5231+
5232+ snap_path = self .get_ceph_cmd_stdout (f'fs subvolume snapshot getpath '
5233+ f'{ self .volname } { subvol_name } '
5234+ f'{ snap_name } { group_name } ' )\
5235+ .strip ()
5236+ # expected snapshot path
5237+ exp_snap_path = os .path .join ('/volumes' , group_name , subvol_name ,
5238+ '.snap' , snap_name , sv_uuid )
5239+ self .assertEqual (snap_path , exp_snap_path )
5240+
5241+ def test_snapshot_getpath_on_retained_subvol (self ):
5242+ '''
5243+ Test that "ceph fs subvolume snapshot getpath" command returns path to
5244+ the specified snapshot in the specified subvolume that was deleted but
5245+ snapshots on which is retained.
5246+ '''
5247+ subvol_name = self ._gen_subvol_name ()
5248+ snap_name = self ._gen_subvol_snap_name ()
5249+
5250+ self .run_ceph_cmd (f'fs subvolume create { self .volname } { subvol_name } ' )
5251+ sv_uuid = self .get_subvol_uuid (subvol_name )
5252+ self .run_ceph_cmd (f'fs subvolume snapshot create { self .volname } '
5253+ f'{ subvol_name } { snap_name } ' )
5254+ self .run_ceph_cmd (f'fs subvolume rm { self .volname } { subvol_name } '
5255+ '--retain-snapshots' )
5256+
5257+ snap_path = self .get_ceph_cmd_stdout (f'fs subvolume snapshot getpath '
5258+ f'{ self .volname } { subvol_name } '
5259+ f'{ snap_name } ' ).strip ()
5260+
5261+ # expected snapshot path
5262+ exp_snap_path = os .path .join ('/volumes' , '_nogroup' , subvol_name ,
5263+ '.snap' , snap_name , sv_uuid )
5264+ self .assertEqual (snap_path , exp_snap_path )
5265+
5266+ def test_snapshot_getpath_on_retained_subvol_in_group (self ):
5267+ '''
5268+ Test that "ceph fs subvolume snapshot getpath" command returns path to
5269+ the specified snapshot in the specified subvolume that was deleted but
5270+ snapshots on which is retained. And the deleted subvolume is located on
5271+ a non-default group.
5272+ '''
5273+ subvol_name = self ._gen_subvol_name ()
5274+ group_name = self ._gen_subvol_grp_name ()
5275+ snap_name = self ._gen_subvol_snap_name ()
5276+
5277+ self .run_ceph_cmd (f'fs subvolumegroup create { self .volname } { group_name } ' )
5278+ self .run_ceph_cmd (f'fs subvolume create { self .volname } { subvol_name } '
5279+ f'{ group_name } ' )
5280+ sv_uuid = self .get_subvol_uuid (subvol_name , group_name )
5281+ self .run_ceph_cmd (f'fs subvolume snapshot create { self .volname } '
5282+ f'{ subvol_name } { snap_name } { group_name } ' )
5283+ self .run_ceph_cmd (f'fs subvolume rm { self .volname } { subvol_name } '
5284+ f'{ group_name } --retain-snapshots' )
5285+
5286+ snap_path = self .get_ceph_cmd_stdout (f'fs subvolume snapshot getpath '
5287+ f'{ self .volname } { subvol_name } '
5288+ f'{ snap_name } { group_name } ' )\
5289+ .strip ()
5290+ # expected snapshot path
5291+ exp_snap_path = os .path .join ('/volumes' , group_name , subvol_name ,
5292+ '.snap' , snap_name , sv_uuid )
5293+ self .assertEqual (snap_path , exp_snap_path )
5294+
51785295 def test_subvolume_snapshot_info (self ):
51795296
51805297 """
0 commit comments