]> 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)
committerRamana Raja <rraja@redhat.com>
Mon, 27 Jul 2020 12:35:47 +0000 (18:05 +0530)
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>
(cherry picked from commit 87292811215f6ded9a784d3216a910faaef648e2)

qa/tasks/ceph_test_case.py
qa/tasks/cephfs/cephfs_test_case.py

index e2506436b745a70eb3e727a1f6db3988cfd53d23..a1ce69549642a330e58ba911dc037d165a9b307e 100644 (file)
@@ -1,4 +1,3 @@
-
 import unittest
 from unittest import case
 import time
@@ -32,6 +31,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()))
 
@@ -43,12 +44,42 @@ class CephTestCase(unittest.TestCase):
                 raise case.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 e17bdd35f05ef0ac27484f03479ce717789cec67..de93f0d303fd4ab5fea311dcbda367e633acaea9 100644 (file)
@@ -170,8 +170,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()
@@ -182,6 +180,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)