Merge "Modify limits fields according to microversion"
This commit is contained in:
commit
365f701964
@ -338,10 +338,18 @@ Microversion tests implemented in Tempest
|
||||
|
||||
.. _2.32: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id29
|
||||
|
||||
* `2.36`_
|
||||
|
||||
.. _2.36: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#microversion
|
||||
|
||||
* `2.37`_
|
||||
|
||||
.. _2.37: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id34
|
||||
|
||||
* `2.39`_
|
||||
|
||||
.. _2.39: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id35
|
||||
|
||||
* `2.42`_
|
||||
|
||||
.. _2.42: https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#maximum-in-ocata
|
||||
|
@ -18,6 +18,7 @@ from tempest.lib import decorators
|
||||
|
||||
|
||||
class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
|
||||
max_microversion = '2.56'
|
||||
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
@ -26,22 +27,14 @@ class AbsoluteLimitsTestJSON(base.BaseV2ComputeTest):
|
||||
|
||||
@decorators.idempotent_id('b54c66af-6ab6-4cf0-a9e5-a0cb58d75e0b')
|
||||
def test_absLimits_get(self):
|
||||
# To check if all limits are present in the response
|
||||
limits = self.client.show_limits()['limits']
|
||||
absolute_limits = limits['absolute']
|
||||
expected_elements = ['maxImageMeta', 'maxPersonality',
|
||||
'maxPersonalitySize',
|
||||
'maxServerMeta', 'maxTotalCores',
|
||||
'maxTotalFloatingIps', 'maxSecurityGroups',
|
||||
'maxSecurityGroupRules', 'maxTotalInstances',
|
||||
'maxTotalKeypairs', 'maxTotalRAMSize',
|
||||
'maxServerGroups', 'maxServerGroupMembers',
|
||||
'totalCoresUsed', 'totalFloatingIpsUsed',
|
||||
'totalSecurityGroupsUsed', 'totalInstancesUsed',
|
||||
'totalRAMUsed', 'totalServerGroupsUsed']
|
||||
# check whether all expected elements exist
|
||||
missing_elements =\
|
||||
[ele for ele in expected_elements if ele not in absolute_limits]
|
||||
self.assertEmpty(missing_elements,
|
||||
"Failed to find element %s in absolute limits list"
|
||||
% ', '.join(ele for ele in missing_elements))
|
||||
# To check if all limits are present in the response (will be checked
|
||||
# by schema)
|
||||
self.client.show_limits()
|
||||
|
||||
|
||||
class AbsoluteLimitsV257TestJSON(base.BaseV2ComputeTest):
|
||||
min_microversion = '2.57'
|
||||
max_microversion = 'latest'
|
||||
|
||||
# NOTE(felipemonteiro): This class tests the Absolute Limits APIs
|
||||
# response schema for the 2.57 microversion.
|
||||
|
@ -33,15 +33,15 @@ class AbsoluteLimitsNegativeTestJSON(base.BaseV2ComputeTest):
|
||||
|
||||
@decorators.attr(type=['negative'])
|
||||
@decorators.idempotent_id('215cd465-d8ae-49c9-bf33-9c911913a5c8')
|
||||
def test_max_image_meta_exceed_limit(self):
|
||||
# We should not create vm with image meta over maxImageMeta limit
|
||||
def test_max_metadata_exceed_limit(self):
|
||||
# We should not create vm with metadata over maxServerMeta limit
|
||||
# Get max limit value
|
||||
limits = self.client.show_limits()['limits']
|
||||
max_meta = limits['absolute']['maxImageMeta']
|
||||
max_meta = limits['absolute']['maxServerMeta']
|
||||
|
||||
# No point in running this test if there is no limit.
|
||||
if max_meta == -1:
|
||||
raise self.skipException('no limit for maxImageMeta')
|
||||
raise self.skipException('no limit for maxServerMeta')
|
||||
|
||||
# Create server should fail, since we are passing > metadata Limit!
|
||||
max_meta_data = max_meta + 1
|
||||
|
35
tempest/lib/api_schema/response/compute/v2_36/limits.py
Normal file
35
tempest/lib/api_schema/response/compute/v2_36/limits.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright 2018 ZTE Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import copy
|
||||
|
||||
from tempest.lib.api_schema.response.compute.v2_1 import limits as limitv21
|
||||
|
||||
# Compute microversion 2.36:
|
||||
# remove attributes in get_limit:
|
||||
# 'maxSecurityGroupRules',
|
||||
# 'maxSecurityGroups',
|
||||
# 'maxTotalFloatingIps',
|
||||
# 'totalFloatingIpsUsed',
|
||||
# 'totalSecurityGroupsUsed'
|
||||
|
||||
get_limit = copy.deepcopy(limitv21.get_limit)
|
||||
|
||||
for item in ['maxSecurityGroupRules', 'maxSecurityGroups',
|
||||
'maxTotalFloatingIps', 'totalFloatingIpsUsed',
|
||||
'totalSecurityGroupsUsed']:
|
||||
get_limit['response_body']['properties']['limits']['properties'][
|
||||
'absolute']['properties'].pop(item)
|
||||
get_limit['response_body']['properties']['limits']['properties'][
|
||||
'absolute']['required'].remove(item)
|
29
tempest/lib/api_schema/response/compute/v2_39/limits.py
Normal file
29
tempest/lib/api_schema/response/compute/v2_39/limits.py
Normal file
@ -0,0 +1,29 @@
|
||||
# Copyright 2018 ZTE Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import copy
|
||||
|
||||
from tempest.lib.api_schema.response.compute.v2_36 import limits as limitv236
|
||||
|
||||
# Compute microversion 2.39:
|
||||
# remove attributes in get_limit:
|
||||
# 'maxImageMeta'
|
||||
|
||||
get_limit = copy.deepcopy(limitv236.get_limit)
|
||||
|
||||
get_limit['response_body']['properties']['limits']['properties']['absolute'][
|
||||
'properties'].pop('maxImageMeta')
|
||||
|
||||
get_limit['response_body']['properties']['limits']['properties']['absolute'][
|
||||
'required'].remove('maxImageMeta')
|
30
tempest/lib/api_schema/response/compute/v2_57/limits.py
Normal file
30
tempest/lib/api_schema/response/compute/v2_57/limits.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Copyright 2018 ZTE Corporation. All rights reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import copy
|
||||
|
||||
from tempest.lib.api_schema.response.compute.v2_39 import limits as limitv239
|
||||
|
||||
# Compute microversion 2.57:
|
||||
# remove attributes in get_limit:
|
||||
# 'maxPersonality',
|
||||
# 'maxPersonalitySize'
|
||||
|
||||
get_limit = copy.deepcopy(limitv239.get_limit)
|
||||
|
||||
for item in ['maxPersonality', 'maxPersonalitySize']:
|
||||
get_limit['response_body']['properties']['limits']['properties'][
|
||||
'absolute']['properties'].pop(item)
|
||||
get_limit['response_body']['properties']['limits']['properties'][
|
||||
'absolute']['required'].remove(item)
|
@ -15,15 +15,25 @@
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.api_schema.response.compute.v2_1 import limits as schema
|
||||
from tempest.lib.api_schema.response.compute.v2_1 import limits as schemav21
|
||||
from tempest.lib.api_schema.response.compute.v2_36 import limits as schemav236
|
||||
from tempest.lib.api_schema.response.compute.v2_39 import limits as schemav239
|
||||
from tempest.lib.api_schema.response.compute.v2_57 import limits as schemav257
|
||||
from tempest.lib.common import rest_client
|
||||
from tempest.lib.services.compute import base_compute_client
|
||||
|
||||
|
||||
class LimitsClient(base_compute_client.BaseComputeClient):
|
||||
|
||||
schema_versions_info = [
|
||||
{'min': None, 'max': '2.35', 'schema': schemav21},
|
||||
{'min': '2.36', 'max': '2.38', 'schema': schemav236},
|
||||
{'min': '2.39', 'max': '2.56', 'schema': schemav239},
|
||||
{'min': '2.57', 'max': None, 'schema': schemav257}]
|
||||
|
||||
def show_limits(self):
|
||||
resp, body = self.get("limits")
|
||||
body = json.loads(body)
|
||||
schema = self.get_schema(self.schema_versions_info)
|
||||
self.validate_response(schema.get_limit, resp, body)
|
||||
return rest_client.ResponseBody(resp, body)
|
||||
|
Loading…
Reference in New Issue
Block a user