From 451a5ff5d9c98048ca79d5a174fcaf72e8e938fa Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Thu, 20 Aug 2015 10:18:37 +0900 Subject: [PATCH] Merge limits functional tests of v2 and v2.1 Currently v2 and v2.1 have separate functional tests and their corresponding sample files. As v2 and v2.1 are supposed to be identical, there is overhead to maintain two set of functional tests and sample files. We can have one set of tests which can run for both v2 and v2.1. This commit merges limits functional tests. There was no functional tests for limits in v2.1 V2 implied RateLimitingMiddleware while V2.1 does not have that so the response data is different between V2 and V2.1, there are more info in "rate" section in V2 than V2.1. We have to keep both of the template files. Partially implements blueprint test-collapse-v2-and-v21 Change-Id: If4fbaaeaa1819083f7f4c460216023ae8f65021d --- .../legacy_v2/limits/limit-get-resp.json | 85 ------------------- doc/api_samples/limits/limit-get-resp.json | 20 +++++ .../v2-limit-get-resp.json} | 0 .../limits/limit-get-resp.json.tpl | 20 +++++ .../limits/v2-limit-get-resp.json.tpl} | 0 .../legacy_v2/limits/limit-get-resp.json.tpl | 85 ------------------- .../legacy_v2/test_api_samples.py | 15 ---- .../api_sample_tests/test_limits.py | 53 ++++++++++++ 8 files changed, 93 insertions(+), 185 deletions(-) delete mode 100644 doc/api_samples/legacy_v2/limits/limit-get-resp.json create mode 100644 doc/api_samples/limits/limit-get-resp.json rename doc/api_samples/{legacy_v2/os-server-group-quotas/limit-get-resp.json => limits/v2-limit-get-resp.json} (100%) create mode 100644 nova/tests/functional/api_sample_tests/api_samples/limits/limit-get-resp.json.tpl rename nova/tests/functional/api_sample_tests/{legacy_v2/os-server-group-quotas/limit-get-resp.json.tpl => api_samples/limits/v2-limit-get-resp.json.tpl} (100%) delete mode 100644 nova/tests/functional/api_sample_tests/legacy_v2/limits/limit-get-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/test_limits.py diff --git a/doc/api_samples/legacy_v2/limits/limit-get-resp.json b/doc/api_samples/legacy_v2/limits/limit-get-resp.json deleted file mode 100644 index 967633dfcb39..000000000000 --- a/doc/api_samples/legacy_v2/limits/limit-get-resp.json +++ /dev/null @@ -1,85 +0,0 @@ -{ - "limits": { - "absolute": { - "maxImageMeta": 128, - "maxPersonality": 5, - "maxPersonalitySize": 10240, - "maxSecurityGroupRules": 20, - "maxSecurityGroups": 10, - "maxServerMeta": 128, - "maxTotalCores": 20, - "maxTotalFloatingIps": 10, - "maxTotalInstances": 10, - "maxTotalKeypairs": 100, - "maxTotalRAMSize": 51200 - }, - "rate": [ - { - "limit": [ - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - }, - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "PUT" - }, - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "DELETE" - } - ], - "regex": ".*", - "uri": "*" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - } - ], - "regex": "^/servers", - "uri": "*/servers" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "GET" - } - ], - "regex": ".*changes-since.*", - "uri": "*changes-since*" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:22:18Z", - "remaining": 12, - "unit": "MINUTE", - "value": 12, - "verb": "GET" - } - ], - "regex": "^/os-fping", - "uri": "*/os-fping" - } - ] - } -} diff --git a/doc/api_samples/limits/limit-get-resp.json b/doc/api_samples/limits/limit-get-resp.json new file mode 100644 index 000000000000..79171f5ff026 --- /dev/null +++ b/doc/api_samples/limits/limit-get-resp.json @@ -0,0 +1,20 @@ +{ + "limits": { + "absolute": { + "maxImageMeta": 128, + "maxPersonality": 5, + "maxPersonalitySize": 10240, + "maxSecurityGroupRules": 20, + "maxSecurityGroups": 10, + "maxServerMeta": 128, + "maxTotalCores": 20, + "maxTotalFloatingIps": 10, + "maxTotalInstances": 10, + "maxTotalKeypairs": 100, + "maxTotalRAMSize": 51200, + "maxServerGroups": 10, + "maxServerGroupMembers": 10 + }, + "rate": [] + } +} diff --git a/doc/api_samples/legacy_v2/os-server-group-quotas/limit-get-resp.json b/doc/api_samples/limits/v2-limit-get-resp.json similarity index 100% rename from doc/api_samples/legacy_v2/os-server-group-quotas/limit-get-resp.json rename to doc/api_samples/limits/v2-limit-get-resp.json diff --git a/nova/tests/functional/api_sample_tests/api_samples/limits/limit-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/limits/limit-get-resp.json.tpl new file mode 100644 index 000000000000..d1d8342fc083 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/api_samples/limits/limit-get-resp.json.tpl @@ -0,0 +1,20 @@ +{ + "limits": { + "absolute": { + "maxImageMeta": 128, + "maxPersonality": 5, + "maxPersonalitySize": 10240, + "maxServerMeta": 128, + "maxTotalCores": 20, + "maxTotalFloatingIps": 10, + "maxTotalInstances": 10, + "maxTotalKeypairs": 100, + "maxTotalRAMSize": 51200, + "maxSecurityGroups": 10, + "maxSecurityGroupRules": 20, + "maxServerGroups": 10, + "maxServerGroupMembers": 10 + }, + "rate": [] + } +} diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/os-server-group-quotas/limit-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl similarity index 100% rename from nova/tests/functional/api_sample_tests/legacy_v2/os-server-group-quotas/limit-get-resp.json.tpl rename to nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/limits/limit-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/legacy_v2/limits/limit-get-resp.json.tpl deleted file mode 100644 index f5b30047da66..000000000000 --- a/nova/tests/functional/api_sample_tests/legacy_v2/limits/limit-get-resp.json.tpl +++ /dev/null @@ -1,85 +0,0 @@ -{ - "limits": { - "absolute": { - "maxImageMeta": 128, - "maxPersonality": 5, - "maxPersonalitySize": 10240, - "maxServerMeta": 128, - "maxTotalCores": 20, - "maxTotalFloatingIps": 10, - "maxTotalInstances": 10, - "maxTotalKeypairs": 100, - "maxTotalRAMSize": 51200, - "maxSecurityGroups": 10, - "maxSecurityGroupRules": 20 - }, - "rate": [ - { - "limit": [ - { - "next-available": "%(isotime)s", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - }, - { - "next-available": "%(isotime)s", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "PUT" - }, - { - "next-available": "%(isotime)s", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "DELETE" - } - ], - "regex": ".*", - "uri": "*" - }, - { - "limit": [ - { - "next-available": "%(isotime)s", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - } - ], - "regex": "^/servers", - "uri": "*/servers" - }, - { - "limit": [ - { - "next-available": "%(isotime)s", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "GET" - } - ], - "regex": ".*changes-since.*", - "uri": "*changes-since*" - }, - { - "limit": [ - { - "next-available": "%(isotime)s", - "remaining": 12, - "unit": "MINUTE", - "value": 12, - "verb": "GET" - } - ], - "regex": "^/os-fping", - "uri": "*/os-fping" - } - ] - } -} diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py b/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py index e0b7707ade88..934cf5c11a11 100644 --- a/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py +++ b/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py @@ -156,15 +156,6 @@ class ServersSampleBase(ApiSampleTestBaseV2): self.__class__._use_common_server_api_samples = orig_value -class LimitsSampleJsonTest(ApiSampleTestBaseV2): - sample_dir = 'limits' - - def test_limits_get(self): - response = self._do_get('limits') - subs = self._get_regexes() - self._verify_response('limit-get-resp', subs, response, 200) - - class ExtendedIpsSampleJsonTests(ServersSampleBase): extension_name = ("nova.api.openstack.compute.legacy_v2.contrib" ".extended_ips.Extended_ips") @@ -211,9 +202,3 @@ class ExtendedIpsMacSampleJsonTests(ServersSampleBase): subs['hostid'] = '[a-f0-9]+' subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}' self._verify_response('servers-detail-resp', subs, response, 200) - - -class ServerGroupQuotas_LimitsSampleJsonTest(LimitsSampleJsonTest): - sample_dir = None - extension_name = ("nova.api.openstack.compute.legacy_v2.contrib." - "server_group_quotas.Server_group_quotas") diff --git a/nova/tests/functional/api_sample_tests/test_limits.py b/nova/tests/functional/api_sample_tests/test_limits.py new file mode 100644 index 000000000000..6728eb8bb503 --- /dev/null +++ b/nova/tests/functional/api_sample_tests/test_limits.py @@ -0,0 +1,53 @@ +# Copyright 2012 Nebula, Inc. +# Copyright 2013 IBM Corp. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_config import cfg + +from nova.tests.functional.api_sample_tests import api_sample_base + +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.legacy_v2.extensions') + + +class LimitsSampleJsonTest(api_sample_base.ApiSampleTestBaseV3): + ADMIN_API = True + extension_name = "limits" + + # TODO(gmann): Overriding '_api_version' till all functional tests + # are merged between v2 and v2.1. After that base class variable + # itself can be changed to 'v2' + _api_version = 'v2' + + def setUp(self): + super(LimitsSampleJsonTest, self).setUp() + # NOTE(gmann): We have to separate the template files between V2 + # and V2.1 as the response are different. + self.template = 'limit-get-resp' + if(self._test == "v2"): + self.template = 'v2-limit-get-resp' + + def _get_flags(self): + f = super(LimitsSampleJsonTest, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append("nova.api.openstack.compute." + "legacy_v2.contrib.server_group_quotas." + "Server_group_quotas") + return f + + def test_limits_get(self): + response = self._do_get('limits') + subs = self._get_regexes() + self._verify_response(self.template, subs, response, 200)