Skip to content

Commit 13bb1cb

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add CLI read-only functional tests"
2 parents c15ab5b + 4c5e5e4 commit 13bb1cb

6 files changed

Lines changed: 151 additions & 1 deletion

File tree

.testr.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[DEFAULT]
2-
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./cinderclient/tests} $LISTOPT $IDOPTION
2+
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./cinderclient/tests/unit} $LISTOPT $IDOPTION
33
test_id_option=--load-list $IDFILE
44
test_list_option=--list

cinderclient/tests/functional/__init__.py

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 os
14+
15+
from tempest_lib.cli import base
16+
from tempest_lib.cli import output_parser
17+
18+
19+
class ClientTestBase(base.ClientTestBase):
20+
"""Cinder base class, issues calls to cinderclient.
21+
22+
"""
23+
def setUp(self):
24+
super(ClientTestBase, self).setUp()
25+
self.clients = self._get_clients()
26+
self.parser = output_parser
27+
28+
def _get_clients(self):
29+
cli_dir = os.environ.get(
30+
'OS_CINDERCLIENT_EXEC_DIR',
31+
os.path.join(os.path.abspath('.'), '.tox/functional/bin'))
32+
33+
return base.CLIClient(
34+
username=os.environ.get('OS_USERNAME'),
35+
password=os.environ.get('OS_PASSWORD'),
36+
tenant_name=os.environ.get('OS_TENANT_NAME'),
37+
uri=os.environ.get('OS_AUTH_URL'),
38+
cli_dir=cli_dir)
39+
40+
def cinder(self, *args, **kwargs):
41+
return self.clients.cinder(*args,
42+
**kwargs)
43+
44+
def assertTableStruct(self, items, field_names):
45+
"""Verify that all items has keys listed in field_names.
46+
47+
:param items: items to assert are field names in the output table
48+
:type items: list
49+
:param field_names: field names from the output table of the cmd
50+
:type field_names: list
51+
"""
52+
# Strip off the --- if present
53+
54+
for item in items:
55+
for field in field_names:
56+
self.assertIn(field, item)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
14+
from cinderclient.tests.functional import base
15+
16+
17+
class CinderClientReadOnlyTests(base.ClientTestBase):
18+
"""Basic read-only test for cinderclient.
19+
20+
Simple check of base list commands, verify they
21+
respond and include the expected headers in the
22+
resultant table.
23+
24+
Not intended for testing things that require actual
25+
resource creation/manipulation, thus the name 'read-only'.
26+
27+
"""
28+
29+
# Commands in order listed in 'cinder help'
30+
def test_absolute_limits(self):
31+
limits = self.parser.listing(self.cinder('absolute-limits'))
32+
self.assertTableStruct(limits, ['Name', 'Value'])
33+
34+
def test_availability_zones(self):
35+
zone_list = self.parser.listing(self.cinder('availability-zone-list'))
36+
self.assertTableStruct(zone_list, ['Name', 'Status'])
37+
38+
def test_backup_list(self):
39+
backup_list = self.parser.listing(self.cinder('backup-list'))
40+
self.assertTableStruct(backup_list, ['ID', 'Volume ID', 'Status',
41+
'Name', 'Size', 'Object Count',
42+
'Container'])
43+
44+
def test_encryption_type_list(self):
45+
encrypt_list = self.parser.listing(self.cinder('encryption-type-list'))
46+
self.assertTableStruct(encrypt_list, ['Volume Type ID', 'Provider',
47+
'Cipher', 'Key Size',
48+
'Control Location'])
49+
50+
def test_endpoints(self):
51+
out = self.cinder('endpoints')
52+
tables = self.parser.tables(out)
53+
for table in tables:
54+
headers = table['headers']
55+
self.assertTrue(2 >= len(headers))
56+
self.assertEqual('Value', headers[1])
57+
58+
def test_list(self):
59+
list = self.parser.listing(self.cinder('list'))
60+
self.assertTableStruct(list, ['ID', 'Status', 'Name', 'Size',
61+
'Volume Type', 'Bootable',
62+
'Attached to'])
63+
64+
def test_qos_list(self):
65+
qos_list = self.parser.listing(self.cinder('qos-list'))
66+
self.assertTableStruct(qos_list, ['ID', 'Name', 'Consumer', 'specs'])
67+
68+
def test_rate_limits(self):
69+
rate_limits = self.parser.listing(self.cinder('rate-limits'))
70+
self.assertTableStruct(rate_limits, ['Verb', 'URI', 'Value', 'Remain',
71+
'Unit', 'Next_Available'])
72+
73+
def test_service_list(self):
74+
service_list = self.parser.listing(self.cinder('service-list'))
75+
self.assertTableStruct(service_list, ['Binary', 'Host', 'Zone',
76+
'Status', 'State', 'Updated_at'])
77+
78+
def test_snapshot_list(self):
79+
snapshot_list = self.parser.listing(self.cinder('snapshot-list'))
80+
self.assertTableStruct(snapshot_list, ['ID', 'Volume ID', 'Status',
81+
'Name', 'Size'])
82+
83+
def test_transfer_list(self):
84+
transfer_list = self.parser.listing(self.cinder('transfer-list'))
85+
self.assertTableStruct(transfer_list, ['ID', 'Volume ID', 'Name'])
86+
87+
def test_type_list(self):
88+
type_list = self.parser.listing(self.cinder('type-list'))
89+
self.assertTableStruct(type_list, ['ID', 'Name'])

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ oslosphinx>=2.5.0 # Apache-2.0
1111
python-subunit>=0.0.18
1212
requests-mock>=0.6.0 # Apache-2.0
1313
sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3
14+
tempest-lib>=0.5.0
1415
testtools>=0.9.36,!=1.2.0
1516
testrepository>=0.0.18

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
2626
commands=
2727
python setup.py build_sphinx
2828

29+
[testenv:functional]
30+
setenv =
31+
OS_TEST_PATH = ./cinderclient/tests/functional
32+
2933
[tox:jenkins]
3034
downloadcache = ~/cache/pip
3135

0 commit comments

Comments
 (0)