2018-02-05 13:56:46 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-02-28 22:14:35 +00:00
|
|
|
from .helper import DashboardTestCase, authenticate
|
2018-02-05 13:56:46 +00:00
|
|
|
|
|
|
|
|
2018-02-28 22:14:35 +00:00
|
|
|
class PerfCountersControllerTest(DashboardTestCase):
|
2018-02-05 13:56:46 +00:00
|
|
|
|
|
|
|
@authenticate
|
|
|
|
def test_perf_counters_list(self):
|
|
|
|
data = self._get('/api/perf_counters')
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIsInstance(data, dict)
|
2018-02-28 22:14:35 +00:00
|
|
|
for mon in self.mons():
|
|
|
|
self.assertIn('mon.{}'.format(mon), data)
|
|
|
|
|
|
|
|
osds = self.ceph_cluster.mon_manager.get_osd_dump()
|
|
|
|
for osd in osds:
|
|
|
|
self.assertIn('osd.{}'.format(osd['osd']), data)
|
2018-02-05 13:56:46 +00:00
|
|
|
|
|
|
|
@authenticate
|
2018-03-07 15:39:27 +00:00
|
|
|
def test_perf_counters_mon_get(self):
|
|
|
|
mon = self.mons()[0]
|
|
|
|
data = self._get('/api/perf_counters/mon/{}'.format(mon))
|
2018-02-05 13:56:46 +00:00
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIsInstance(data, dict)
|
|
|
|
self.assertEqual('mon', data['service']['type'])
|
2018-03-07 15:39:27 +00:00
|
|
|
self.assertEqual(mon, data['service']['id'])
|
2018-02-05 13:56:46 +00:00
|
|
|
self.assertIsInstance(data['counters'], list)
|
|
|
|
self.assertGreater(len(data['counters']), 0)
|
|
|
|
counter = data['counters'][0]
|
|
|
|
self.assertIsInstance(counter, dict)
|
|
|
|
self.assertIn('description', counter)
|
|
|
|
self.assertIn('name', counter)
|
|
|
|
self.assertIn('unit', counter)
|
|
|
|
self.assertIn('value', counter)
|
2018-03-07 15:39:27 +00:00
|
|
|
|
|
|
|
@authenticate
|
|
|
|
def test_perf_counters_mgr_get(self):
|
|
|
|
mgr = self.mgr_cluster.mgr_ids[0]
|
|
|
|
data = self._get('/api/perf_counters/mgr/{}'.format(mgr))
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIsInstance(data, dict)
|
|
|
|
self.assertEqual('mgr', data['service']['type'])
|
|
|
|
self.assertEqual(mgr, data['service']['id'])
|
|
|
|
self.assertIsInstance(data['counters'], list)
|
2018-03-15 12:44:52 +00:00
|
|
|
self.assertGreater(len(data['counters']), 0)
|
|
|
|
counter = data['counters'][0]
|
|
|
|
self.assertIsInstance(counter, dict)
|
|
|
|
self.assertIn('description', counter)
|
|
|
|
self.assertIn('name', counter)
|
|
|
|
self.assertIn('unit', counter)
|
|
|
|
self.assertIn('value', counter)
|