From 82d46470516c5dbc54a0b352120f38e15f40d563 Mon Sep 17 00:00:00 2001 From: neeraj pratap singh Date: Wed, 17 Apr 2024 16:12:06 +0530 Subject: [PATCH] qa: add tests for fixing dangling symlink Fixes: https://tracker.ceph.com/issues/58090 Signed-off-by: Neeraj Pratap Singh --- qa/tasks/cephfs/test_volumes.py | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/qa/tasks/cephfs/test_volumes.py b/qa/tasks/cephfs/test_volumes.py index 037b046304eb..3d02bd7d1d23 100644 --- a/qa/tasks/cephfs/test_volumes.py +++ b/qa/tasks/cephfs/test_volumes.py @@ -14,6 +14,7 @@ from io import StringIO from tasks.cephfs.cephfs_test_case import CephFSTestCase from tasks.cephfs.fuse_mount import FuseMount from teuthology.exceptions import CommandFailedError +from teuthology import contextutil log = logging.getLogger(__name__) @@ -8165,6 +8166,51 @@ class TestMisc(TestVolumesHelper): # remove group self._fs_cmd("subvolumegroup", "rm", self.volname, group) + def test_dangling_symlink(self): + """ + test_dangling_symlink + Tests for the presence of any dangling symlink, if yes, + will remove it. + """ + subvolume = self._gen_subvol_name() + snapshot = self._gen_subvol_snap_name() + clone = self._gen_subvol_clone_name() + + self._fs_cmd("subvolume", "create", self.volname, subvolume) + + self._fs_cmd("subvolume", "snapshot", "create", self.volname, subvolume, snapshot) + + self.config_set('mgr', 'mgr/volumes/snapshot_clone_delay', 60) + + self.config_set('mgr', 'mgr/volumes/snapshot_clone_no_wait', False) + + self._fs_cmd("subvolume", "snapshot", "clone", self.volname, subvolume, snapshot, clone) + + result = json.loads(self._fs_cmd("subvolume", "snapshot", "info", self.volname, subvolume, snapshot)) + + # verify snapshot info + self.assertEqual(result['has_pending_clones'], "yes") + + clone_path = f'./volumes/_nogroup/{clone}' + self.mount_a.run_shell(['sudo', 'rm', '-rf', clone_path], omit_sudo=False) + + with contextutil.safe_while(sleep=5, tries=6) as proceed: + while proceed(): + try: + result = json.loads(self._fs_cmd("subvolume", "snapshot", "info", self.volname, subvolume, snapshot)) + # verify snapshot info + self.assertEqual(result['has_pending_clones'], "no") + break + except AssertionError as e: + log.debug(f'{e}, retrying') + + self._fs_cmd("subvolume", "snapshot", "rm", self.volname, subvolume, snapshot) + + self._fs_cmd("subvolume", "rm", self.volname, subvolume) + + self._wait_for_trash_empty() + + class TestPerModuleFinsherThread(TestVolumesHelper): """ Per module finisher thread tests related to mgr/volume cmds. -- 2.47.3