2018-02-15 18:40:01 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-04-24 16:32:54 +00:00
|
|
|
from .helper import DashboardTestCase
|
2018-02-15 18:40:01 +00:00
|
|
|
|
|
|
|
|
2018-02-28 22:14:35 +00:00
|
|
|
class CephfsTest(DashboardTestCase):
|
|
|
|
CEPHFS = True
|
|
|
|
|
2018-04-24 16:32:54 +00:00
|
|
|
AUTH_ROLES = ['cephfs-manager']
|
|
|
|
|
|
|
|
@DashboardTestCase.RunAs('test', 'test', ['block-manager'])
|
|
|
|
def test_access_permissions(self):
|
|
|
|
fs_id = self.fs.get_namespace_id()
|
|
|
|
self._get("/api/cephfs/{}/clients".format(fs_id))
|
|
|
|
self.assertStatus(403)
|
|
|
|
self._get("/api/cephfs/{}".format(fs_id))
|
|
|
|
self.assertStatus(403)
|
|
|
|
self._get("/api/cephfs/{}/mds_counters".format(fs_id))
|
|
|
|
self.assertStatus(403)
|
|
|
|
|
2018-02-15 18:40:01 +00:00
|
|
|
def test_cephfs_clients(self):
|
2018-02-28 22:14:35 +00:00
|
|
|
fs_id = self.fs.get_namespace_id()
|
2018-05-08 15:16:29 +00:00
|
|
|
data = self._get("/api/cephfs/{}/clients".format(fs_id))
|
2018-02-15 18:40:01 +00:00
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIn('status', data)
|
|
|
|
self.assertIn('data', data)
|
|
|
|
|
2018-05-08 15:16:29 +00:00
|
|
|
def test_cephfs_get(self):
|
2018-02-28 22:14:35 +00:00
|
|
|
fs_id = self.fs.get_namespace_id()
|
2018-05-08 15:16:29 +00:00
|
|
|
data = self._get("/api/cephfs/{}/".format(fs_id))
|
2018-02-15 18:40:01 +00:00
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIn('cephfs', data)
|
|
|
|
self.assertIn('standbys', data)
|
|
|
|
self.assertIn('versions', data)
|
|
|
|
self.assertIsNotNone(data['cephfs'])
|
|
|
|
self.assertIsNotNone(data['standbys'])
|
|
|
|
self.assertIsNotNone(data['versions'])
|
|
|
|
|
|
|
|
def test_cephfs_mds_counters(self):
|
2018-02-28 22:14:35 +00:00
|
|
|
fs_id = self.fs.get_namespace_id()
|
2018-05-08 15:16:29 +00:00
|
|
|
data = self._get("/api/cephfs/{}/mds_counters".format(fs_id))
|
2018-02-15 18:40:01 +00:00
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self.assertIsInstance(data, dict)
|
|
|
|
self.assertIsNotNone(data)
|
2018-04-24 16:20:59 +00:00
|
|
|
|
|
|
|
def test_cephfs_mds_counters_wrong(self):
|
2018-05-08 15:16:29 +00:00
|
|
|
self._get("/api/cephfs/baadbaad/mds_counters")
|
2018-04-24 16:20:59 +00:00
|
|
|
self.assertStatus(400)
|
|
|
|
self.assertJsonBody({
|
2018-04-24 16:32:54 +00:00
|
|
|
"component": 'cephfs',
|
|
|
|
"code": "invalid_cephfs_id",
|
|
|
|
"detail": "Invalid cephfs ID baadbaad"
|
|
|
|
})
|
2018-04-24 16:20:59 +00:00
|
|
|
|
2018-05-08 15:16:29 +00:00
|
|
|
def test_cephfs_list(self):
|
|
|
|
data = self._get("/api/cephfs/")
|
|
|
|
self.assertStatus(200)
|
|
|
|
self.assertIsInstance(data, list)
|
|
|
|
|
|
|
|
cephfs = data[0]
|
|
|
|
self.assertIn('id', cephfs)
|
|
|
|
self.assertIn('mdsmap', cephfs)
|
|
|
|
self.assertIsNotNone(cephfs['id'])
|
|
|
|
self.assertIsNotNone(cephfs['mdsmap'])
|