]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: manage config changes through mons
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 10 Feb 2020 18:46:09 +0000 (10:46 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 13 Feb 2020 15:51:09 +0000 (07:51 -0800)
This provides a generic framework for modifying Ceph configuration
changes in tests through the monitors rather than the asok interface or
local ceph.conf changes. Any changes are reverted during test teardown.

A future patch will convert existing tests manipulating the local
ceph.conf or admin socket.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/ceph_test_case.py
qa/tasks/cephfs/cephfs_test_case.py
qa/tasks/cephfs/filesystem.py
qa/tasks/vstart_runner.py

index f3c258700a5c10473d8e342afa733fa14f8a66ec..e5c2f48b278051122381dad4d2a68c5a9fc70e50 100644 (file)
@@ -1,4 +1,3 @@
-
 import unittest
 import time
 import logging
@@ -31,6 +30,8 @@ class CephTestCase(unittest.TestCase):
     REQUIRE_MEMSTORE = False
 
     def setUp(self):
+        self._mon_configs_set = set()
+
         self.ceph_cluster.mon_manager.raw_cluster_cmd("log",
             "Starting test {0}".format(self.id()))
 
@@ -42,12 +43,42 @@ class CephTestCase(unittest.TestCase):
                 raise self.skipTest("Require `memstore` OSD backend (test " \
                         "would take too long on full sized OSDs")
 
-
-
     def tearDown(self):
+        self.config_clear()
+
         self.ceph_cluster.mon_manager.raw_cluster_cmd("log",
             "Ended test {0}".format(self.id()))
 
+    def config_clear(self):
+        for section, key in self._mon_configs_set:
+            self.config_rm(section, key)
+        self._mon_configs_set.clear()
+
+    def _fix_key(self, key):
+        return str(key).replace(' ', '_')
+
+    def config_get(self, section, key):
+       key = self._fix_key(key)
+       return self.ceph_cluster.mon_manager.raw_cluster_cmd("config", "get", section, key).strip()
+
+    def config_show(self, entity, key):
+       key = self._fix_key(key)
+       return self.ceph_cluster.mon_manager.raw_cluster_cmd("config", "show", entity, key).strip()
+
+    def config_minimal(self):
+       return self.ceph_cluster.mon_manager.raw_cluster_cmd("config", "generate-minimal-conf").strip()
+
+    def config_rm(self, section, key):
+       key = self._fix_key(key)
+       self.ceph_cluster.mon_manager.raw_cluster_cmd("config", "rm", section, key)
+       # simplification: skip removing from _mon_configs_set;
+       # let tearDown clear everything again
+
+    def config_set(self, section, key, value):
+       key = self._fix_key(key)
+       self._mon_configs_set.add((section, key))
+       self.ceph_cluster.mon_manager.raw_cluster_cmd("config", "set", section, key, str(value))
+
     def assert_cluster_log(self, expected_pattern, invert_match=False,
                            timeout=10, watch_channel=None):
         """
index 421284a9e5bd27240b5939842bb842bddeb075dd..98a18b3d550f3efe57e3df0a94fcfc6f47b87387 100644 (file)
@@ -169,8 +169,6 @@ class CephFSTestCase(CephTestCase):
         self.configs_set = set()
 
     def tearDown(self):
-        super(CephFSTestCase, self).tearDown()
-
         self.mds_cluster.clear_firewall()
         for m in self.mounts:
             m.teardown()
@@ -181,6 +179,8 @@ class CephFSTestCase(CephTestCase):
         for subsys, key in self.configs_set:
             self.mds_cluster.clear_ceph_conf(subsys, key)
 
+        return super(CephFSTestCase, self).tearDown()
+
     def set_conf(self, subsys, key, value):
         self.configs_set.add((subsys, key))
         self.mds_cluster.set_ceph_conf(subsys, key, value)
index 834eee65dc0b0dddf33b0ad6c609d7bda5b1c827..02c07a42e07a77be09530f5a2d7dc50b5df255e9 100644 (file)
@@ -197,12 +197,6 @@ class CephCluster(object):
         self._ctx = ctx
         self.mon_manager = ceph_manager.CephManager(self.admin_remote, ctx=ctx, logger=log.getChild('ceph_manager'))
 
-    def set_config_opt(self, section, opt, val):
-        self.mon_manager.raw_cluster_cmd('config', 'set', section, opt, val)
-
-    def rm_config_opt(self, section, opt):
-        self.mon_manager.raw_cluster_cmd('config', 'rm', section)
-
     def get_config(self, key, service_type=None):
         """
         Get config from mon by default, or a specific service if caller asks for it
index 5f33d546a27aeeec8280e94d5e12e93bc849fd8b..0d50af9405778770bf129769e05a62c3b87d8fe5 100644 (file)
@@ -1016,12 +1016,6 @@ class LocalCephCluster(CephCluster):
     def admin_remote(self):
         return LocalRemote()
 
-    def set_config_opt(self, section, opt, val):
-        self.mon_manager.raw_cluster_cmd('config', 'set', section, opt, val)
-
-    def rm_config_opt(self, section, opt):
-        self.mon_manager.raw_cluster_cmd('config', 'rm', section, opt)
-
     def get_config(self, key, service_type=None):
         if service_type is None:
             service_type = 'mon'