From: Patrick Donnelly Date: Mon, 10 Feb 2020 18:46:09 +0000 (-0800) Subject: qa: manage config changes through mons X-Git-Tag: v15.1.1~424^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=87292811215f6ded9a784d3216a910faaef648e2;p=ceph-ci.git qa: manage config changes through mons 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 --- diff --git a/qa/tasks/ceph_test_case.py b/qa/tasks/ceph_test_case.py index f3c258700a5..e5c2f48b278 100644 --- a/qa/tasks/ceph_test_case.py +++ b/qa/tasks/ceph_test_case.py @@ -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): """ diff --git a/qa/tasks/cephfs/cephfs_test_case.py b/qa/tasks/cephfs/cephfs_test_case.py index 421284a9e5b..98a18b3d550 100644 --- a/qa/tasks/cephfs/cephfs_test_case.py +++ b/qa/tasks/cephfs/cephfs_test_case.py @@ -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) diff --git a/qa/tasks/cephfs/filesystem.py b/qa/tasks/cephfs/filesystem.py index 834eee65dc0..02c07a42e07 100644 --- a/qa/tasks/cephfs/filesystem.py +++ b/qa/tasks/cephfs/filesystem.py @@ -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 diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 5f33d546a27..0d50af94057 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -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'