2016-02-12 12:48:33 -06:00
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2016-09-05 20:35:06 -07:00
|
|
|
from openstackclient.tests.functional import base
|
2016-02-12 12:48:33 -06:00
|
|
|
|
|
|
|
|
2016-09-05 20:35:06 -07:00
|
|
|
class QuotaTests(base.TestCase):
|
2016-02-12 12:48:33 -06:00
|
|
|
"""Functional tests for quota. """
|
|
|
|
# Test quota information for compute, network and volume.
|
2016-03-14 19:27:36 +08:00
|
|
|
EXPECTED_FIELDS = ['instances', 'networks', 'volumes']
|
2016-07-11 09:55:22 +08:00
|
|
|
EXPECTED_CLASS_FIELDS = ['instances', 'volumes']
|
2016-02-12 12:48:33 -06:00
|
|
|
PROJECT_NAME = None
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
cls.PROJECT_NAME =\
|
|
|
|
cls.get_openstack_configuration_value('auth.project_name')
|
|
|
|
|
2016-09-29 15:32:51 -05:00
|
|
|
def test_quota_list_network_option(self):
|
|
|
|
self.openstack('quota set --networks 40 ' +
|
|
|
|
self.PROJECT_NAME)
|
|
|
|
raw_output = self.openstack('quota list --network')
|
|
|
|
self.assertIsNotNone(raw_output)
|
|
|
|
self.assertIn("40", raw_output)
|
|
|
|
|
|
|
|
def test_quota_list_compute_option(self):
|
|
|
|
self.openstack('quota set --instances 40 ' +
|
|
|
|
self.PROJECT_NAME)
|
|
|
|
raw_output = self.openstack('quota list --compute')
|
|
|
|
self.assertIsNotNone(raw_output)
|
|
|
|
self.assertIn("40", raw_output)
|
|
|
|
|
|
|
|
def test_quota_list_volume_option(self):
|
|
|
|
self.openstack('quota set --backups 40 ' +
|
|
|
|
self.PROJECT_NAME)
|
|
|
|
raw_output = self.openstack('quota list --volume')
|
|
|
|
self.assertIsNotNone(raw_output)
|
|
|
|
self.assertIn("40", raw_output)
|
|
|
|
|
2016-02-12 12:48:33 -06:00
|
|
|
def test_quota_set(self):
|
2016-08-05 16:49:08 +08:00
|
|
|
self.openstack('quota set --instances 11 --volumes 11 --networks 11 ' +
|
|
|
|
self.PROJECT_NAME)
|
2016-07-05 12:16:18 +03:00
|
|
|
opts = self.get_opts(self.EXPECTED_FIELDS)
|
2016-02-12 12:48:33 -06:00
|
|
|
raw_output = self.openstack('quota show ' + self.PROJECT_NAME + opts)
|
2016-03-14 19:27:36 +08:00
|
|
|
self.assertEqual("11\n11\n11\n", raw_output)
|
2016-02-12 12:48:33 -06:00
|
|
|
|
|
|
|
def test_quota_show(self):
|
|
|
|
raw_output = self.openstack('quota show ' + self.PROJECT_NAME)
|
|
|
|
for expected_field in self.EXPECTED_FIELDS:
|
2016-04-06 01:12:40 +02:00
|
|
|
self.assertIn(expected_field, raw_output)
|
2016-04-21 11:33:24 -05:00
|
|
|
|
|
|
|
def test_quota_show_default_project(self):
|
|
|
|
raw_output = self.openstack('quota show')
|
|
|
|
for expected_field in self.EXPECTED_FIELDS:
|
|
|
|
self.assertIn(expected_field, raw_output)
|
2016-07-11 09:55:22 +08:00
|
|
|
|
|
|
|
def test_quota_show_with_default_option(self):
|
|
|
|
raw_output = self.openstack('quota show --default')
|
|
|
|
for expected_field in self.EXPECTED_FIELDS:
|
|
|
|
self.assertIn(expected_field, raw_output)
|
|
|
|
|
|
|
|
def test_quota_show_with_class_option(self):
|
|
|
|
raw_output = self.openstack('quota show --class')
|
|
|
|
for expected_field in self.EXPECTED_CLASS_FIELDS:
|
|
|
|
self.assertIn(expected_field, raw_output)
|
2016-08-05 16:49:08 +08:00
|
|
|
|
|
|
|
def test_quota_class_set(self):
|
|
|
|
class_name = 'default'
|
|
|
|
class_expected_fields = ['instances', 'volumes']
|
|
|
|
self.openstack('quota set --instances 11 --volumes 11 --class ' +
|
|
|
|
class_name)
|
|
|
|
opts = self.get_opts(class_expected_fields)
|
|
|
|
raw_output = self.openstack('quota show --class ' + class_name + opts)
|
|
|
|
self.assertEqual("11\n11\n", raw_output)
|