]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | # -*- coding: utf-8 -*- |
2 | ||
3 | from __future__ import absolute_import | |
4 | ||
f67539c2 | 5 | from .helper import DashboardTestCase, JList, JObj |
11fdf7f2 TL |
6 | |
7 | ||
8 | class ECPTest(DashboardTestCase): | |
9 | ||
10 | AUTH_ROLES = ['pool-manager'] | |
11 | ||
12 | @DashboardTestCase.RunAs('test', 'test', ['rgw-manager']) | |
13 | def test_read_access_permissions(self): | |
14 | self._get('/api/erasure_code_profile') | |
15 | self.assertStatus(403) | |
16 | ||
17 | @DashboardTestCase.RunAs('test', 'test', ['read-only']) | |
18 | def test_write_access_permissions(self): | |
19 | self._get('/api/erasure_code_profile') | |
20 | self.assertStatus(200) | |
21 | data = {'name': 'ecp32', 'k': 3, 'm': 2} | |
22 | self._post('/api/erasure_code_profile', data) | |
23 | self.assertStatus(403) | |
24 | self._delete('/api/erasure_code_profile/default') | |
25 | self.assertStatus(403) | |
26 | ||
27 | @classmethod | |
28 | def tearDownClass(cls): | |
29 | super(ECPTest, cls).tearDownClass() | |
30 | cls._ceph_cmd(['osd', 'erasure-code-profile', 'rm', 'ecp32']) | |
31 | cls._ceph_cmd(['osd', 'erasure-code-profile', 'rm', 'lrc']) | |
32 | ||
33 | def test_list(self): | |
34 | data = self._get('/api/erasure_code_profile') | |
35 | self.assertStatus(200) | |
36 | ||
37 | default = [p for p in data if p['name'] == 'default'] | |
38 | if default: | |
39 | default_ecp = { | |
40 | 'k': 2, | |
41 | 'technique': 'reed_sol_van', | |
42 | 'm': 1, | |
43 | 'name': 'default', | |
44 | 'plugin': 'jerasure' | |
45 | } | |
46 | if 'crush-failure-domain' in default[0]: | |
47 | default_ecp['crush-failure-domain'] = default[0]['crush-failure-domain'] | |
48 | self.assertSubset(default_ecp, default[0]) | |
49 | get_data = self._get('/api/erasure_code_profile/default') | |
50 | self.assertEqual(get_data, default[0]) | |
51 | ||
11fdf7f2 TL |
52 | def test_create(self): |
53 | data = {'name': 'ecp32', 'k': 3, 'm': 2} | |
54 | self._post('/api/erasure_code_profile', data) | |
55 | self.assertStatus(201) | |
56 | ||
57 | self._get('/api/erasure_code_profile/ecp32') | |
58 | self.assertJsonSubset({ | |
59 | 'crush-device-class': '', | |
60 | 'crush-failure-domain': 'osd', | |
61 | 'crush-root': 'default', | |
62 | 'jerasure-per-chunk-alignment': 'false', | |
63 | 'k': 3, | |
64 | 'm': 2, | |
65 | 'name': 'ecp32', | |
66 | 'plugin': 'jerasure', | |
67 | 'technique': 'reed_sol_van', | |
68 | }) | |
69 | ||
70 | self.assertStatus(200) | |
71 | ||
72 | self._delete('/api/erasure_code_profile/ecp32') | |
73 | self.assertStatus(204) | |
74 | ||
75 | def test_create_plugin(self): | |
76 | data = {'name': 'lrc', 'k': '2', 'm': '2', 'l': '2', 'plugin': 'lrc'} | |
77 | self._post('/api/erasure_code_profile', data) | |
78 | self.assertJsonBody(None) | |
79 | self.assertStatus(201) | |
80 | ||
81 | self._get('/api/erasure_code_profile/lrc') | |
82 | self.assertJsonBody({ | |
83 | 'crush-device-class': '', | |
84 | 'crush-failure-domain': 'host', | |
85 | 'crush-root': 'default', | |
86 | 'k': 2, | |
87 | 'l': '2', | |
88 | 'm': 2, | |
89 | 'name': 'lrc', | |
90 | 'plugin': 'lrc' | |
91 | }) | |
92 | ||
93 | self.assertStatus(200) | |
94 | ||
95 | self._delete('/api/erasure_code_profile/lrc') | |
96 | self.assertStatus(204) | |
97 | ||
98 | def test_ecp_info(self): | |
9f95a23c | 99 | self._get('/ui-api/erasure_code_profile/info') |
11fdf7f2 | 100 | self.assertSchemaBody(JObj({ |
f67539c2 TL |
101 | 'names': JList(str), |
102 | 'plugins': JList(str), | |
103 | 'directory': str, | |
e306af50 | 104 | 'nodes': JList(JObj({}, allow_unknown=True)) |
11fdf7f2 | 105 | })) |