blob: 62a75563320b83e7662a7c5b55ad7ffc8cd8670b [file] [log] [blame]
ivan-zhu24358182013-11-27 15:08:06 +08001# Copyright 2012 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16from tempest.api.compute import base
ivan-zhub6d69ee2013-12-17 14:16:31 +080017from tempest import test
ivan-zhu24358182013-11-27 15:08:06 +080018
19
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090020class QuotasV3Test(base.BaseV3ComputeTest):
ivan-zhu24358182013-11-27 15:08:06 +080021
22 @classmethod
23 def setUpClass(cls):
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090024 super(QuotasV3Test, cls).setUpClass()
ivan-zhu24358182013-11-27 15:08:06 +080025 cls.client = cls.quotas_client
Andrea Frittoli9612e812014-03-13 10:57:26 +000026 cls.tenant_id = cls.client.tenant_id
27 cls.user_id = cls.client.user_id
ivan-zhub6d69ee2013-12-17 14:16:31 +080028 cls.default_quota_set = set(('metadata_items',
ivan-zhu24358182013-11-27 15:08:06 +080029 'ram', 'floating_ips',
30 'fixed_ips', 'key_pairs',
ivan-zhu24358182013-11-27 15:08:06 +080031 'instances', 'security_group_rules',
32 'cores', 'security_groups'))
33
ivan-zhub6d69ee2013-12-17 14:16:31 +080034 @test.attr(type='smoke')
ivan-zhu24358182013-11-27 15:08:06 +080035 def test_get_quotas(self):
36 # User can get the quota set for it's tenant
37 expected_quota_set = self.default_quota_set | set(['id'])
38 resp, quota_set = self.client.get_quota_set(self.tenant_id)
39 self.assertEqual(200, resp.status)
40 self.assertEqual(sorted(expected_quota_set),
41 sorted(quota_set.keys()))
42 self.assertEqual(quota_set['id'], self.tenant_id)
43
Zhi Kun Liu90e41312014-03-06 14:56:01 +080044 # get the quota set using user id
45 resp, quota_set = self.client.get_quota_set(self.tenant_id,
46 self.user_id)
47 self.assertEqual(200, resp.status)
48 self.assertEqual(sorted(expected_quota_set),
49 sorted(quota_set.keys()))
50 self.assertEqual(quota_set['id'], self.tenant_id)
51
ivan-zhub6d69ee2013-12-17 14:16:31 +080052 @test.attr(type='smoke')
ivan-zhu24358182013-11-27 15:08:06 +080053 def test_get_default_quotas(self):
54 # User can get the default quota set for it's tenant
55 expected_quota_set = self.default_quota_set | set(['id'])
56 resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
57 self.assertEqual(200, resp.status)
58 self.assertEqual(sorted(expected_quota_set),
59 sorted(quota_set.keys()))
60 self.assertEqual(quota_set['id'], self.tenant_id)
61
ivan-zhub6d69ee2013-12-17 14:16:31 +080062 @test.attr(type='smoke')
ivan-zhu24358182013-11-27 15:08:06 +080063 def test_compare_tenant_quotas_with_default_quotas(self):
64 # Tenants are created with the default quota values
65 resp, defualt_quota_set = \
66 self.client.get_default_quota_set(self.tenant_id)
67 self.assertEqual(200, resp.status)
68 resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
69 self.assertEqual(200, resp.status)
70 self.assertEqual(defualt_quota_set, tenant_quota_set)