Add "list Glance API versions" test
Many projects provides multiple API versions and the version information is very important for users, because users can know what features are available on clouds. However, Tempest didn't test the Clance API versions in long-term. So this patch adds the corresponding test. Change-Id: Ib85819fb71f0b12b64351b307d83a3beb77d7fad
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add versions_client module for image service.
|
||||
This new module provides list_versions() method which shows API versions
|
||||
from Image service.
|
@@ -145,6 +145,7 @@ class BaseV2ImageTest(BaseImageTest):
|
||||
cls.namespace_objects_client = cls.os.namespace_objects_client
|
||||
cls.namespace_tags_client = cls.os.namespace_tags_client
|
||||
cls.schemas_client = cls.os.schemas_client
|
||||
cls.versions_client = cls.os.image_versions_client
|
||||
|
||||
def create_namespace(cls, namespace_name=None, visibility='public',
|
||||
description='Tempest', protected=False,
|
||||
|
30
tempest/api/image/v2/test_versions.py
Normal file
30
tempest/api/image/v2/test_versions.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from tempest.api.image import base
|
||||
from tempest.lib import decorators
|
||||
from tempest import test
|
||||
|
||||
|
||||
class VersionsTest(base.BaseV2ImageTest):
|
||||
|
||||
@decorators.idempotent_id('659ea30a-a17c-4317-832c-0f68ed23c31d')
|
||||
@test.attr(type='smoke')
|
||||
def test_list_versions(self):
|
||||
versions = self.versions_client.list_versions()['versions']
|
||||
expected_resources = ('id', 'links', 'status')
|
||||
|
||||
for version in versions:
|
||||
for res in expected_resources:
|
||||
self.assertIn(res, version)
|
@@ -125,6 +125,8 @@ class Manager(clients.ServiceClients):
|
||||
self.image_v2.NamespacePropertiesClient()
|
||||
self.namespace_tags_client = \
|
||||
self.image_v2.NamespaceTagsClient()
|
||||
self.image_versions_client = \
|
||||
self.image_v2.VersionsClient()
|
||||
|
||||
def _set_compute_clients(self):
|
||||
self.agents_client = self.compute.AgentsClient()
|
||||
|
@@ -25,7 +25,9 @@ from tempest.lib.services.image.v2.namespaces_client import NamespacesClient
|
||||
from tempest.lib.services.image.v2.resource_types_client import \
|
||||
ResourceTypesClient
|
||||
from tempest.lib.services.image.v2.schemas_client import SchemasClient
|
||||
from tempest.lib.services.image.v2.versions_client import VersionsClient
|
||||
|
||||
__all__ = ['ImageMembersClient', 'ImagesClient', 'NamespaceObjectsClient',
|
||||
'NamespacePropertiesClient', 'NamespaceTagsClient',
|
||||
'NamespacesClient', 'ResourceTypesClient', 'SchemasClient']
|
||||
'NamespacesClient', 'ResourceTypesClient', 'SchemasClient',
|
||||
'VersionsClient']
|
||||
|
38
tempest/lib/services/image/v2/versions_client.py
Normal file
38
tempest/lib/services/image/v2/versions_client.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
import time
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
from tempest.lib.common import rest_client
|
||||
|
||||
|
||||
class VersionsClient(rest_client.RestClient):
|
||||
api_version = "v2"
|
||||
|
||||
def list_versions(self):
|
||||
"""List API versions"""
|
||||
version_url = self._get_base_version_url()
|
||||
|
||||
start = time.time()
|
||||
resp, body = self.raw_request(version_url, 'GET')
|
||||
end = time.time()
|
||||
self._log_request('GET', version_url, resp, secs=(end - start),
|
||||
resp_body=body)
|
||||
self._error_checker(resp, body)
|
||||
|
||||
self.expected_success(300, resp.status)
|
||||
body = json.loads(body)
|
||||
return rest_client.ResponseBody(resp, body)
|
94
tempest/tests/lib/services/image/v2/test_versions_client.py
Normal file
94
tempest/tests/lib/services/image/v2/test_versions_client.py
Normal file
@@ -0,0 +1,94 @@
|
||||
# Copyright 2017 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.
|
||||
|
||||
from tempest.lib.services.image.v2 import versions_client
|
||||
from tempest.tests.lib import fake_auth_provider
|
||||
from tempest.tests.lib.services import base
|
||||
|
||||
|
||||
class TestVersionsClient(base.BaseServiceTest):
|
||||
|
||||
FAKE_VERSIONS_INFO = {
|
||||
"versions": [
|
||||
{
|
||||
"status": "CURRENT", "id": "v2.5",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "SUPPORTED", "id": "v2.4",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "SUPPORTED", "id": "v2.3",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "SUPPORTED", "id": "v2.2",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "SUPPORTED", "id": "v2.1",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "SUPPORTED", "id": "v2.0",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v2/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "DEPRECATED", "id": "v1.1",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v1/", "rel": "self"}
|
||||
]
|
||||
},
|
||||
{
|
||||
"status": "DEPRECATED", "id": "v1.0",
|
||||
"links": [
|
||||
{"href": "https://10.220.1.21:9292/v1/", "rel": "self"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
def setUp(self):
|
||||
super(TestVersionsClient, self).setUp()
|
||||
fake_auth = fake_auth_provider.FakeAuthProvider()
|
||||
self.client = versions_client.VersionsClient(fake_auth,
|
||||
'image',
|
||||
'regionOne')
|
||||
|
||||
def _test_list_versions(self, bytes_body=False):
|
||||
self.check_service_client_function(
|
||||
self.client.list_versions,
|
||||
'tempest.lib.common.rest_client.RestClient.raw_request',
|
||||
self.FAKE_VERSIONS_INFO,
|
||||
bytes_body,
|
||||
300)
|
||||
|
||||
def test_list_versions_with_str_body(self):
|
||||
self._test_list_versions()
|
||||
|
||||
def test_list_versions_with_bytes_body(self):
|
||||
self._test_list_versions(bytes_body=True)
|
Reference in New Issue
Block a user