From d8c55edaf33bca31bd5ddbbd2293fc45789fb43b Mon Sep 17 00:00:00 2001 From: Milind Changire Date: Tue, 30 Aug 2022 07:58:51 +0530 Subject: [PATCH] qa: test snap id failures for fs pools Signed-off-by: Milind Changire --- qa/tasks/cephfs/test_snapshots.py | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/qa/tasks/cephfs/test_snapshots.py b/qa/tasks/cephfs/test_snapshots.py index bc3e6a16c8a..51dcf80abd0 100644 --- a/qa/tasks/cephfs/test_snapshots.py +++ b/qa/tasks/cephfs/test_snapshots.py @@ -534,3 +534,62 @@ class TestSnapshots(CephFSTestCase): # after reducing limit we expect the new snapshot creation to fail pass self.delete_dir_and_snaps("accounts", new_limit + 1) + + +class TestMonSnapsAndFsPools(CephFSTestCase): + MDSS_REQUIRED = 3 + + def test_disallow_monitor_managed_snaps_for_fs_pools(self): + """ + Test that creation of monitor managed snaps fails for pools attached + to any file-system + """ + with self.assertRaises(CommandFailedError): + self.fs.rados(["mksnap", "snap1"], pool=self.fs.get_data_pool_name()) + + with self.assertRaises(CommandFailedError): + self.fs.rados(["mksnap", "snap2"], pool=self.fs.get_metadata_pool_name()) + + def test_attaching_pools_with_snaps_to_fs_fails(self): + """ + Test that attempt to attach pool with snapshots to an fs fails + """ + test_pool_name = 'snap-test-pool' + base_cmd = f'osd pool create {test_pool_name}' + ret = self.run_cluster_cmd_result(base_cmd) + self.assertEqual(ret, 0) + + self.fs.rados(["mksnap", "snap3"], pool=test_pool_name) + + base_cmd = f'fs add_data_pool {self.fs.name} {test_pool_name}' + ret = self.run_cluster_cmd_result(base_cmd) + self.assertEqual(ret, errno.EOPNOTSUPP) + + # cleanup + self.fs.rados(["rmsnap", "snap3"], pool=test_pool_name) + base_cmd = f'osd pool delete {test_pool_name}' + ret = self.run_cluster_cmd_result(base_cmd) + + def test_using_pool_with_snap_fails_fs_creation(self): + """ + Test that using a pool with snaps for fs creation fails + """ + base_cmd = 'osd pool create test_data_pool' + ret = self.run_cluster_cmd_result(base_cmd) + self.assertEqual(ret, 0) + base_cmd = 'osd pool create test_metadata_pool' + ret = self.run_cluster_cmd_result(base_cmd) + self.assertEqual(ret, 0) + + self.fs.rados(["mksnap", "snap4"], pool='test_data_pool') + + base_cmd = 'fs new testfs test_metadata_pool test_data_pool' + ret = self.run_cluster_cmd_result(base_cmd) + self.assertEqual(ret, errno.EOPNOTSUPP) + + # cleanup + self.fs.rados(["rmsnap", "snap4"], pool='test_data_pool') + base_cmd = 'osd pool delete test_data_pool' + ret = self.run_cluster_cmd_result(base_cmd) + base_cmd = 'osd pool delete test_metadata_pool' + ret = self.run_cluster_cmd_result(base_cmd)