From 8ca794cdbbf9d4ea55b260a798d3f42b58ce720e Mon Sep 17 00:00:00 2001 From: Douglas Viroel Date: Tue, 15 Jul 2025 14:51:31 -0300 Subject: [PATCH] Add a new tox environment to run unit tests in threading mode It is done by disabling the eventlet patching and configuring oslo.service backend to threading. Once oslo.service backend is configured, it can't be reverted to eventlet. This needs to be done before including other modules, which may include oslo.service library. Adds a job that run a subset of tests with eventlet patching disabled. Change-Id: I9f8c2c5bbcf3192313cc3b309e8f2719a3bea18f Signed-off-by: Douglas Viroel --- .zuul.yaml | 9 +++++++++ tox.ini | 10 ++++++++++ watcher/tests/__init__.py | 7 +++++++ 3 files changed, 26 insertions(+) diff --git a/.zuul.yaml b/.zuul.yaml index 039601715..1fca7de69 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -278,6 +278,14 @@ devstack_localrc: 'SYSTEMD_ENV_VARS["watcher-decision-engine"]': OS_WATCHER_DISABLE_EVENTLET_PATCHING=true +- job: + name: openstack-tox-py312-threading + parent: openstack-tox-py312 + description: | + Run tox with the py3-threading environment. + vars: + tox_envlist: py3-threading + - project: queue: watcher templates: @@ -288,6 +296,7 @@ - release-notes-jobs-python3 check: jobs: + - openstack-tox-py312-threading - watcher-tempest-functional - watcher-grenade - watcher-tempest-strategies diff --git a/tox.ini b/tox.ini index 349e5300c..91eacecd6 100644 --- a/tox.ini +++ b/tox.ini @@ -37,6 +37,16 @@ passenv = # debugging issue with fixtures and mocks. PYTHONOPTIMIZE +[testenv:py3-threading] +setenv = + OS_WATCHER_DISABLE_EVENTLET_PATCHING=true +commands = + rm -f .testrepository/times.dbm + find . -type f -name "*.py[c|o]" -delete + # NOTE(dviroel): Applier still requires changes to support + # threading mode + stestr run {posargs} --exclude-regex 'applier' + [testenv:pep8] description = Run style checks. diff --git a/watcher/tests/__init__.py b/watcher/tests/__init__.py index 1c1facda6..a6c535ab4 100644 --- a/watcher/tests/__init__.py +++ b/watcher/tests/__init__.py @@ -21,6 +21,13 @@ from watcher import eventlet eventlet.patch() +# NOTE(dviroel): oslo service backend needs to be initialize +# as soon as possible, before importing oslo service. If eventlet +# patching is enabled, it should be patched before calling this +# function +from watcher.common import oslo_service_helper as helper # noqa E402 +helper.init_oslo_service_backend() + from watcher import objects # noqa E402 # NOTE(comstud): Make sure we have all of the objects loaded. We do this