@@ -1822,6 +1822,24 @@ def __init__(self, test, modules):
1822
1822
1823
1823
def find_spec (self , fullname , path , target = None ):
1824
1824
if fullname in self .modules :
1825
+ current = eventlet .getcurrent ()
1826
+ # NOTE(gibi) not all eventlet spawn is under our control, so
1827
+ # there can be senders without test_case_id set, find the first
1828
+ # ancestor that was spawned from nova.utils.spawn[_n] and
1829
+ # therefore has the id set.
1830
+ while (
1831
+ current is not None and
1832
+ not getattr (current , 'test_case_id' , None )
1833
+ ):
1834
+ current = current .parent
1835
+
1836
+ if current is not None :
1837
+ self .test .tc_id = current .test_case_id
1838
+ LOG .warning (
1839
+ "!!!---!!! TestCase ID %s hit the import poison while "
1840
+ "importing %s. If you see this in a failed functional "
1841
+ "test then please let #openstack-nova on IRC know "
1842
+ "about it. !!!---!!!" , current .test_case_id , fullname )
1825
1843
self .test .fail_message = (
1826
1844
f"This test imports the '{ fullname } ' module, which it "
1827
1845
f'should not in the test environment. Please add '
@@ -1832,6 +1850,7 @@ def find_spec(self, fullname, path, target=None):
1832
1850
def __init__ (self , module_names ):
1833
1851
self .module_names = module_names
1834
1852
self .fail_message = ''
1853
+ self .tc_id = None
1835
1854
if isinstance (module_names , str ):
1836
1855
self .module_names = {module_names }
1837
1856
self .meta_path_finder = self .ForbiddenModules (self , self .module_names )
@@ -1849,6 +1868,13 @@ def cleanup(self):
1849
1868
# there (which is also what self.assert* and self.fail() do underneath)
1850
1869
# will not work to cause a failure in the test.
1851
1870
if self .fail_message :
1871
+ if self .tc_id is not None :
1872
+ LOG .warning (
1873
+ "!!!---!!! TestCase ID %s hit the import poison. If you "
1874
+ "see this in a failed functional test then please let "
1875
+ "#openstack-nova on IRC know about it. !!!---!!!" ,
1876
+ self .tc_id
1877
+ )
1852
1878
raise ImportError (self .fail_message )
1853
1879
1854
1880
0 commit comments