summaryrefslogtreecommitdiff
path: root/nova/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-02-14 16:25:42 +0000
committerGerrit Code Review <review@openstack.org>2023-02-14 16:25:42 +0000
commit1330b280778fa834cffbc4ec9a8aa6b04cb2471e (patch)
tree4eac1303dc7a049db97966e402cab286a41c854a /nova/tests
parenta2964417822bd1a4a83fa5c27282d2be1e18868a (diff)
parent1778a9c589cf24e17b44f556680b17af9577df11 (diff)
downloadnova-1330b280778fa834cffbc4ec9a8aa6b04cb2471e.tar.gz
Merge "Add logging to find test cases leaking libvirt threads"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/fixtures/nova.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py
index 5fd893e7dc..9a652c02cb 100644
--- a/nova/tests/fixtures/nova.py
+++ b/nova/tests/fixtures/nova.py
@@ -1822,6 +1822,24 @@ class ImportModulePoisonFixture(fixtures.Fixture):
def find_spec(self, fullname, path, target=None):
if fullname in self.modules:
+ current = eventlet.getcurrent()
+ # NOTE(gibi) not all eventlet spawn is under our control, so
+ # there can be senders without test_case_id set, find the first
+ # ancestor that was spawned from nova.utils.spawn[_n] and
+ # therefore has the id set.
+ while (
+ current is not None and
+ not getattr(current, 'test_case_id', None)
+ ):
+ current = current.parent
+
+ if current is not None:
+ self.test.tc_id = current.test_case_id
+ LOG.warning(
+ "!!!---!!! TestCase ID %s hit the import poison while "
+ "importing %s. If you see this in a failed functional "
+ "test then please let #openstack-nova on IRC know "
+ "about it. !!!---!!!", current.test_case_id, fullname)
self.test.fail_message = (
f"This test imports the '{fullname}' module, which it "
f'should not in the test environment. Please add '
@@ -1832,6 +1850,7 @@ class ImportModulePoisonFixture(fixtures.Fixture):
def __init__(self, module_names):
self.module_names = module_names
self.fail_message = ''
+ self.tc_id = None
if isinstance(module_names, str):
self.module_names = {module_names}
self.meta_path_finder = self.ForbiddenModules(self, self.module_names)
@@ -1849,6 +1868,13 @@ class ImportModulePoisonFixture(fixtures.Fixture):
# there (which is also what self.assert* and self.fail() do underneath)
# will not work to cause a failure in the test.
if self.fail_message:
+ if self.tc_id is not None:
+ LOG.warning(
+ "!!!---!!! TestCase ID %s hit the import poison. If you "
+ "see this in a failed functional test then please let "
+ "#openstack-nova on IRC know about it. !!!---!!!",
+ self.tc_id
+ )
raise ImportError(self.fail_message)