Merge used-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 used_limits functional tests.

V2 implied RateLimitingMiddleware while V2.1 dropped that from
https://review.openstack.org/#/c/115893/, 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: I3192f550b57694ccb700eebcc0af55468a2f222f
This commit is contained in:
parklong
2015-08-20 09:50:38 +09:00
committed by ghanshyam
parent 388ef726a0
commit 71f41e633f
8 changed files with 33 additions and 396 deletions

View File

@@ -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"
}
]
}
}

View File

@@ -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"
}
]
}
}

View File

@@ -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"
}
]
}
}

View File

@@ -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"
}
]
}
}

View File

@@ -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")

View File

@@ -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)