Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2013 Hewlett-Packard Development Company, L.P. |
| 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 | |
Mark McClain | f2982e8 | 2013-07-06 17:48:03 -0400 | [diff] [blame] | 18 | from neutronclient.common import exceptions as exc |
Matthew Treinish | f441859 | 2013-09-09 20:59:23 +0000 | [diff] [blame^] | 19 | |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 20 | from tempest.scenario.manager import NetworkScenarioTest |
Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 21 | |
| 22 | MAX_REASONABLE_ITERATIONS = 51 # more than enough. Default for port is 50. |
| 23 | |
| 24 | |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 25 | class TestNetworkQuotaBasic(NetworkScenarioTest): |
Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 26 | """ |
| 27 | This test suite contains tests that each loop trying to grab a |
| 28 | particular resource until a quota limit is hit. |
| 29 | For sanity, there is a maximum number of iterations - if this is hit |
| 30 | the test fails. Covers network, subnet, port. |
| 31 | """ |
| 32 | |
| 33 | @classmethod |
| 34 | def check_preconditions(cls): |
| 35 | super(TestNetworkQuotaBasic, cls).check_preconditions() |
| 36 | |
| 37 | @classmethod |
| 38 | def setUpClass(cls): |
| 39 | super(TestNetworkQuotaBasic, cls).setUpClass() |
| 40 | cls.check_preconditions() |
| 41 | cls.networks = [] |
| 42 | cls.subnets = [] |
| 43 | cls.ports = [] |
| 44 | |
| 45 | def test_create_network_until_quota_hit(self): |
| 46 | hit_limit = False |
| 47 | for n in xrange(MAX_REASONABLE_ITERATIONS): |
| 48 | try: |
| 49 | self.networks.append( |
| 50 | self._create_network(self.tenant_id, |
| 51 | namestart='network-quotatest-')) |
Mark McClain | f2982e8 | 2013-07-06 17:48:03 -0400 | [diff] [blame] | 52 | except exc.NeutronClientException as e: |
Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 53 | if (e.status_code != 409): |
| 54 | raise |
| 55 | hit_limit = True |
| 56 | break |
| 57 | self.assertTrue(hit_limit, "Failed: Did not hit quota limit !") |
| 58 | |
| 59 | def test_create_subnet_until_quota_hit(self): |
| 60 | if not self.networks: |
| 61 | self.networks.append( |
| 62 | self._create_network(self.tenant_id, |
| 63 | namestart='network-quotatest-')) |
| 64 | hit_limit = False |
| 65 | for n in xrange(MAX_REASONABLE_ITERATIONS): |
| 66 | try: |
| 67 | self.subnets.append( |
| 68 | self._create_subnet(self.networks[0], |
| 69 | namestart='subnet-quotatest-')) |
Mark McClain | f2982e8 | 2013-07-06 17:48:03 -0400 | [diff] [blame] | 70 | except exc.NeutronClientException as e: |
Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 71 | if (e.status_code != 409): |
| 72 | raise |
| 73 | hit_limit = True |
| 74 | break |
| 75 | self.assertTrue(hit_limit, "Failed: Did not hit quota limit !") |
| 76 | |
| 77 | def test_create_ports_until_quota_hit(self): |
| 78 | if not self.networks: |
| 79 | self.networks.append( |
| 80 | self._create_network(self.tenant_id, |
| 81 | namestart='network-quotatest-')) |
| 82 | hit_limit = False |
| 83 | for n in xrange(MAX_REASONABLE_ITERATIONS): |
| 84 | try: |
| 85 | self.ports.append( |
| 86 | self._create_port(self.networks[0], |
| 87 | namestart='port-quotatest-')) |
Mark McClain | f2982e8 | 2013-07-06 17:48:03 -0400 | [diff] [blame] | 88 | except exc.NeutronClientException as e: |
Gavin Brebner | 516487b | 2013-03-14 13:43:21 +0000 | [diff] [blame] | 89 | if (e.status_code != 409): |
| 90 | raise |
| 91 | hit_limit = True |
| 92 | break |
| 93 | self.assertTrue(hit_limit, "Failed: Did not hit quota limit !") |