Skip to content

Commit

Permalink
qa: add test for fs rm idempotency
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Donnelly <[email protected]>
  • Loading branch information
batrick committed Jan 12, 2021
1 parent e4d826d commit 780a1dd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 18 deletions.
41 changes: 24 additions & 17 deletions qa/tasks/cephfs/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,27 +680,19 @@ def run_client_payload(self, cmd):
m.run_shell_payload(cmd)
m.umount_wait(require_clean=True)

def destroy(self, reset_obj_attrs=True):
log.info(f'Destroying file system {self.name} and related pools')
def _remove_pool(self, name, **kwargs):
c = f'osd pool rm {name} {name} --yes-i-really-really-mean-it'
return self.mon_manager.ceph(c, **kwargs)

if self.dead():
log.debug('already dead...')
return
def rm(self, **kwargs):
c = f'fs rm {self.name} --yes-i-really-mean-it'
return self.mon_manager.ceph(c, **kwargs)

data_pools = self.get_data_pool_names(refresh=True)

# make sure no MDSs are attached to given FS.
self.mon_manager.raw_cluster_cmd('fs', 'fail', self.name)
self.mon_manager.raw_cluster_cmd(
'fs', 'rm', self.name, '--yes-i-really-mean-it')

self.mon_manager.raw_cluster_cmd('osd', 'pool', 'rm',
self.get_metadata_pool_name(), self.get_metadata_pool_name(),
'--yes-i-really-really-mean-it')
def remove_pools(self, data_pools):
self._remove_pool(self.get_metadata_pool_name())
for poolname in data_pools:
try:
self.mon_manager.raw_cluster_cmd('osd', 'pool', 'rm', poolname,
poolname, '--yes-i-really-really-mean-it')
self._remove_pool(poolname)
except CommandFailedError as e:
# EBUSY, this data pool is used by two metadata pools, let the
# 2nd pass delete it
Expand All @@ -709,6 +701,21 @@ def destroy(self, reset_obj_attrs=True):
else:
raise

def destroy(self, reset_obj_attrs=True):
log.info(f'Destroying file system {self.name} and related pools')

if self.dead():
log.debug('already dead...')
return

data_pools = self.get_data_pool_names(refresh=True)

# make sure no MDSs are attached to given FS.
self.fail()
self.rm()

self.remove_pools(data_pools)

if reset_obj_attrs:
self.id = None
self.name = None
Expand Down
28 changes: 27 additions & 1 deletion qa/tasks/cephfs/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from teuthology.orchestra.run import CommandFailedError, Raw

from tasks.cephfs.cephfs_test_case import CephFSTestCase
from tasks.cephfs.filesystem import FileLayout
from tasks.cephfs.filesystem import FileLayout, FSMissing
from tasks.cephfs.fuse_mount import FuseMount
from tasks.cephfs.caps_helper import CapsHelper

Expand Down Expand Up @@ -576,3 +576,29 @@ def setup_test_env(self, perm, paths=()):
mounts = (self.mount_a, )

return filepaths, filedata, mounts, keyring

class TestAdminCommandIdempotency(CephFSTestCase):
"""
Tests for administration command idempotency.
"""

CLIENTS_REQUIRED = 0
MDSS_REQUIRED = 1

def test_rm_idempotency(self):
"""
That a removing a fs twice is idempotent.
"""

data_pools = self.fs.get_data_pool_names(refresh=True)
self.fs.fail()
self.fs.rm()
try:
self.fs.get_mds_map()
except FSMissing:
pass
else:
self.fail("get_mds_map should raise")
p = self.fs.rm()
self.assertIn("does not exist", p.stderr.getvalue())
self.fs.remove_pools(data_pools)

0 comments on commit 780a1dd

Please sign in to comment.