]> git.proxmox.com Git - ceph.git/blame - ceph/qa/tasks/mgr/test_module_selftest.py
update sources to v12.2.5
[ceph.git] / ceph / qa / tasks / mgr / test_module_selftest.py
CommitLineData
3efd9988
FG
1
2import time
3import requests
4
5from tasks.mgr.mgr_test_case import MgrTestCase
6
7
8class TestModuleSelftest(MgrTestCase):
9 """
10 That modules with a self-test command can be loaded and execute it
11 without errors.
12
13 This is not a substitute for really testing the modules, but it
14 is quick and is designed to catch regressions that could occur
15 if data structures change in a way that breaks how the modules
16 touch them.
17 """
18 MGRS_REQUIRED = 1
19
20 def _selftest_plugin(self, module_name):
21 self._load_module(module_name)
22
23 # Execute the module's self-test routine
24 self.mgr_cluster.mon_manager.raw_cluster_cmd(module_name, "self-test")
25
26 def test_zabbix(self):
b32b8144
FG
27 # Set these mandatory config fields so that the zabbix module
28 # won't trigger health/log errors on load/serve.
29 self.mgr_cluster.set_module_conf("zabbix", "zabbix_host", "localhost")
30 self.mgr_cluster.set_module_conf("zabbix", "identifier", "foo")
3efd9988
FG
31 self._selftest_plugin("zabbix")
32
33 def test_prometheus(self):
94b18763 34 self._assign_ports("prometheus", "server_port", min_port=8100)
3efd9988
FG
35 self._selftest_plugin("prometheus")
36
37 def test_influx(self):
38 self._selftest_plugin("influx")
39
40 def test_selftest_run(self):
41 self._load_module("selftest")
42 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test", "run")
43
44 def test_selftest_command_spam(self):
45 # Use the selftest module to stress the mgr daemon
46 self._load_module("selftest")
47
48 # Use the dashboard to test that the mgr is still able to do its job
49 self._assign_ports("dashboard", "server_port")
50 self._load_module("dashboard")
51
52 original_active = self.mgr_cluster.get_active_id()
53 original_standbys = self.mgr_cluster.get_standby_ids()
54
55 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test",
56 "background", "start",
57 "command_spam")
58
59 dashboard_uri = self._get_uri("dashboard")
60
61 delay = 10
62 periods = 10
63 for i in range(0, periods):
64 t1 = time.time()
65 # Check that an HTTP module remains responsive
66 r = requests.get(dashboard_uri)
67 self.assertEqual(r.status_code, 200)
68
69 # Check that a native non-module command remains responsive
70 self.mgr_cluster.mon_manager.raw_cluster_cmd("osd", "df")
71
72 time.sleep(delay - (time.time() - t1))
73
74 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test",
75 "background", "stop")
76
77 # Check that all mgr daemons are still running
78 self.assertEqual(original_active, self.mgr_cluster.get_active_id())
79 self.assertEqual(original_standbys, self.mgr_cluster.get_standby_ids())