blob: b97ab2c51caf78825768bf045ffd2764f94c1586 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Rohit Karajgi07599c52012-11-02 05:35:16 -07002# 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
Sean Dague1937d092013-05-17 16:36:38 -040016from tempest.api.compute import base
Chris Yeoh9465b0b2013-02-09 22:19:15 +103017from tempest.test import attr
Rohit Karajgi07599c52012-11-02 05:35:16 -070018
19
ivan-zhuf2b00502013-10-18 10:06:52 +080020class QuotasTestJSON(base.BaseV2ComputeTest):
Rohit Karajgi07599c52012-11-02 05:35:16 -070021
22 @classmethod
23 def setUpClass(cls):
Attila Fazekas19044d52013-02-16 07:35:06 +010024 super(QuotasTestJSON, cls).setUpClass()
Rohit Karajgi07599c52012-11-02 05:35:16 -070025 cls.client = cls.quotas_client
26 cls.admin_client = cls._get_identity_admin_client()
27 resp, tenants = cls.admin_client.list_tenants()
28 cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
29 cls.client.tenant_name][0]
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020030 cls.default_quota_set = set(('injected_file_content_bytes',
31 'metadata_items', 'injected_files',
32 'ram', 'floating_ips',
33 'fixed_ips', 'key_pairs',
34 'injected_file_path_bytes',
35 'instances', 'security_group_rules',
36 'cores', 'security_groups'))
Leo Toyoda87a52b72013-04-09 10:34:40 +090037
38 @attr(type='smoke')
39 def test_get_quotas(self):
40 # User can get the quota set for it's tenant
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020041 expected_quota_set = self.default_quota_set | set(['id'])
Leo Toyoda87a52b72013-04-09 10:34:40 +090042 resp, quota_set = self.client.get_quota_set(self.tenant_id)
43 self.assertEqual(200, resp.status)
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020044 self.assertEqual(sorted(expected_quota_set),
45 sorted(quota_set.keys()))
46 self.assertEqual(quota_set['id'], self.tenant_id)
Rohit Karajgi07599c52012-11-02 05:35:16 -070047
48 @attr(type='smoke')
49 def test_get_default_quotas(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050050 # User can get the default quota set for it's tenant
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020051 expected_quota_set = self.default_quota_set | set(['id'])
Leo Toyoda87a52b72013-04-09 10:34:40 +090052 resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
53 self.assertEqual(200, resp.status)
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020054 self.assertEqual(sorted(expected_quota_set),
55 sorted(quota_set.keys()))
56 self.assertEqual(quota_set['id'], self.tenant_id)
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053057
Daniel Korn6653c4e2013-10-28 10:51:23 +020058 @attr(type='smoke')
59 def test_compare_tenant_quotas_with_default_quotas(self):
60 # Tenants are created with the default quota values
61 resp, defualt_quota_set = \
62 self.client.get_default_quota_set(self.tenant_id)
63 self.assertEqual(200, resp.status)
64 resp, tenant_quota_set = self.client.get_quota_set(self.tenant_id)
65 self.assertEqual(200, resp.status)
66 self.assertEqual(defualt_quota_set, tenant_quota_set)
67
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053068
Attila Fazekas19044d52013-02-16 07:35:06 +010069class QuotasTestXML(QuotasTestJSON):
70 _interface = 'xml'