From 73eda1cb7ddc574f24e19eac5c1618593a4fbfef Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 4 May 2016 10:14:15 +0800 Subject: [PATCH] Remove the legacy v2 API test scenarios from API sample tests This patches from the test scenarios for the legacy v2 from API sample tests. There still have some codes for legacy v2 which should be cleanup, but that can be done later patches. This patch just stop the test on the legacy v2 API. Partially implements blueprint remove-legacy-v2-api-code Change-Id: I38626e5a4aa98cbfd7b65b5eb0edbcae96e5b3f2 --- .../extensions-get-resp-v2.json | 10 -- doc/api_samples/limits/v2-limit-get-resp.json | 87 ----------------- .../v2-usedlimits-get-resp.json | 93 ------------------- .../api_sample_tests/api_sample_base.py | 17 +--- .../extensions-get-resp-v2.json.tpl | 10 -- .../limits/v2-limit-get-resp.json.tpl | 87 ----------------- .../v2-usedlimits-get-resp.json.tpl | 93 ------------------- .../api_sample_tests/test_extension_info.py | 18 +--- .../api_sample_tests/test_limits.py | 2 - .../api_sample_tests/test_used_limits.py | 19 ---- 10 files changed, 4 insertions(+), 432 deletions(-) delete mode 100644 doc/api_samples/extension-info/extensions-get-resp-v2.json delete mode 100644 doc/api_samples/limits/v2-limit-get-resp.json delete mode 100644 doc/api_samples/os-used-limits/v2-usedlimits-get-resp.json delete mode 100644 nova/tests/functional/api_sample_tests/api_samples/extension-info/extensions-get-resp-v2.json.tpl delete mode 100644 nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl delete mode 100644 nova/tests/functional/api_sample_tests/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl diff --git a/doc/api_samples/extension-info/extensions-get-resp-v2.json b/doc/api_samples/extension-info/extensions-get-resp-v2.json deleted file mode 100644 index 538ca8c3cb..0000000000 --- a/doc/api_samples/extension-info/extensions-get-resp-v2.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extension": { - "alias": "os-agents", - "description": "Agents support.", - "links": [], - "name": "Agents", - "namespace": "http://docs.openstack.org/compute/ext/agents/api/v2", - "updated": "2012-10-28T00:00:00Z" - } -} \ No newline at end of file diff --git a/doc/api_samples/limits/v2-limit-get-resp.json b/doc/api_samples/limits/v2-limit-get-resp.json deleted file mode 100644 index 6ccac46acd..0000000000 --- a/doc/api_samples/limits/v2-limit-get-resp.json +++ /dev/null @@ -1,87 +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, - "maxServerGroups": 10, - "maxServerGroupMembers": 10 - }, - "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/os-used-limits/v2-usedlimits-get-resp.json b/doc/api_samples/os-used-limits/v2-usedlimits-get-resp.json deleted file mode 100644 index 5b3ee33e8a..0000000000 --- a/doc/api_samples/os-used-limits/v2-usedlimits-get-resp.json +++ /dev/null @@ -1,93 +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, - "maxServerGroups": 10, - "maxServerGroupMembers": 10, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 0, - "totalServerGroupsUsed": 0 - }, - "rate": [ - { - "limit": [ - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - }, - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "PUT" - }, - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "DELETE" - } - ], - "regex": ".*", - "uri": "*" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "POST" - } - ], - "regex": "^/servers", - "uri": "*/servers" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 120, - "unit": "MINUTE", - "value": 120, - "verb": "GET" - } - ], - "regex": ".*changes-since.*", - "uri": "*changes-since*" - }, - { - "limit": [ - { - "next-available": "2012-11-27T17:24:52Z", - "remaining": 12, - "unit": "MINUTE", - "value": 12, - "verb": "GET" - } - ], - "regex": "^/os-fping", - "uri": "*/os-fping" - } - ] - } -} diff --git a/nova/tests/functional/api_sample_tests/api_sample_base.py b/nova/tests/functional/api_sample_tests/api_sample_base.py index 89149344a1..f596e26c03 100644 --- a/nova/tests/functional/api_sample_tests/api_sample_base.py +++ b/nova/tests/functional/api_sample_tests/api_sample_base.py @@ -37,15 +37,12 @@ CONF.import_opt('osapi_compute_extension', # the scenario (should be unique), and the second item is a dictionary # of attributes to change in the class for the test. # -# By default we're running scenarios for 3 situations +# By default we're running scenarios for 2 situations # -# - Hitting the default /v2 endpoint +# - Hitting the default /v2 endpoint with the v2.1 Compatibility stack # # - Hitting the default /v2.1 endpoint # -# - Hitting the /v2 but fixing the paste pipeline so that it uses the -# legacy v2 code. This requires a fixture. -# # Things we need to set: # # - api_major_version - what version of the API we should be hitting @@ -54,9 +51,6 @@ CONF.import_opt('osapi_compute_extension', # # - _additional_fixtures - any additional fixtures need # -# - _legacy_v2_code - True/False if we are using the legacy v2 code -# stack. Sadly, a few tests really care about this. -# # NOTE(sdague): if you want to build a test that only tests specific # microversions, then replace the ``scenarios`` class variable in that # test class with something like: @@ -71,7 +65,6 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios, _additional_fixtures = [] sample_dir = None extra_extensions_to_load = None - _legacy_v2_code = False _project_id = True scenarios = [ @@ -81,12 +74,6 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios, # test v2.1 base microversion ('v2_1', { 'api_major_version': 'v2.1'}), - # test v2 with the v2 legacy code - ('v2legacy', { - 'api_major_version': 'v2', - '_legacy_v2_code': True, - '_additional_fixtures': [ - api_paste_fixture.ApiPasteLegacyV2Fixture]}), # test v2.18 code without project id ('v2_1_noproject_id', { 'api_major_version': 'v2.1', diff --git a/nova/tests/functional/api_sample_tests/api_samples/extension-info/extensions-get-resp-v2.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/extension-info/extensions-get-resp-v2.json.tpl deleted file mode 100644 index 9b6b764988..0000000000 --- a/nova/tests/functional/api_sample_tests/api_samples/extension-info/extensions-get-resp-v2.json.tpl +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extension": { - "alias": "os-agents", - "description": "%(text)s", - "links": [], - "name": "Agents", - "namespace": "http://docs.openstack.org/compute/ext/agents/api/v2", - "updated": "%(isotime)s" - } -} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl deleted file mode 100644 index 939bbd7cd8..0000000000 --- a/nova/tests/functional/api_sample_tests/api_samples/limits/v2-limit-get-resp.json.tpl +++ /dev/null @@ -1,87 +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, - "maxServerGroups": 10, - "maxServerGroupMembers": 10 - }, - "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/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl deleted file mode 100644 index 3bd6b42432..0000000000 --- a/nova/tests/functional/api_sample_tests/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl +++ /dev/null @@ -1,93 +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, - "maxServerGroups": 10, - "maxServerGroupMembers": 10, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 0, - "totalServerGroupsUsed": 0 - }, - "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/test_extension_info.py b/nova/tests/functional/api_sample_tests/test_extension_info.py index 895bcd8700..ce7983e7f3 100644 --- a/nova/tests/functional/api_sample_tests/test_extension_info.py +++ b/nova/tests/functional/api_sample_tests/test_extension_info.py @@ -14,15 +14,10 @@ # under the License. import mock -from oslo_config import cfg from nova.api.openstack import extensions as api_extensions 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') - def fake_soft_extension_authorizer(extension_name, core=False): def authorize(context, action=None): @@ -42,10 +37,7 @@ class ExtensionInfoAllSamplesJsonTest(api_sample_base.ApiSampleTestBaseV21): # stack. We default to the v2.1 case. template = 'extensions-list-resp' if self.api_major_version == 'v2': - if self._legacy_v2_code: - template = 'extensions-list-resp-v2' - else: - template = 'extensions-list-resp-v21-compatible' + template = 'extensions-list-resp-v21-compatible' self._verify_response(template, {}, response, 200) @@ -58,10 +50,4 @@ class ExtensionInfoSamplesJsonTest(api_sample_base.ApiSampleTestBaseV21): def test_get_extensions(self, soft_auth): soft_auth.side_effect = fake_soft_extension_authorizer response = self._do_get('extensions/os-agents') - # The extension details info are different between legacy v2 and v2.1 - # stack. namespace link and updated date are different. So keep both - # version for testing and default to v2.1 - template = 'extensions-get-resp' - if self._legacy_v2_code: - template = 'extensions-get-resp-v2' - self._verify_response(template, {}, response, 200) + self._verify_response('extensions-get-resp', {}, response, 200) diff --git a/nova/tests/functional/api_sample_tests/test_limits.py b/nova/tests/functional/api_sample_tests/test_limits.py index a2932b2c01..224393916f 100644 --- a/nova/tests/functional/api_sample_tests/test_limits.py +++ b/nova/tests/functional/api_sample_tests/test_limits.py @@ -31,8 +31,6 @@ class LimitsSampleJsonTest(api_sample_base.ApiSampleTestBaseV21): # 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._legacy_v2_code: - self.template = 'v2-limit-get-resp' def _get_flags(self): f = super(LimitsSampleJsonTest, self)._get_flags() diff --git a/nova/tests/functional/api_sample_tests/test_used_limits.py b/nova/tests/functional/api_sample_tests/test_used_limits.py index 117a39d3e4..3e50ecf512 100644 --- a/nova/tests/functional/api_sample_tests/test_used_limits.py +++ b/nova/tests/functional/api_sample_tests/test_used_limits.py @@ -32,25 +32,6 @@ class UsedLimitsSamplesJsonTest(api_sample_base.ApiSampleTestBaseV21): # NOTE(park): We have to separate the template files between V2 # and V2.1 as the response are different. self.template = 'usedlimits-get-resp' - if self._legacy_v2_code: - self.template = 'v2-usedlimits-get-resp' - - def _get_flags(self): - f = super(UsedLimitsSamplesJsonTest, self)._get_flags() - if self._legacy_v2_code: - 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") - f['osapi_compute_extension'].append( - "nova.api.openstack.compute." - "legacy_v2.contrib.used_limits.Used_limits") - f['osapi_compute_extension'].append( - "nova.api.openstack.compute." - "legacy_v2.contrib.used_limits_for_admin." - "Used_limits_for_admin") - return f def test_get_used_limits(self): # Get api sample to used limits.