From 874f0fea56085d2bcdfffe125054e39b80306a6d Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 17 Oct 2024 11:14:18 +0900 Subject: [PATCH] Simplify zaqar endpoint detection in tests Use environment variables used in devstack to detect endpoints. Also in CI we can make zaqar bind localhost to use the static address. Change-Id: Ia6d0fb3322ae2faf4c5b30f833e9b82292599747 --- .zuul.yaml | 4 ++++ tox.ini | 2 ++ zaqarclient/tests/queues/base.py | 12 ++++-------- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 066566eb..03660524 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -7,6 +7,8 @@ - opendev.org/openstack/zaqar - opendev.org/openstack/zaqar-tempest-plugin vars: + devstack_localrc: + ZAQAR_SERVICE_HOST: localhost devstack_plugins: zaqar: https://opendev.org/openstack/zaqar devstack_services: @@ -24,6 +26,8 @@ # when they have been enabled again by a native Zuul v3 job. # The failing job can be checked by removing this filter. tox_extra_args: -vv -- tests.functional.queues.v2.test_health + tox_environment: + ZAQAR_SERVICE_HOST: localhost - project: templates: diff --git a/tox.ini b/tox.ini index c155eada..ce5ae685 100644 --- a/tox.ini +++ b/tox.ini @@ -35,6 +35,8 @@ setenv = OS_TEST_PATH = ./tests/functional ZAQARCLIENT_AUTH_FUNCTIONAL = 1 ZAQARCLIENT_TEST_FUNCTIONAL = 1 +passenv = + ZAQAR_SERVICE_HOST [testenv:venv] commands = {posargs} diff --git a/zaqarclient/tests/queues/base.py b/zaqarclient/tests/queues/base.py index dc654398..c55133a5 100644 --- a/zaqarclient/tests/queues/base.py +++ b/zaqarclient/tests/queues/base.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -import subprocess +import os from unittest import mock from oslo_utils import netutils @@ -22,18 +22,14 @@ from zaqarclient.queues import client from zaqarclient.tests import base from zaqarclient.tests.transport import dummy -cmd = 'cat /etc/zaqar/uwsgi.conf | grep http' -MY_HOST_IP = subprocess.run(cmd, shell=True, capture_output=True, text=True) -if len(MY_HOST_IP.stdout.split("= ")) < 2: - MY_IP = netutils.get_my_ipv4() + ':8888' -else: - MY_IP = MY_HOST_IP.stdout.split("= ")[1] + +MY_IP = os.environ.get('ZAQAR_SERVICE_HOST', netutils.get_my_ipv4()) class QueuesTestBase(base.TestBase): transport_cls = dummy.DummyTransport - url = 'http://%s' % MY_IP + url = 'http://%s:8888' % netutils.escape_ipv6(MY_IP) version = 1 def setUp(self):