Make dynamic routing tests use clients as others

Change-Id: Ieafc4d8af1c6eee52e65373deb201eec3615d181
This commit is contained in:
elajkat 2020-07-09 11:23:15 +02:00
parent 7cc1a9ded5
commit b7cb10b946
2 changed files with 32 additions and 34 deletions

View File

@ -26,29 +26,8 @@ from neutron_tempest_plugin.services.bgp import bgp_client
CONF = config.CONF CONF = config.CONF
def _setup_client_args(auth_provider):
"""Set up ServiceClient arguments using config settings. """
service = CONF.network.catalog_type or 'network'
region = CONF.network.region or 'regionOne'
endpoint_type = CONF.network.endpoint_type
build_interval = CONF.network.build_interval
build_timeout = CONF.network.build_timeout
# The disable_ssl appears in identity
disable_ssl_certificate_validation = (
CONF.identity.disable_ssl_certificate_validation)
ca_certs = CONF.identity.ca_certificates_file
# Trace in debug section
trace_requests = CONF.debug.trace_requests
return [auth_provider, service, region, endpoint_type,
build_interval, build_timeout,
disable_ssl_certificate_validation, ca_certs,
trace_requests]
class BgpSpeakerTestJSONBase(base.BaseAdminNetworkTest): class BgpSpeakerTestJSONBase(base.BaseAdminNetworkTest):
credentials = ['primary', 'admin']
default_bgp_speaker_args = {'local_as': '1234', default_bgp_speaker_args = {'local_as': '1234',
'ip_version': 4, 'ip_version': 4,
@ -65,18 +44,20 @@ class BgpSpeakerTestJSONBase(base.BaseAdminNetworkTest):
super(BgpSpeakerTestJSONBase, self).setUp() super(BgpSpeakerTestJSONBase, self).setUp()
@classmethod @classmethod
def _setup_bgp_admin_client(cls): def setup_clients(cls):
mgr = cls.get_client_manager(credential_type='admin') super(BgpSpeakerTestJSONBase, cls).setup_clients()
auth_provider = mgr.auth_provider cls.bgp_client = cls.os_primary.bgp_client
client_args = _setup_client_args(auth_provider) cls.bgp_adm_client = cls.os_admin.bgp_client
cls.bgp_adm_client = bgp_client.BgpSpeakerClientJSON(*client_args)
@classmethod @classmethod
def _setup_bgp_non_admin_client(cls): def get_client_manager(cls, credential_type=None, roles=None,
mgr = cls.get_client_manager() force_new=None):
auth_provider = mgr.auth_provider manager = super(BgpSpeakerTestJSONBase, cls).get_client_manager(
client_args = _setup_client_args(auth_provider) credential_type=credential_type,
cls.bgp_client = bgp_client.BgpSpeakerClientJSON(*client_args) roles=roles,
force_new=force_new
)
return bgp_client.Manager(manager.credentials)
@classmethod @classmethod
def resource_setup(cls): def resource_setup(cls):
@ -89,8 +70,6 @@ class BgpSpeakerTestJSONBase(base.BaseAdminNetworkTest):
cls.admin_floatingips = [] cls.admin_floatingips = []
cls.admin_routers = [] cls.admin_routers = []
cls.ext_net_id = CONF.network.public_network_id cls.ext_net_id = CONF.network.public_network_id
cls._setup_bgp_admin_client()
cls._setup_bgp_non_admin_client()
@classmethod @classmethod
def resource_cleanup(cls): def resource_cleanup(cls):

View File

@ -15,6 +15,25 @@
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from tempest.lib.common import rest_client from tempest.lib.common import rest_client
from neutron_tempest_plugin.api import clients as manager
from neutron_tempest_plugin import config
CONF = config.CONF
class Manager(manager.Manager):
def __init__(self, credentials=None, service=None):
super(Manager, self).__init__(credentials, service)
self.bgp_client = BgpSpeakerClientJSON(
self.auth_provider,
CONF.network.catalog_type,
CONF.network.region or CONF.identity.region,
endpoint_type=CONF.network.endpoint_type,
build_interval=CONF.network.build_interval,
build_timeout=CONF.network.build_timeout,
**self.default_params)
class BgpSpeakerClientJSON(rest_client.RestClient): class BgpSpeakerClientJSON(rest_client.RestClient):