Allow to start unit test without eventlet

The end goals is to be able to run at least some of the unit tests
without eventlet. But there are things preventing that for now.

We need to make sure that the oslo.sevice backed is not initialized to
eventlet by any early import code before our monkey_patch module can do
the selective backed selection based on the env variable.

The nova.tests.unit module had some import time code execution that is
forcing imports that initialize the oslo.service backend too early,
way before nova would do it in normal execution. We could remove
objects.register_all() from nova/tests/unit/__init__.py as it seems
tests are passing without it. Still that would not be enough so I
eventually decide to keep it.

The other issue is that the unit test discovery imports all modules
under nova.tests.unit and that eventually imports oslo.messaging and
that also forces oslo.service backend selection.

So we injected an early call to our smart monkey_patch module to preempt
that. This does not change the imported modules as monkey_patch module
imported anyhow via nova.test module. Just changed the order to allow
oslo.service backend selection explicitly.

After this patch the unit test can be run via

  OS_NOVA_DISABLE_EVENTLET_PATCHING=true tox -e py312

Most of the test will pass but there are a bunch of test timing out or
hanging.

Change-Id: I210cb6a30deaee779d55f88f0f57584c65b0dc05
Signed-off-by: Balazs Gibizer <gibi@redhat.com>
This commit is contained in:
Balazs Gibizer
2025-06-26 14:14:57 +02:00
parent 2a9cbdabce
commit b278240370
3 changed files with 46 additions and 11 deletions
+3
View File
@@ -48,6 +48,9 @@ passenv =
PYTHONOPTIMIZE
# there is also secret magic in subunit-trace which lets you run in a fail only
# mode. To do this define the TRACE_FAILONLY environmental variable.
# allow running without eventlet
OS_NOVA_DISABLE_EVENTLET_PATCHING
commands =
stestr run {posargs}
env TEST_OSPROFILER=1 stestr run --combine --no-discover 'nova.tests.unit.test_profiler'