]>
git.proxmox.com Git - ceph.git/blob - ceph/qa/tasks/mgr/dashboard/test_perf_counters.py
c01368bce8db15556db9680751b98e3a507e5b76
1 # -*- coding: utf-8 -*-
2 from __future__
import absolute_import
4 from .helper
import DashboardTestCase
, JObj
7 class PerfCountersControllerTest(DashboardTestCase
):
9 def test_perf_counters_list(self
):
10 data
= self
._get
('/api/perf_counters')
11 self
.assertStatus(200)
13 self
.assertIsInstance(data
, dict)
14 for mon
in self
.mons():
15 self
.assertIn('mon.{}'.format(mon
), data
)
17 osds
= self
.ceph_cluster
.mon_manager
.get_osd_dump()
19 self
.assertIn('osd.{}'.format(osd
['osd']), data
)
21 def _validate_perf(self
, srv_id
, srv_type
, data
, allow_empty
):
22 self
.assertIsInstance(data
, dict)
23 self
.assertEqual(srv_type
, data
['service']['type'])
24 self
.assertEqual(str(srv_id
), data
['service']['id'])
25 self
.assertIsInstance(data
['counters'], list)
27 self
.assertGreater(len(data
['counters']), 0)
28 for counter
in data
['counters'][0:1]:
29 self
.assertIsInstance(counter
, dict)
30 self
.assertIn('description', counter
)
31 self
.assertIn('name', counter
)
32 self
.assertIn('unit', counter
)
33 self
.assertIn('value', counter
)
35 def test_perf_counters_mon_get(self
):
37 data
= self
._get
('/api/perf_counters/mon/{}'.format(mon
))
38 self
.assertStatus(200)
39 self
._validate
_perf
(mon
, 'mon', data
, allow_empty
=False)
41 def test_perf_counters_mgr_get(self
):
42 mgr
= list(self
.mgr_cluster
.mgr_ids
)[0]
43 data
= self
._get
('/api/perf_counters/mgr/{}'.format(mgr
))
44 self
.assertStatus(200)
45 self
._validate
_perf
(mgr
, 'mgr', data
, allow_empty
=False)
47 def test_perf_counters_mds_get(self
):
48 for mds
in self
.mds_cluster
.mds_ids
:
49 data
= self
._get
('/api/perf_counters/mds/{}'.format(mds
))
50 self
.assertStatus(200)
51 self
._validate
_perf
(mds
, 'mds', data
, allow_empty
=True)
53 def test_perf_counters_osd_get(self
):
54 for osd
in self
.ceph_cluster
.mon_manager
.get_osd_dump():
56 data
= self
._get
('/api/perf_counters/osd/{}'.format(osd
))
57 self
.assertStatus(200)
58 self
._validate
_perf
(osd
, 'osd', data
, allow_empty
=False)
60 def test_perf_counters_not_found(self
):
61 osds
= self
.ceph_cluster
.mon_manager
.get_osd_dump()
62 unused_id
= int(list(map(lambda o
: o
['osd'], osds
)).pop()) + 1
64 self
._get
('/api/perf_counters/osd/{}'.format(unused_id
))
65 self
.assertStatus(404)
66 schema
= JObj(sub_elems
={
69 }, allow_unknown
=True)
70 self
.assertEqual(self
._resp
.json()['detail'], "'osd.{}' not found".format(unused_id
))
71 self
.assertSchemaBody(schema
)