Add test for Nova list-versions API
This commit adds a test that does a GET on the raw endpoint to ensure that the nova version GET does the right thing. Co-Authored-By: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Related-Bug: #1491579 Change-Id: I5ee09891cd1b62a87d25284be961c2027cdbd82a
This commit is contained in:
parent
5ddca1fb65
commit
2b6012b7aa
@ -89,6 +89,7 @@ class BaseComputeTest(tempest.test.BaseTestCase):
|
|||||||
cls.migrations_client = cls.os.migrations_client
|
cls.migrations_client = cls.os.migrations_client
|
||||||
cls.security_group_default_rules_client = (
|
cls.security_group_default_rules_client = (
|
||||||
cls.os.security_group_default_rules_client)
|
cls.os.security_group_default_rules_client)
|
||||||
|
cls.versions_client = cls.os.compute_versions_client
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resource_setup(cls):
|
def resource_setup(cls):
|
||||||
|
24
tempest/api/compute/test_versions.py
Normal file
24
tempest/api/compute/test_versions.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# 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 tempest.api.compute import base
|
||||||
|
from tempest import test
|
||||||
|
|
||||||
|
|
||||||
|
class TestVersions(base.BaseComputeTest):
|
||||||
|
|
||||||
|
@test.idempotent_id('6c0a0990-43b6-4529-9b61-5fd8daf7c55c')
|
||||||
|
def test_list_api_versions(self):
|
||||||
|
result = self.versions_client.list_versions()
|
||||||
|
self.assertIsNotNone(result)
|
54
tempest/api_schema/response/compute/v2_1/versions.py
Normal file
54
tempest/api_schema/response/compute/v2_1/versions.py
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# Copyright 2015 NEC 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.
|
||||||
|
|
||||||
|
list_versions = {
|
||||||
|
'status_code': [200],
|
||||||
|
'response_body': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'versions': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'id': {'type': 'string'},
|
||||||
|
'links': {
|
||||||
|
'type': 'array',
|
||||||
|
'items': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'href': {'type': 'string',
|
||||||
|
'format': 'uri'},
|
||||||
|
'rel': {'type': 'string'},
|
||||||
|
},
|
||||||
|
'required': ['href', 'rel'],
|
||||||
|
'additionalProperties': False
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'status': {'type': 'string'},
|
||||||
|
'updated': {'type': 'string', 'format': 'date-time'},
|
||||||
|
'version': {'type': 'string'},
|
||||||
|
'min_version': {'type': 'string'}
|
||||||
|
},
|
||||||
|
# NOTE: version and min_version have been added since Kilo,
|
||||||
|
# so they should not be required.
|
||||||
|
'required': ['id', 'links', 'status', 'updated'],
|
||||||
|
'additionalProperties': False
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['versions'],
|
||||||
|
'additionalProperties': False
|
||||||
|
}
|
||||||
|
}
|
@ -77,6 +77,7 @@ from tempest.services.compute.json.tenant_networks_client import \
|
|||||||
TenantNetworksClient
|
TenantNetworksClient
|
||||||
from tempest.services.compute.json.tenant_usages_client import \
|
from tempest.services.compute.json.tenant_usages_client import \
|
||||||
TenantUsagesClient
|
TenantUsagesClient
|
||||||
|
from tempest.services.compute.json.versions_client import VersionsClient
|
||||||
from tempest.services.compute.json.volumes_extensions_client import \
|
from tempest.services.compute.json.volumes_extensions_client import \
|
||||||
VolumesExtensionsClient
|
VolumesExtensionsClient
|
||||||
from tempest.services.data_processing.v1_1.data_processing_client import \
|
from tempest.services.data_processing.v1_1.data_processing_client import \
|
||||||
@ -322,6 +323,8 @@ class Manager(manager.Manager):
|
|||||||
})
|
})
|
||||||
self.volumes_extensions_client = VolumesExtensionsClient(
|
self.volumes_extensions_client = VolumesExtensionsClient(
|
||||||
self.auth_provider, **params_volume)
|
self.auth_provider, **params_volume)
|
||||||
|
self.compute_versions_client = VersionsClient(self.auth_provider,
|
||||||
|
**params_volume)
|
||||||
|
|
||||||
def _set_database_clients(self):
|
def _set_database_clients(self):
|
||||||
self.database_flavors_client = DatabaseFlavorsClient(
|
self.database_flavors_client = DatabaseFlavorsClient(
|
||||||
|
37
tempest/services/compute/json/versions_client.py
Normal file
37
tempest/services/compute/json/versions_client.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# 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_serialization import jsonutils as json
|
||||||
|
from six.moves import urllib
|
||||||
|
|
||||||
|
from tempest.api_schema.response.compute.v2_1 import versions as schema
|
||||||
|
from tempest.common import service_client
|
||||||
|
|
||||||
|
|
||||||
|
class VersionsClient(service_client.ServiceClient):
|
||||||
|
|
||||||
|
def list_versions(self):
|
||||||
|
# NOTE: The URL which is gotten from keystone's catalog contains
|
||||||
|
# API version and project-id like "v2/{project-id}", but we need
|
||||||
|
# to access the URL which doesn't contain them for getting API
|
||||||
|
# versions. For that, here should use raw_request() instead of
|
||||||
|
# get().
|
||||||
|
endpoint = self.base_url
|
||||||
|
url = urllib.parse.urlparse(endpoint)
|
||||||
|
version_url = '%s://%s/' % (url.scheme, url.netloc)
|
||||||
|
|
||||||
|
resp, body = self.raw_request(version_url, 'GET')
|
||||||
|
body = json.loads(body)
|
||||||
|
self.validate_response(schema.list_versions, resp, body)
|
||||||
|
return service_client.ResponseBody(resp, body)
|
Loading…
Reference in New Issue
Block a user