Use base plugin interface to load additional client
... so that we can leverage the base feature to implement common options for endpoint detection. Change-Id: Iceb8bece1e54fe40074f51f97bc02d5121337cb9 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
1 parent
4dbe63018c
commit
9491d7906c
5 files changed
+46
-50
No files matched your search
@@ -27,6 +27,16 @@ MessagingGroup = [
|
||||
cfg.StrOpt('catalog_type',
|
||||
default='messaging',
|
||||
help='Catalog type of the Messaging service.'),
|
||||
cfg.StrOpt('endpoint_type',
|
||||
default='public',
|
||||
choices=['public', 'admin', 'internal'],
|
||||
help="The endpoint type to use for the messaging service."),
|
||||
cfg.StrOpt("region",
|
||||
default="",
|
||||
help="The messaging region name to use. If empty, the value "
|
||||
"of identity.region is used instead. If no such region "
|
||||
"is found in the service catalog, the first found one is "
|
||||
"used."),
|
||||
cfg.IntOpt('max_queues_per_page',
|
||||
default=20,
|
||||
help='The maximum number of queue records per page when '
|
||||
|
||||
@@ -71,3 +71,14 @@ class ZaqarTempestPlugin(plugins.TempestPlugin):
|
||||
zaqar_config.MessagingGroup),
|
||||
(config.service_available_group.name,
|
||||
[zaqar_config.service_option])]
|
||||
|
||||
def get_service_clients(self):
|
||||
messaging_config = config.service_client_config('messaging')
|
||||
messaging_params = {
|
||||
'name': 'messaging',
|
||||
'service_version': 'messaging.v2',
|
||||
'module_path': 'zaqar_tempest_plugin.services.messaging',
|
||||
'client_names': ['V2MessagingClient'],
|
||||
}
|
||||
messaging_params.update(messaging_config)
|
||||
return [messaging_params]
|
||||
@@ -0,0 +1,19 @@
|
||||
# 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 zaqar_tempest_plugin.services.messaging.json.messaging_client \
|
||||
import V2MessagingClient
|
||||
|
||||
__all__ = [
|
||||
'V2MessagingClient'
|
||||
]
|
||||
@@ -27,22 +27,15 @@ from zaqar_tempest_plugin.api_schema.response.v2 \
|
||||
|
||||
class MessagingClient(rest_client.RestClient, metaclass=abc.ABCMeta):
|
||||
|
||||
def __init__(self, auth_provider, service, region, **kwargs):
|
||||
super(MessagingClient, self).__init__(
|
||||
auth_provider, service, region, **kwargs)
|
||||
|
||||
self.uri_prefix = 'v{0}'.format(self.version)
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MessagingClient, self).__init__(*args, **kwargs)
|
||||
|
||||
client_id = uuidutils.generate_uuid(dashed=False)
|
||||
self.headers = {'Client-ID': client_id}
|
||||
|
||||
|
||||
class V2MessagingClient(MessagingClient):
|
||||
version = '2'
|
||||
|
||||
def __init__(self, auth_provider, service, region, **kwargs):
|
||||
super(V2MessagingClient, self).__init__(
|
||||
auth_provider, service, region, **kwargs)
|
||||
uri_prefix = 'v2'
|
||||
|
||||
def list_queues(self, url_params=False):
|
||||
uri = '{0}/queues'.format(self.uri_prefix)
|
||||
|
||||
@@ -17,8 +17,6 @@ from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest import test
|
||||
|
||||
from zaqar_tempest_plugin.services.messaging.json import messaging_client
|
||||
|
||||
CONF = config.CONF
|
||||
|
||||
|
||||
@@ -146,56 +144,21 @@ class BaseMessagingTest(test.BaseTestCase):
|
||||
return rbody
|
||||
|
||||
|
||||
class BaseV11MessagingTest(BaseMessagingTest):
|
||||
"""Base class for the Messaging (Zaqar) v1.1 tests."""
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(BaseV11MessagingTest, cls).setup_clients()
|
||||
cls.client = messaging_client.V11MessagingClient(
|
||||
cls.os_primary.auth_provider,
|
||||
CONF.messaging.catalog_type,
|
||||
CONF.identity.region,
|
||||
build_interval=CONF.compute.build_interval,
|
||||
build_timeout=CONF.compute.build_timeout)
|
||||
|
||||
@classmethod
|
||||
def generate_message_body(cls, repeat=1):
|
||||
"""Wrapper utility that sets the metadata of a queue."""
|
||||
message_ttl = data_utils.\
|
||||
rand_int_id(start=60, end=CONF.messaging.max_message_ttl)
|
||||
|
||||
key = data_utils.arbitrary_string(size=20, base_text='MessagingKey')
|
||||
value = data_utils.arbitrary_string(size=20,
|
||||
base_text='MessagingValue')
|
||||
message_body = {key: value}
|
||||
|
||||
body = ([{'body': message_body, 'ttl': message_ttl}] * repeat)
|
||||
rbody = {'messages': body}
|
||||
return rbody
|
||||
|
||||
|
||||
class BaseV2MessagingTest(BaseMessagingTest):
|
||||
"""Base class for the Messaging (Zaqar) v2 tests."""
|
||||
@classmethod
|
||||
def setup_clients(cls):
|
||||
super(BaseV2MessagingTest, cls).setup_clients()
|
||||
cls.client = messaging_client.V2MessagingClient(
|
||||
cls.os_primary.auth_provider,
|
||||
CONF.messaging.catalog_type,
|
||||
CONF.identity.region,
|
||||
build_interval=CONF.compute.build_interval,
|
||||
build_timeout=CONF.compute.build_timeout)
|
||||
cls.client = cls.os_primary.messaging.V2MessagingClient()
|
||||
|
||||
@classmethod
|
||||
def purge_queue(cls, queue_name, resource=None):
|
||||
resp, body = cls.client.purge_queue(
|
||||
queue_name, resource)
|
||||
resp, body = cls.client.purge_queue(queue_name, resource)
|
||||
return resp, body
|
||||
|
||||
@classmethod
|
||||
def create_subscription(cls, queue_name, rbody):
|
||||
resp, body = cls.client.create_subscription(
|
||||
queue_name, rbody)
|
||||
resp, body = cls.client.create_subscription(queue_name, rbody)
|
||||
return resp, body
|
||||
|
||||
@classmethod
|
||||
|
||||
Reference in new issue
Block a user