blob: 4617bd2d035ab9d3235f8440e1a646fcfe7697bf [file] [log] [blame]
Rohit Karajgi07599c52012-11-02 05:35:16 -07001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2012 OpenStack Foundation
Rohit Karajgi07599c52012-11-02 05:35:16 -07004# 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
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Chris Yeoh9465b0b2013-02-09 22:19:15 +103019from tempest.test import attr
Rohit Karajgi07599c52012-11-02 05:35:16 -070020
21
ivan-zhuf2b00502013-10-18 10:06:52 +080022class QuotasTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010023 _interface = 'json'
Rohit Karajgi07599c52012-11-02 05:35:16 -070024
25 @classmethod
26 def setUpClass(cls):
Attila Fazekas19044d52013-02-16 07:35:06 +010027 super(QuotasTestJSON, cls).setUpClass()
Rohit Karajgi07599c52012-11-02 05:35:16 -070028 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]
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020033 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'))
Leo Toyoda87a52b72013-04-09 10:34:40 +090040
41 @attr(type='smoke')
42 def test_get_quotas(self):
43 # User can get the quota set for it's tenant
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020044 expected_quota_set = self.default_quota_set | set(['id'])
Leo Toyoda87a52b72013-04-09 10:34:40 +090045 resp, quota_set = self.client.get_quota_set(self.tenant_id)
46 self.assertEqual(200, resp.status)
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020047 self.assertEqual(sorted(expected_quota_set),
48 sorted(quota_set.keys()))
49 self.assertEqual(quota_set['id'], self.tenant_id)
Rohit Karajgi07599c52012-11-02 05:35:16 -070050
51 @attr(type='smoke')
52 def test_get_default_quotas(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050053 # User can get the default quota set for it's tenant
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020054 expected_quota_set = self.default_quota_set | set(['id'])
Leo Toyoda87a52b72013-04-09 10:34:40 +090055 resp, quota_set = self.client.get_default_quota_set(self.tenant_id)
56 self.assertEqual(200, resp.status)
Attila Fazekasd9aef1e2013-07-13 17:33:45 +020057 self.assertEqual(sorted(expected_quota_set),
58 sorted(quota_set.keys()))
59 self.assertEqual(quota_set['id'], self.tenant_id)
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053060
61
Attila Fazekas19044d52013-02-16 07:35:06 +010062class QuotasTestXML(QuotasTestJSON):
63 _interface = 'xml'