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
This commit is contained in:
Takashi Kajinami 2024-10-17 11:14:18 +09:00
parent c0522e2419
commit 874f0fea56
3 changed files with 10 additions and 8 deletions

View File

@ -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:

View File

@ -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}

View File

@ -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):