Skip to content

Commit 4d44a3c

Browse files
author
Huanxuan Ao
committed
Add some functional tests for commands in VolumeV2
VolumeV2 lacked functional tests for qos specs and volume type commands, so I add them. These tests are quite similar to those in v1,just three difference: 1.Importing functional.common.test instead of functional.tests.volume.v1.common 2.Adding test_volume_type_set_unset_project() in test_volume_type.py. 3.Adding a test for "qos unset" command in test_qos.py Change-Id: Ic50e8c49ef01ac967c01ec41fb3f04cd51fea9e4
1 parent f44416b commit 4d44a3c

2 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class VolumeTests(test.TestCase):
19+
"""Functional tests for volume qos. """
20+
21+
NAME = uuid.uuid4().hex
22+
HEADERS = ['Name']
23+
FIELDS = ['id', 'name']
24+
ID = None
25+
26+
@classmethod
27+
def setUpClass(cls):
28+
opts = cls.get_show_opts(cls.FIELDS)
29+
raw_output = cls.openstack('volume qos create ' + cls.NAME + opts)
30+
cls.ID, name, rol = raw_output.split('\n')
31+
cls.assertOutput(cls.NAME, name)
32+
33+
@classmethod
34+
def tearDownClass(cls):
35+
raw_output = cls.openstack('volume qos delete ' + cls.ID)
36+
cls.assertOutput('', raw_output)
37+
38+
def test_volume_qos_list(self):
39+
opts = self.get_list_opts(self.HEADERS)
40+
raw_output = self.openstack('volume qos list' + opts)
41+
self.assertIn(self.NAME, raw_output)
42+
43+
def test_volume_qos_show(self):
44+
opts = self.get_show_opts(self.FIELDS)
45+
raw_output = self.openstack('volume qos show ' + self.ID + opts)
46+
self.assertEqual(self.ID + "\n" + self.NAME + "\n", raw_output)
47+
48+
def test_volume_qos_metadata(self):
49+
raw_output = self.openstack(
50+
'volume qos set --property a=b --property c=d ' + self.ID)
51+
self.assertEqual("", raw_output)
52+
opts = self.get_show_opts(['name', 'specs'])
53+
raw_output = self.openstack('volume qos show ' + self.ID + opts)
54+
self.assertEqual(self.NAME + "\na='b', c='d'\n", raw_output)
55+
56+
raw_output = self.openstack(
57+
'volume qos unset --property a ' + self.ID)
58+
self.assertEqual("", raw_output)
59+
opts = self.get_show_opts(['name', 'specs'])
60+
raw_output = self.openstack('volume qos show ' + self.ID + opts)
61+
self.assertEqual(self.NAME + "\nc='d'\n", raw_output)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
import uuid
14+
15+
from functional.common import test
16+
17+
18+
class VolumeTypeTests(test.TestCase):
19+
"""Functional tests for volume type. """
20+
21+
NAME = uuid.uuid4().hex
22+
HEADERS = ['"Name"']
23+
FIELDS = ['name']
24+
25+
@classmethod
26+
def setUpClass(cls):
27+
opts = cls.get_show_opts(cls.FIELDS)
28+
raw_output = cls.openstack(
29+
'volume type create --private ' + cls.NAME + opts)
30+
expected = cls.NAME + '\n'
31+
cls.assertOutput(expected, raw_output)
32+
33+
@classmethod
34+
def tearDownClass(cls):
35+
raw_output = cls.openstack('volume type delete ' + cls.NAME)
36+
cls.assertOutput('', raw_output)
37+
38+
def test_volume_type_list(self):
39+
opts = self.get_list_opts(self.HEADERS)
40+
raw_output = self.openstack('volume type list' + opts)
41+
self.assertIn(self.NAME, raw_output)
42+
43+
def test_volume_type_show(self):
44+
opts = self.get_show_opts(self.FIELDS)
45+
raw_output = self.openstack('volume type show ' + self.NAME + opts)
46+
self.assertEqual(self.NAME + "\n", raw_output)
47+
48+
def test_volume_type_set_unset_properties(self):
49+
raw_output = self.openstack(
50+
'volume type set --property a=b --property c=d ' + self.NAME)
51+
self.assertEqual("", raw_output)
52+
53+
opts = self.get_show_opts(["properties"])
54+
raw_output = self.openstack('volume type show ' + self.NAME + opts)
55+
self.assertEqual("a='b', c='d'\n", raw_output)
56+
57+
raw_output = self.openstack('volume type unset --property a '
58+
+ self.NAME)
59+
self.assertEqual("", raw_output)
60+
raw_output = self.openstack('volume type show ' + self.NAME + opts)
61+
self.assertEqual("c='d'\n", raw_output)
62+
63+
def test_volume_type_set_unset_project(self):
64+
raw_output = self.openstack(
65+
'volume type set --project admin ' + self.NAME)
66+
self.assertEqual("", raw_output)
67+
68+
raw_output = self.openstack(
69+
'volume type unset --project admin ' + self.NAME)
70+
self.assertEqual("", raw_output)

0 commit comments

Comments
 (0)