Remove utils.reset_is_neutron() to avoid races
If a unit test does not call utils.reset_is_neutron() when it is complete, it may introduce a race condition because the utils.is_neutron() value is cached to the old result. This patch removes the utils.reset_is_neutron() and instead makes sure that we never have a cached value for it. It also refactors _is_neutron out of vmwareapi.VMOps because it cache the result unnecessarily. Change-Id: I2440e308b00979b31c750513d14608808a295c33 Closes-Bug: #1309043
This commit is contained in:
@@ -52,6 +52,7 @@ from nova import rpc
|
||||
from nova import service
|
||||
from nova.tests import conf_fixture
|
||||
from nova.tests import policy_fixture
|
||||
from nova import utils
|
||||
|
||||
|
||||
test_opts = [
|
||||
@@ -305,6 +306,11 @@ class TestCase(testtools.TestCase):
|
||||
objects_base.NovaObject._obj_classes)
|
||||
self.addCleanup(self._restore_obj_registry)
|
||||
|
||||
# NOTE(mnaser): All calls to utils.is_neutron() are cached in
|
||||
# nova.utils._IS_NEUTRON. We set it to None to avoid any
|
||||
# caching of that value.
|
||||
utils._IS_NEUTRON = None
|
||||
|
||||
mox_fixture = self.useFixture(moxstubout.MoxStubout())
|
||||
self.mox = mox_fixture.mox
|
||||
self.stubs = mox_fixture.stubs
|
||||
|
||||
@@ -1067,11 +1067,6 @@ def is_neutron():
|
||||
return _IS_NEUTRON
|
||||
|
||||
|
||||
def reset_is_neutron():
|
||||
global _IS_NEUTRON
|
||||
_IS_NEUTRON = None
|
||||
|
||||
|
||||
def is_auto_disk_config_disabled(auto_disk_config_raw):
|
||||
auto_disk_config_disabled = False
|
||||
if auto_disk_config_raw is not None:
|
||||
|
||||
Reference in New Issue
Block a user