blob: 93063510d0e18a61d61cfe9358671d3ea76434a8 [file] [log] [blame]
Rohit Karajgi07599c52012-11-02 05:35:16 -07001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
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 nose.plugins.attrib import attr
19
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053020from tempest.tests.compute import base
Rohit Karajgi07599c52012-11-02 05:35:16 -070021
22
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053023class QuotasTestBase(object):
Rohit Karajgi07599c52012-11-02 05:35:16 -070024
25 @classmethod
26 def setUpClass(cls):
Rohit Karajgi07599c52012-11-02 05:35:16 -070027 cls.client = cls.quotas_client
28 cls.admin_client = cls._get_identity_admin_client()
29 resp, tenants = cls.admin_client.list_tenants()
30 cls.tenant_id = [tnt['id'] for tnt in tenants if tnt['name'] ==
31 cls.client.tenant_name][0]
32
33 @attr(type='smoke')
34 def test_get_default_quotas(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050035 # User can get the default quota set for it's tenant
Rohit Karajgi07599c52012-11-02 05:35:16 -070036 expected_quota_set = {'injected_file_content_bytes': 10240,
37 'metadata_items': 128, 'injected_files': 5,
38 'ram': 51200, 'floating_ips': 10,
39 'key_pairs': 100,
40 'injected_file_path_bytes': 255, 'instances': 10,
41 'security_group_rules': 20, 'cores': 20,
42 'id': self.tenant_id, 'security_groups': 10}
43 try:
44 resp, quota_set = self.client.get_quota_set(self.tenant_id)
45 self.assertEqual(200, resp.status)
46 self.assertSequenceEqual(expected_quota_set, quota_set)
Matthew Treinish05d9fb92012-12-07 16:14:05 -050047 except Exception:
Rohit Karajgi07599c52012-11-02 05:35:16 -070048 self.fail("Quota set for tenant did not have default limits")
rajalakshmi-ganesan1982c3c2013-01-10 14:56:45 +053049
50
51class QuotasTestJSON(QuotasTestBase, base.BaseComputeTestJSON):
52
53 @classmethod
54 def setUpClass(cls):
55 base.BaseComputeTestJSON.setUpClass()
56 super(QuotasTestJSON, cls).setUpClass()
57
58
59class QuotasTestXML(QuotasTestBase, base.BaseComputeTestXML):
60
61 @classmethod
62 def setUpClass(cls):
63 base.BaseComputeTestXML.setUpClass()
64 super(QuotasTestXML, cls).setUpClass()