]> git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/mgr/test_module_selftest.py
update sources to v12.2.3
[ceph.git] / ceph / qa / tasks / mgr / test_module_selftest.py
1
2 import time
3 import requests
4
5 from tasks.mgr.mgr_test_case import MgrTestCase
6
7
8 class 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):
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")
31 self._selftest_plugin("zabbix")
32
33 def test_prometheus(self):
34 self._selftest_plugin("prometheus")
35
36 def test_influx(self):
37 self._selftest_plugin("influx")
38
39 def test_selftest_run(self):
40 self._load_module("selftest")
41 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test", "run")
42
43 def test_selftest_command_spam(self):
44 # Use the selftest module to stress the mgr daemon
45 self._load_module("selftest")
46
47 # Use the dashboard to test that the mgr is still able to do its job
48 self._assign_ports("dashboard", "server_port")
49 self._load_module("dashboard")
50
51 original_active = self.mgr_cluster.get_active_id()
52 original_standbys = self.mgr_cluster.get_standby_ids()
53
54 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test",
55 "background", "start",
56 "command_spam")
57
58 dashboard_uri = self._get_uri("dashboard")
59
60 delay = 10
61 periods = 10
62 for i in range(0, periods):
63 t1 = time.time()
64 # Check that an HTTP module remains responsive
65 r = requests.get(dashboard_uri)
66 self.assertEqual(r.status_code, 200)
67
68 # Check that a native non-module command remains responsive
69 self.mgr_cluster.mon_manager.raw_cluster_cmd("osd", "df")
70
71 time.sleep(delay - (time.time() - t1))
72
73 self.mgr_cluster.mon_manager.raw_cluster_cmd("mgr", "self-test",
74 "background", "stop")
75
76 # Check that all mgr daemons are still running
77 self.assertEqual(original_active, self.mgr_cluster.get_active_id())
78 self.assertEqual(original_standbys, self.mgr_cluster.get_standby_ids())