]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/mgr/dashboard/test_mgr_module.py
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
7 from .helper
import DashboardTestCase
, JAny
, JObj
, JList
, JLeaf
9 logger
= logging
.getLogger(__name__
)
12 class MgrModuleTestCase(DashboardTestCase
):
15 def wait_until_rest_api_accessible(self
):
17 Wait until the REST API is accessible.
20 def _check_connection():
22 # Try reaching an API endpoint successfully.
23 self
._get
('/api/mgr/module')
24 if self
._resp
.status_code
== 200:
26 except requests
.ConnectionError
:
30 self
.wait_until_true(_check_connection
, timeout
=30)
33 class MgrModuleTest(MgrModuleTestCase
):
34 def test_list_disabled_module(self
):
35 self
._ceph
_cmd
(['mgr', 'module', 'disable', 'iostat'])
36 self
.wait_until_rest_api_accessible()
37 data
= self
._get
('/api/mgr/module')
38 self
.assertStatus(200)
44 'enabled': JLeaf(bool),
45 'always_on': JLeaf(bool),
54 'default_value': JAny(none
=False),
55 'min': JAny(none
=False),
56 'max': JAny(none
=False),
57 'enum_allowed': JList(str),
58 'see_also': JList(str),
64 module_info
= self
.find_object_in_list('name', 'iostat', data
)
65 self
.assertIsNotNone(module_info
)
66 self
.assertFalse(module_info
['enabled'])
68 def test_list_enabled_module(self
):
69 self
._ceph
_cmd
(['mgr', 'module', 'enable', 'iostat'])
70 self
.wait_until_rest_api_accessible()
71 data
= self
._get
('/api/mgr/module')
72 self
.assertStatus(200)
78 'enabled': JLeaf(bool),
79 'always_on': JLeaf(bool),
88 'default_value': JAny(none
=False),
89 'min': JAny(none
=False),
90 'max': JAny(none
=False),
91 'enum_allowed': JList(str),
92 'see_also': JList(str),
98 module_info
= self
.find_object_in_list('name', 'iostat', data
)
99 self
.assertIsNotNone(module_info
)
100 self
.assertTrue(module_info
['enabled'])
103 class MgrModuleTelemetryTest(MgrModuleTestCase
):
105 data
= self
._get
('/api/mgr/module/telemetry')
106 self
.assertStatus(200)
112 'channel_basic': bool,
113 'channel_ident': bool,
114 'channel_crash': bool,
115 'channel_device': bool,
120 'last_opt_revision': int,
128 self
.set_config_key('config/mgr/mgr/telemetry/contact', '')
129 self
.set_config_key('config/mgr/mgr/telemetry/description', '')
130 self
.set_config_key('config/mgr/mgr/telemetry/enabled', 'True')
131 self
.set_config_key('config/mgr/mgr/telemetry/interval', '72')
132 self
.set_config_key('config/mgr/mgr/telemetry/leaderboard', 'False')
133 self
.set_config_key('config/mgr/mgr/telemetry/organization', '')
134 self
.set_config_key('config/mgr/mgr/telemetry/proxy', '')
135 self
.set_config_key('config/mgr/mgr/telemetry/url', '')
137 '/api/mgr/module/telemetry',
140 'contact': 'tux@suse.com',
141 'description': 'test',
145 'organization': 'SUSE Linux',
147 'url': 'https://foo.bar/report'
150 self
.assertStatus(200)
151 data
= self
._get
('/api/mgr/module/telemetry')
152 self
.assertStatus(200)
153 self
.assertEqual(data
['contact'], 'tux@suse.com')
154 self
.assertEqual(data
['description'], 'test')
155 self
.assertFalse(data
['enabled'])
156 self
.assertEqual(data
['interval'], 4711)
157 self
.assertTrue(data
['leaderboard'])
158 self
.assertEqual(data
['organization'], 'SUSE Linux')
159 self
.assertEqual(data
['proxy'], 'foo')
160 self
.assertEqual(data
['url'], 'https://foo.bar/report')