diff --git a/doc/api_samples/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json b/doc/api_samples/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json deleted file mode 100644 index 3522140ee8..0000000000 --- a/doc/api_samples/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json +++ /dev/null @@ -1,90 +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, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 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/doc/api_samples/legacy_v2/os-used-limits/usedlimits-get-resp.json b/doc/api_samples/legacy_v2/os-used-limits/usedlimits-get-resp.json deleted file mode 100644 index 3522140ee8..0000000000 --- a/doc/api_samples/legacy_v2/os-used-limits/usedlimits-get-resp.json +++ /dev/null @@ -1,90 +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, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 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/doc/api_samples/legacy_v2/os-server-group-quotas/usedlimits-get-resp.json b/doc/api_samples/os-used-limits/v2-usedlimits-get-resp.json similarity index 100% rename from doc/api_samples/legacy_v2/os-server-group-quotas/usedlimits-get-resp.json rename to doc/api_samples/os-used-limits/v2-usedlimits-get-resp.json diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/os-server-group-quotas/usedlimits-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl similarity index 100% rename from nova/tests/functional/api_sample_tests/legacy_v2/os-server-group-quotas/usedlimits-get-resp.json.tpl rename to nova/tests/functional/api_sample_tests/api_samples/os-used-limits/v2-usedlimits-get-resp.json.tpl diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json.tpl deleted file mode 100644 index dcf861c4ef..0000000000 --- a/nova/tests/functional/api_sample_tests/legacy_v2/os-used-limits-for-admin/usedlimitsforadmin-get-resp.json.tpl +++ /dev/null @@ -1,90 +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, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 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/legacy_v2/os-used-limits/usedlimits-get-resp.json.tpl b/nova/tests/functional/api_sample_tests/legacy_v2/os-used-limits/usedlimits-get-resp.json.tpl deleted file mode 100644 index dcf861c4ef..0000000000 --- a/nova/tests/functional/api_sample_tests/legacy_v2/os-used-limits/usedlimits-get-resp.json.tpl +++ /dev/null @@ -1,90 +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, - "totalCoresUsed": 0, - "totalInstancesUsed": 0, - "totalRAMUsed": 0, - "totalSecurityGroupsUsed": 0, - "totalFloatingIpsUsed": 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/legacy_v2/test_api_samples.py b/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py index 4c71481374..e0b7707ade 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 @@ -165,33 +165,6 @@ class LimitsSampleJsonTest(ApiSampleTestBaseV2): self._verify_response('limit-get-resp', subs, response, 200) -class UsedLimitsSamplesJsonTest(ApiSampleTestBaseV2): - extension_name = ("nova.api.openstack.compute.legacy_v2.contrib." - "used_limits.Used_limits") - - def test_get_used_limits(self): - # Get api sample to used limits. - response = self._do_get('limits') - subs = self._get_regexes() - self._verify_response('usedlimits-get-resp', subs, response, 200) - - -class UsedLimitsForAdminSamplesJsonTest(ApiSampleTestBaseV2): - ADMIN_API = True - extends_name = ("nova.api.openstack.compute.legacy_v2.contrib.used_limits." - "Used_limits") - extension_name = ( - "nova.api.openstack.compute.legacy_v2.contrib.used_limits_for_admin." - "Used_limits_for_admin") - - def test_get_used_limits_for_admin(self): - tenant_id = 'openstack' - response = self._do_get('limits?tenant_id=%s' % tenant_id) - subs = self._get_regexes() - return self._verify_response('usedlimitsforadmin-get-resp', subs, - response, 200) - - class ExtendedIpsSampleJsonTests(ServersSampleBase): extension_name = ("nova.api.openstack.compute.legacy_v2.contrib" ".extended_ips.Extended_ips") @@ -244,10 +217,3 @@ class ServerGroupQuotas_LimitsSampleJsonTest(LimitsSampleJsonTest): sample_dir = None extension_name = ("nova.api.openstack.compute.legacy_v2.contrib." "server_group_quotas.Server_group_quotas") - - -class ServerGroupQuotas_UsedLimitsSamplesJsonTest(UsedLimitsSamplesJsonTest): - extension_name = ("nova.api.openstack.compute.legacy_v2.contrib." - "server_group_quotas.Server_group_quotas") - extends_name = ("nova.api.openstack.compute.legacy_v2.contrib.used_limits." - "Used_limits") 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 838bf8d745..2177d7de16 100644 --- a/nova/tests/functional/api_sample_tests/test_used_limits.py +++ b/nova/tests/functional/api_sample_tests/test_used_limits.py @@ -13,20 +13,51 @@ # 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 UsedLimitsSamplesJsonTest(api_sample_base.ApiSampleTestBaseV3): ADMIN_API = True extension_name = "os-used-limits" extra_extensions_to_load = ["limits"] + # TODO(park): 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(UsedLimitsSamplesJsonTest, self).setUp() + # 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._test == "v2"): + self.template = 'v2-usedlimits-get-resp' + + def _get_flags(self): + f = super(UsedLimitsSamplesJsonTest, 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") + 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. response = self._do_get('limits') subs = self._get_regexes() - self._verify_response('usedlimits-get-resp', subs, response, 200) + self._verify_response(self.template, subs, response, 200) def test_get_used_limits_for_admin(self): # TODO(sdague): if we split the admin tests out the whole @@ -34,4 +65,4 @@ class UsedLimitsSamplesJsonTest(api_sample_base.ApiSampleTestBaseV3): tenant_id = 'openstack' response = self._do_get('limits?tenant_id=%s' % tenant_id) subs = self._get_regexes() - self._verify_response('usedlimits-get-resp', subs, response, 200) + self._verify_response(self.template, subs, response, 200)