blob: 475d055141a01e0b711f9480d7593e996690787a [file] [log] [blame]
ivan-zhu24358182013-11-27 15:08:06 +08001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack Foundation
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
18from tempest.api.compute import base
19from tempest.test import attr
20
21
22class QuotasTestJSON(base.BaseV2ComputeTest):
23 _interface = 'json'
24
25 @classmethod
26 def setUpClass(cls):
27 super(QuotasTestJSON, cls).setUpClass()
28 cls.client = cls.quotas_client
29 cls.admin_client = cls._get_identity_admin_client()
30 resp, tenants = cls.admin_client.list_tenants()
31 cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
32 cls.client.tenant_name][0]
33 cls.default_quota_set = set(('injected_file_content_bytes',
34 'metadata_items', 'injected_files',
35 'ram', 'floating_ips',
36 'fixed_ips', 'key_pairs',
37 'injected_file_path_bytes',
38 'instances', 'security_group_rules',
39 'cores', 'security_groups'))
40
41 @attr(type='smoke')
42 def test_get_quotas(self):
43 # User can get the quota set for it's tenant
44 expected_quota_set = self.default_quota_set | set(['id'])
45 resp, quota_set = self.client.get_quota_set(self.tenant_id)
46 self.assertEqual(200, resp.status)
47 self.assertEqual(sorted(expected_quota_set),
48 sorted(quota_set.keys()))
49 self.assertEqual(quota_set['id'], self.tenant_id)
50
51 @attr(type='smoke')
52 def test_get_default_quotas(self):
53 # User can get the default quota set for it's tenant
54 expected_quota_set = self.default_quota_set | set(['id'])
55 resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
56 self.assertEqual(200, resp.status)
57 self.assertEqual(sorted(expected_quota_set),
58 sorted(quota_set.keys()))
59 self.assertEqual(quota_set['id'], self.tenant_id)
60
61 @attr(type='smoke')
62 def test_compare_tenant_quotas_with_default_quotas(self):
63 # Tenants are created with the default quota values
64 resp, defualt_quota_set = \
65 self.client.get_default_quota_set(self.tenant_id)
66 self.assertEqual(200, resp.status)
67 resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
68 self.assertEqual(200, resp.status)
69 self.assertEqual(defualt_quota_set, tenant_quota_set)
70
71
72class QuotasTestXML(QuotasTestJSON):
73 _interface = 'xml'