2018-03-14 14:51:10 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2018-09-17 07:54:11 +00:00
|
|
|
import six
|
2018-03-14 14:51:10 +00:00
|
|
|
|
2018-09-17 07:54:11 +00:00
|
|
|
from .helper import DashboardTestCase, JObj, JList
|
2018-03-14 14:51:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ECPTest(DashboardTestCase):
|
|
|
|
|
2018-04-24 16:32:54 +00:00
|
|
|
AUTH_ROLES = ['pool-manager']
|
|
|
|
|
2018-12-01 01:00:03 +00:00
|
|
|
@DashboardTestCase.RunAs('test', 'test', ['rgw-manager'])
|
2018-04-24 16:32:54 +00:00
|
|
|
def test_read_access_permissions(self):
|
2018-09-17 07:54:11 +00:00
|
|
|
self._get('/api/erasure_code_profile')
|
2018-04-24 16:32:54 +00:00
|
|
|
self.assertStatus(403)
|
|
|
|
|
|
|
|
@DashboardTestCase.RunAs('test', 'test', ['read-only'])
|
|
|
|
def test_write_access_permissions(self):
|
2018-09-17 07:54:11 +00:00
|
|
|
self._get('/api/erasure_code_profile')
|
2018-04-24 16:32:54 +00:00
|
|
|
self.assertStatus(200)
|
|
|
|
data = {'name': 'ecp32', 'k': 3, 'm': 2}
|
|
|
|
self._post('/api/erasure_code_profile', data)
|
|
|
|
self.assertStatus(403)
|
|
|
|
self._delete('/api/erasure_code_profile/default')
|
|
|
|
self.assertStatus(403)
|
2018-03-14 14:51:10 +00:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
super(ECPTest, cls).tearDownClass()
|
|
|
|
cls._ceph_cmd(['osd', 'erasure-code-profile', 'rm', 'ecp32'])
|
|
|
|
cls._ceph_cmd(['osd', 'erasure-code-profile', 'rm', 'lrc'])
|
|
|
|
|
|
|
|
def test_list(self):
|
|
|
|
data = self._get('/api/erasure_code_profile')
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
default = [p for p in data if p['name'] == 'default']
|
|
|
|
if default:
|
|
|
|
default_ecp = {
|
|
|
|
'k': 2,
|
2018-09-17 07:54:11 +00:00
|
|
|
'technique': 'reed_sol_van',
|
2018-03-14 14:51:10 +00:00
|
|
|
'm': 1,
|
2018-09-17 07:54:11 +00:00
|
|
|
'name': 'default',
|
|
|
|
'plugin': 'jerasure'
|
2018-03-14 14:51:10 +00:00
|
|
|
}
|
|
|
|
if 'crush-failure-domain' in default[0]:
|
|
|
|
default_ecp['crush-failure-domain'] = default[0]['crush-failure-domain']
|
2018-11-15 15:59:51 +00:00
|
|
|
self.assertSubset(default_ecp, default[0])
|
2018-03-14 14:51:10 +00:00
|
|
|
get_data = self._get('/api/erasure_code_profile/default')
|
|
|
|
self.assertEqual(get_data, default[0])
|
|
|
|
|
|
|
|
|
|
|
|
def test_create(self):
|
|
|
|
data = {'name': 'ecp32', 'k': 3, 'm': 2}
|
|
|
|
self._post('/api/erasure_code_profile', data)
|
|
|
|
self.assertStatus(201)
|
|
|
|
|
|
|
|
self._get('/api/erasure_code_profile/ecp32')
|
2018-11-15 15:59:51 +00:00
|
|
|
self.assertJsonSubset({
|
2018-09-17 07:54:11 +00:00
|
|
|
'crush-device-class': '',
|
|
|
|
'crush-failure-domain': 'osd',
|
|
|
|
'crush-root': 'default',
|
|
|
|
'jerasure-per-chunk-alignment': 'false',
|
|
|
|
'k': 3,
|
|
|
|
'm': 2,
|
|
|
|
'name': 'ecp32',
|
|
|
|
'plugin': 'jerasure',
|
|
|
|
'technique': 'reed_sol_van',
|
2018-03-14 14:51:10 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self._delete('/api/erasure_code_profile/ecp32')
|
|
|
|
self.assertStatus(204)
|
|
|
|
|
|
|
|
def test_create_plugin(self):
|
|
|
|
data = {'name': 'lrc', 'k': '2', 'm': '2', 'l': '2', 'plugin': 'lrc'}
|
|
|
|
self._post('/api/erasure_code_profile', data)
|
|
|
|
self.assertJsonBody(None)
|
|
|
|
self.assertStatus(201)
|
|
|
|
|
|
|
|
self._get('/api/erasure_code_profile/lrc')
|
|
|
|
self.assertJsonBody({
|
2018-09-17 07:54:11 +00:00
|
|
|
'crush-device-class': '',
|
|
|
|
'crush-failure-domain': 'host',
|
|
|
|
'crush-root': 'default',
|
|
|
|
'k': 2,
|
|
|
|
'l': '2',
|
|
|
|
'm': 2,
|
|
|
|
'name': 'lrc',
|
|
|
|
'plugin': 'lrc'
|
2018-03-14 14:51:10 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
self.assertStatus(200)
|
|
|
|
|
|
|
|
self._delete('/api/erasure_code_profile/lrc')
|
|
|
|
self.assertStatus(204)
|
|
|
|
|
2018-09-17 07:54:11 +00:00
|
|
|
def test_ecp_info(self):
|
|
|
|
self._get('/api/erasure_code_profile/_info')
|
|
|
|
self.assertSchemaBody(JObj({
|
|
|
|
'names': JList(six.string_types),
|
|
|
|
'failure_domains': JList(six.string_types),
|
|
|
|
'plugins': JList(six.string_types),
|
|
|
|
'devices': JList(six.string_types),
|
|
|
|
'directory': six.string_types,
|
|
|
|
}))
|
|
|
|
|