Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 3 | # Copyright 2012 OpenStack Foundation |
Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 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 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Chris Yeoh | 9465b0b | 2013-02-09 22:19:15 +1030 | [diff] [blame] | 19 | from tempest.test import attr |
Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 20 | |
| 21 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 22 | class QuotasTestJSON(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 23 | _interface = 'json' |
Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 24 | |
| 25 | @classmethod |
| 26 | def setUpClass(cls): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 27 | super(QuotasTestJSON, cls).setUpClass() |
Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 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] |
Attila Fazekas | d9aef1e | 2013-07-13 17:33:45 +0200 | [diff] [blame] | 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')) |
Leo Toyoda | 87a52b7 | 2013-04-09 10:34:40 +0900 | [diff] [blame] | 40 | |
| 41 | @attr(type='smoke') |
| 42 | def test_get_quotas(self): |
| 43 | # User can get the quota set for it's tenant |
Attila Fazekas | d9aef1e | 2013-07-13 17:33:45 +0200 | [diff] [blame] | 44 | expected_quota_set = self.default_quota_set | set(['id']) |
Leo Toyoda | 87a52b7 | 2013-04-09 10:34:40 +0900 | [diff] [blame] | 45 | resp, quota_set = self.client.get_quota_set(self.tenant_id) |
| 46 | self.assertEqual(200, resp.status) |
Attila Fazekas | d9aef1e | 2013-07-13 17:33:45 +0200 | [diff] [blame] | 47 | self.assertEqual(sorted(expected_quota_set), |
| 48 | sorted(quota_set.keys())) |
| 49 | self.assertEqual(quota_set['id'], self.tenant_id) |
Rohit Karajgi | 07599c5 | 2012-11-02 05:35:16 -0700 | [diff] [blame] | 50 | |
| 51 | @attr(type='smoke') |
| 52 | def test_get_default_quotas(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 53 | # User can get the default quota set for it's tenant |
Attila Fazekas | d9aef1e | 2013-07-13 17:33:45 +0200 | [diff] [blame] | 54 | expected_quota_set = self.default_quota_set | set(['id']) |
Leo Toyoda | 87a52b7 | 2013-04-09 10:34:40 +0900 | [diff] [blame] | 55 | resp, quota_set = self.client.get_default_quota_set(self.tenant_id) |
| 56 | self.assertEqual(200, resp.status) |
Attila Fazekas | d9aef1e | 2013-07-13 17:33:45 +0200 | [diff] [blame] | 57 | self.assertEqual(sorted(expected_quota_set), |
| 58 | sorted(quota_set.keys())) |
| 59 | self.assertEqual(quota_set['id'], self.tenant_id) |
rajalakshmi-ganesan | 1982c3c | 2013-01-10 14:56:45 +0530 | [diff] [blame] | 60 | |
| 61 | |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 62 | class QuotasTestXML(QuotasTestJSON): |
| 63 | _interface = 'xml' |