Remove old v3 volume services library and use lib/service for v3

Moving volume v3 folders to /lib/services/volumes
Remove old left overs from service/volumes.

The patch removes services/volume api code
Tempest volume api will run from /lib/service

Change-Id: I76fec9c42ecb7038f01a186f3eb51bb471b1679d
This commit is contained in:
Benny Kopilov 2016-11-06 09:07:19 +02:00
parent ae4beb7a56
commit 37b2bee80e
12 changed files with 116 additions and 35 deletions

View File

@ -0,0 +1,7 @@
features:
- |
Define the Volume v3 service clients as library interfaces,
allowing other projects to use these modules as stable
libraries without maintenance changes.
* messages_client(v3)

View File

@ -13,7 +13,7 @@
import fixtures
from tempest.services.volume.base import base_v3_client
from tempest.lib.services.volume.v3 import base_client
class APIMicroversionFixture(fixtures.Fixture):
@ -23,8 +23,8 @@ class APIMicroversionFixture(fixtures.Fixture):
def _setUp(self):
super(APIMicroversionFixture, self)._setUp()
base_v3_client.VOLUME_MICROVERSION = self.volume_microversion
base_client.VOLUME_MICROVERSION = self.volume_microversion
self.addCleanup(self._reset_volume_microversion)
def _reset_volume_microversion(self):
base_v3_client.VOLUME_MICROVERSION = None
base_client.VOLUME_MICROVERSION = None

View File

@ -25,7 +25,6 @@ from tempest.services import baremetal
from tempest.services import identity
from tempest.services import object_storage
from tempest.services import orchestration
from tempest.services import volume
CONF = config.CONF
LOG = logging.getLogger(__name__)
@ -275,8 +274,6 @@ class Manager(clients.ServiceClients):
raise lib_exc.InvalidConfiguration(msg)
def _set_volume_clients(self):
# Mandatory parameters (always defined)
params = self.parameters['volume']
self.volume_qos_client = self.volume_v1.QosSpecsClient()
self.volume_qos_v2_client = self.volume_v2.QosSpecsClient()
@ -291,8 +288,7 @@ class Manager(clients.ServiceClients):
self.snapshots_v2_client = self.volume_v2.SnapshotsClient()
self.volumes_client = self.volume_v1.VolumesClient()
self.volumes_v2_client = self.volume_v2.VolumesClient()
self.volume_v3_messages_client = volume.v3.MessagesClient(
self.auth_provider, **params)
self.volume_v3_messages_client = self.volume_v3.MessagesClient()
self.volume_types_client = self.volume_v1.TypesClient()
self.volume_types_v2_client = self.volume_v2.TypesClient()
self.volume_hosts_client = self.volume_v1.HostsClient()

View File

@ -45,7 +45,8 @@ def tempest_modules():
'image.v2': image.v2,
'network': network,
'volume.v1': volume.v1,
'volume.v2': volume.v2
'volume.v2': volume.v2,
'volume.v3': volume.v3
}
@ -54,7 +55,7 @@ def _tempest_internal_modules():
# NOTE(andreaf) This list will exists only as long the remain clients
# are migrated to tempest.lib, and it will then be deleted without
# deprecation or advance notice
return set(['identity.v3', 'object-storage', 'volume.v3'])
return set(['identity.v3', 'object-storage'])
def available_modules():

View File

@ -14,5 +14,6 @@
from tempest.lib.services.volume import v1
from tempest.lib.services.volume import v2
from tempest.lib.services.volume import v3
__all__ = ['v1', 'v2']
__all__ = ['v1', 'v2', 'v3']

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations under
# the License.
from tempest.services.volume import v3
from tempest.lib.services.volume.v3.base_client import BaseClient
from tempest.lib.services.volume.v3.messages_client import MessagesClient
__all__ = ['v3']
__all__ = ['MessagesClient', 'BaseClient']

View File

@ -19,13 +19,13 @@ from tempest.lib.common import rest_client
VOLUME_MICROVERSION = None
class BaseV3Client(rest_client.RestClient):
class BaseClient(rest_client.RestClient):
"""Base class to handle Cinder v3 client microversion support."""
api_version = 'v3'
api_microversion_header_name = 'Openstack-Api-Version'
def get_headers(self, accept_type=None, send_type=None):
headers = super(BaseV3Client, self).get_headers(
headers = super(BaseClient, self).get_headers(
accept_type=accept_type, send_type=send_type)
if VOLUME_MICROVERSION:
headers[self.api_microversion_header_name] = ('volume %s' %
@ -35,7 +35,7 @@ class BaseV3Client(rest_client.RestClient):
def request(self, method, url, extra_headers=False, headers=None,
body=None, chunked=False):
resp, resp_body = super(BaseV3Client, self).request(
resp, resp_body = super(BaseClient, self).request(
method, url, extra_headers, headers, body, chunked)
if (VOLUME_MICROVERSION and
VOLUME_MICROVERSION != api_version_utils.LATEST_MICROVERSION):

View File

@ -17,10 +17,10 @@ from oslo_serialization import jsonutils as json
from tempest.lib.common import rest_client
from tempest.lib import exceptions as lib_exc
from tempest.services.volume.base import base_v3_client
from tempest.lib.services.volume.v3 import base_client
class MessagesClient(base_v3_client.BaseV3Client):
class MessagesClient(base_client.BaseClient):
"""Client class to send user messages API requests."""
def show_message(self, message_id):

View File

@ -1,17 +0,0 @@
# Copyright (c) 2016 Hewlett-Packard Enterprise 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.services.volume.v3.json.messages_client import MessagesClient
__all__ = ['MessagesClient']

View File

@ -0,0 +1,92 @@
# Copyright 2016 Red Hat. 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.volume.v3 import messages_client
from tempest.tests.lib import fake_auth_provider
from tempest.tests.lib.services import base
class TestUserMessagesClient(base.BaseServiceTest):
USER_MESSAGE_INFO = {
"created_at": "2016-11-21T06:16:34.000000",
"guaranteed_until": "2016-12-21T06:16:34.000000",
"user_message": "No storage could be allocated for this volume "
"request. You may be able to try another size or"
" volume type.",
"resource_uuid": "c570b406-bf0b-4067-9398-f0bb09a7d9d7",
"request_id": "req-8f68681e-9b6b-4009-b94c-ac0811595451",
"message_level": "ERROR",
"id": "9a7dafbd-a156-4540-8996-50e71b5dcadf",
"resource_type": "VOLUME",
"links": [
{"href": "http://192.168.100.230:8776/v3/"
"a678cb65f701462ea2257245cd640829/messages/"
"9a7dafbd-a156-4540-8996-50e71b5dcadf",
"rel": "self"},
{"href": "http://192.168.100.230:8776/"
"a678cb65f701462ea2257245cd640829/messages/"
"9a7dafbd-a156-4540-8996-50e71b5dcadf",
"rel": "bookmark"}]
}
FAKE_SHOW_USER_MESSAGE = {
"message": dict(event_id="000002", **USER_MESSAGE_INFO)}
FAKE_LIST_USER_MESSAGES = {
"messages": [
dict(event_id="000003", **USER_MESSAGE_INFO),
dict(event_id="000004", **USER_MESSAGE_INFO)
]
}
def setUp(self):
super(TestUserMessagesClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
self.client = messages_client.MessagesClient(fake_auth,
'volume',
'regionOne')
def _test_show_user_message(self, bytes_body=False):
self.check_service_client_function(
self.client.show_message,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_SHOW_USER_MESSAGE,
bytes_body,
message_id="9a7dafbd-a156-4540-8996-50e71b5dcadf")
def _test_list_user_message(self, bytes_body=False):
self.check_service_client_function(
self.client.list_messages,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_LIST_USER_MESSAGES,
bytes_body)
def test_list_user_message_with_str_body(self):
self._test_list_user_message()
def test_list_user_message_with_bytes_body(self):
self._test_list_user_message(bytes_body=True)
def test_show_user_message_with_str_body(self):
self._test_show_user_message()
def test_show_user_message_with_bytes_body(self):
self._test_show_user_message(bytes_body=True)
def test_delete_user_message(self):
self.check_service_client_function(
self.client.delete_message,
'tempest.lib.common.rest_client.RestClient.delete',
{},
message_id="9a7dafbd-a156-4540-8996-50e71b5dcadf",
status=204)