ceph/qa/tasks/mgr/dashboard/test_perf_counters.py
Ricardo Dias aa205a6731
mgr/dashboard: renamed dashboard_v2 to dashboard
Signed-off-by: Ricardo Dias <rdias@suse.com>
2018-03-16 07:23:08 +00:00

57 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from .helper import DashboardTestCase, authenticate
class PerfCountersControllerTest(DashboardTestCase):
@authenticate
def test_perf_counters_list(self):
data = self._get('/api/perf_counters')
self.assertStatus(200)
self.assertIsInstance(data, dict)
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)
@authenticate
def test_perf_counters_mon_get(self):
mon = self.mons()[0]
data = self._get('/api/perf_counters/mon/{}'.format(mon))
self.assertStatus(200)
self.assertIsInstance(data, dict)
self.assertEqual('mon', data['service']['type'])
self.assertEqual(mon, data['service']['id'])
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)
@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)
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)