Skip to content

Commit c7c672d

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add quota functional tests"
2 parents 6117e1c + ea0b8f9 commit c7c672d

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

functional/common/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ def openstack(cls, cmd, fail_ok=False):
5151
"""Executes openstackclient command for the given action."""
5252
return execute('openstack ' + cmd, fail_ok=fail_ok)
5353

54+
@classmethod
55+
def get_openstack_configuration_value(cls, configuration):
56+
opts = cls.get_show_opts([configuration])
57+
return cls.openstack('configuration show ' + opts)
58+
5459
@classmethod
5560
def get_show_opts(cls, fields=[]):
5661
return ' -f value ' + ' '.join(['-c ' + it for it in fields])
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
from functional.common import test
14+
15+
16+
class QuotaTests(test.TestCase):
17+
"""Functional tests for quota. """
18+
# Test quota information for compute, network and volume.
19+
EXPECTED_FIELDS = ['instances', 'network', 'volumes']
20+
PROJECT_NAME = None
21+
22+
@classmethod
23+
def setUpClass(cls):
24+
cls.PROJECT_NAME =\
25+
cls.get_openstack_configuration_value('auth.project_name')
26+
27+
def test_quota_set(self):
28+
# TODO(rtheis): Add --network option once supported on set.
29+
self.openstack('quota set --instances 11 --volumes 11 ' +
30+
self.PROJECT_NAME)
31+
opts = self.get_show_opts(self.EXPECTED_FIELDS)
32+
raw_output = self.openstack('quota show ' + self.PROJECT_NAME + opts)
33+
self.assertEqual("11\n10\n11\n", raw_output)
34+
35+
def test_quota_show(self):
36+
raw_output = self.openstack('quota show ' + self.PROJECT_NAME)
37+
for expected_field in self.EXPECTED_FIELDS:
38+
self.assertInOutput(expected_field, raw_output)

0 commit comments

Comments
 (0)