From f1b9e90d7f858496ef1053be9cfa59844b3247b3 Mon Sep 17 00:00:00 2001 From: Jos Collin Date: Tue, 17 Sep 2019 12:16:35 +0530 Subject: [PATCH] qa/tasks: add/update tests for --yes-i-really-mean-it Fixes: https://tracker.ceph.com/issues/41841 Signed-off-by: Jos Collin --- qa/tasks/cephfs/test_volumes.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/qa/tasks/cephfs/test_volumes.py b/qa/tasks/cephfs/test_volumes.py index 98fd17b478d..2155c0d5fa9 100644 --- a/qa/tasks/cephfs/test_volumes.py +++ b/qa/tasks/cephfs/test_volumes.py @@ -63,7 +63,7 @@ class TestVolumes(CephFSTestCase): return path[1:].rstrip() def _delete_test_volume(self): - self._fs_cmd("volume", "rm", self.volname) + self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it") def _do_subvolume_io(self, subvolume, number_of_files=DEFAULT_NUMBER_OF_FILES, file_size=DEFAULT_FILE_SIZE): @@ -95,6 +95,23 @@ class TestVolumes(CephFSTestCase): self._delete_test_volume() super(TestVolumes, self).tearDown() + def test_volume_rm(self): + try: + self._fs_cmd("volume", "rm", self.volname) + except CommandFailedError as ce: + if ce.exitstatus != errno.EPERM: + raise RuntimeError("expected the 'fs volume rm' command to fail with EPERM, " + "but it failed with {0}".format(ce.exitstatus)) + else: + self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it") + + #check if it's gone + volumes = json.loads(self.mgr_cluster.mon_manager.raw_cluster_cmd('fs', 'volume', 'ls', '--format=json-pretty')) + if (self.volname in [volume['name'] for volume in volumes]): + raise RuntimeError("Expected the 'fs volume rm' command to succeed. The volume {0} not removed.".format(self.volname)) + else: + raise RuntimeError("expected the 'fs volume rm' command to fail.") + ### basic subvolume operations def test_subvolume_create_and_rm(self): -- 2.39.5