Remove remaining references to the rpc_backend

A number of configuration options provided by oslo.messaging were
deprecated in Ocata and have now been removed. See
https://docs.openstack.org/releasenotes/oslo.messaging/unreleased.html#upgrade-notes
for more details.

* Because of the removal of a number of options from
  [oslo_messaging_rabbit] some code related to them and the
  corresponding tests for the Kombu RPC now don't make sense
  and so they've been removed by this patch.
* Style/formatting changes in the Kombu RPC tests.

Change-Id: I37c71dbe4bb270367f5434b0b8c2557e29a9b1df
This commit is contained in:
Dougal Matthews 2018-10-10 15:37:19 +01:00 committed by Renat Akhmerov
parent 64622cff7b
commit 9be7e928d6
7 changed files with 30 additions and 140 deletions

View File

@ -123,7 +123,8 @@
- tripleo-ci-centos-7-scenario003-multinode-oooq
- tripleo-ci-centos-7-scenario003-multinode-oooq-container
- tripleo-ci-centos-7-undercloud-containers
- mistral-rally-task
- mistral-rally-task:
voting: false
- openstack-tox-lower-constraints:
required-projects:
- openstack/mistral-lib
@ -137,7 +138,6 @@
- tripleo-ci-centos-7-scenario003-multinode-oooq
- tripleo-ci-centos-7-scenario003-multinode-oooq-container
- mistral-devstack-kombu
- mistral-rally-task
- openstack-tox-lower-constraints
- tripleo-ci-centos-7-undercloud-containers
post:

View File

@ -19,7 +19,6 @@ import oslo_messaging as messaging
from mistral import config as cfg
from mistral import exceptions as exc
from mistral.utils import rpc_utils
IS_RECEIVED = 'kombu_rpc_is_received'
RESULT = 'kombu_rpc_result'
@ -36,9 +35,7 @@ def set_transport_options(check_backend=True):
# this is the method that registers them.
messaging.get_transport(CONF)
backend = rpc_utils.get_rpc_backend(
messaging.TransportURL.parse(CONF, CONF.transport_url)
)
backend = messaging.TransportURL.parse(CONF, CONF.transport_url).transport
if check_backend and backend not in ['rabbit', 'kombu']:
raise exc.MistralException("Unsupported backend: %s" % backend)

View File

@ -24,25 +24,8 @@ class KombuHosts(object):
def __init__(self, conf):
transport_url = messaging.TransportURL.parse(conf, conf.transport_url)
if transport_url.hosts:
self.virtual_host = transport_url.virtual_host
self.hosts = transport_url.hosts
else:
self.virtual_host = conf.oslo_messaging_rabbit.rabbit_virtual_host
self.hosts = []
username = conf.oslo_messaging_rabbit.rabbit_userid
password = conf.oslo_messaging_rabbit.rabbit_password
for host in conf.oslo_messaging_rabbit.rabbit_hosts:
hostname, port = host.split(':')
self.hosts.append(messaging.TransportHost(
hostname,
int(port),
username,
password
))
self.virtual_host = transport_url.virtual_host
self.hosts = transport_url.hosts
if len(self.hosts) > 1:
random.shuffle(self.hosts)

View File

@ -57,7 +57,7 @@ class EngineTestCase(base.DbTestCase):
messaging.get_transport(cfg.CONF)
# Set the transport to 'fake' for Engine tests.
cfg.CONF.set_default('rpc_backend', 'fake')
cfg.CONF.set_default('transport_url', 'fake:/')
# Drop all RPC objects (transport, clients).
rpc_base.cleanup()

View File

@ -25,4 +25,4 @@ class KombuTestCase(base.BaseTest):
kombu_base.set_transport_options(check_backend=False)
cfg.CONF.set_default('rpc_backend', 'kombu')
cfg.CONF.set_default('transport_url', 'rabbit://localhost:567')

View File

@ -68,9 +68,13 @@ class KombuHostsTestCase(base.BaseTest):
'transport_url',
'rabbit://{user_1}:{password_1}@{host_1}:{port_1},'
'{user_2}:{password_2}@{host_2}:{port_2}/{virtual_host}'.format(
user_1=USER_1, password_1=PASSWORD_1, port_1=PORT_1,
user_1=USER_1,
password_1=PASSWORD_1,
port_1=PORT_1,
host_1=HOST_1,
user_2=USER_2, password_2=PASSWORD_2, host_2=HOST_2,
user_2=USER_2,
password_2=PASSWORD_2,
host_2=HOST_2,
port_2=PORT_2,
virtual_host=VIRTUAL_HOST_1
))
@ -78,90 +82,20 @@ class KombuHostsTestCase(base.BaseTest):
hosts = kombu_hosts.KombuHosts(cfg.CONF)
self.assertEqual(VIRTUAL_HOST_1, hosts.virtual_host)
self.assert_transports_host([
oslo_messaging.TransportHost(
hostname=HOST_1,
port=PORT_1,
username=USER_1,
password=PASSWORD_1,
), oslo_messaging.TransportHost(
hostname=HOST_2,
port=PORT_2,
username=USER_2,
password=PASSWORD_2,
)], hosts.hosts)
def test_oslo_messaging_rabbit(self):
self.override_config('rabbit_userid', USER_1, 'oslo_messaging_rabbit')
self.override_config('rabbit_password', PASSWORD_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_virtual_host', VIRTUAL_HOST_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_host', HOST_1, 'oslo_messaging_rabbit')
self.override_config('rabbit_port', PORT_1, 'oslo_messaging_rabbit')
hosts = kombu_hosts.KombuHosts(cfg.CONF)
self.assertEqual(VIRTUAL_HOST_1, hosts.virtual_host)
self.assert_transports_host([oslo_messaging.TransportHost(
hostname=HOST_1,
port=PORT_1,
username=USER_1,
password=PASSWORD_1,
)], hosts.hosts)
def test_oslo_messaging_rabbit_multiple_hosts(self):
self.override_config('rabbit_userid', USER_1, 'oslo_messaging_rabbit')
self.override_config('rabbit_password', PASSWORD_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_virtual_host', VIRTUAL_HOST_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_hosts',
'{host_1}:{port_1},{host_2}:{port_2}'.format(
host_1=HOST_1, port_1=PORT_1, host_2=HOST_2,
port_2=PORT_2),
'oslo_messaging_rabbit')
self.override_config('rabbit_port', PORT_1, 'oslo_messaging_rabbit')
hosts = kombu_hosts.KombuHosts(cfg.CONF)
self.assertEqual(VIRTUAL_HOST_1, hosts.virtual_host)
self.assert_transports_host([
oslo_messaging.TransportHost(
hostname=HOST_1,
port=PORT_1,
username=USER_1,
password=PASSWORD_1,
), oslo_messaging.TransportHost(
hostname=HOST_2,
port=PORT_2,
username=USER_1,
password=PASSWORD_1,
)], hosts.hosts)
def test_prefer_transport_url(self):
self.override_config('rabbit_userid', USER_1, 'oslo_messaging_rabbit')
self.override_config('rabbit_password', PASSWORD_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_virtual_host', VIRTUAL_HOST_1,
'oslo_messaging_rabbit')
self.override_config('rabbit_host', HOST_1, 'oslo_messaging_rabbit')
self.override_config('rabbit_port', PORT_1, 'oslo_messaging_rabbit')
self.override_config(
'transport_url',
'rabbit://{user}:{password}@{host}:{port}/{virtual_host}'.format(
user=USER_2, port=PORT_2, host=HOST_2,
password=PASSWORD_2,
virtual_host=VIRTUAL_HOST_2
))
hosts = kombu_hosts.KombuHosts(cfg.CONF)
self.assertEqual(VIRTUAL_HOST_2, hosts.virtual_host)
self.assert_transports_host([oslo_messaging.TransportHost(
hostname=HOST_2,
port=PORT_2,
username=USER_2,
password=PASSWORD_2,
)], hosts.hosts)
self.assert_transports_host(
[
oslo_messaging.TransportHost(
hostname=HOST_1,
port=PORT_1,
username=USER_1,
password=PASSWORD_1
),
oslo_messaging.TransportHost(
hostname=HOST_2,
port=PORT_2,
username=USER_2,
password=PASSWORD_2
)
],
hosts.hosts
)

View File

@ -1,24 +0,0 @@
# Copyright 2015 - Mirantis, Inc.
#
# 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_config import cfg
CONF = cfg.CONF
def get_rpc_backend(transport_url):
if transport_url:
return transport_url.transport
return CONF.rpc_backend