diff --git a/nova/test.py b/nova/test.py index 928e0d5aa..88a9b3378 100644 --- a/nova/test.py +++ b/nova/test.py @@ -47,7 +47,6 @@ import testtools from nova import context from nova import db from nova.network import manager as network_manager -from nova import objects from nova.objects import base as objects_base from nova.tests import fixtures as nova_fixtures from nova.tests.unit import conf_fixture @@ -62,11 +61,6 @@ logging.register_options(CONF) CONF.set_override('use_stderr', False) logging.setup(CONF, 'nova') -# NOTE(comstud): Make sure we have all of the objects loaded. We do this -# at module import time, because we may be using mock decorators in our -# tests that run at import time. -objects.register_all() - _TRUE_VALUES = ('True', 'true', '1', 'yes') if six.PY3: diff --git a/nova/tests/unit/__init__.py b/nova/tests/unit/__init__.py index 6446a8a73..09d81a2d9 100644 --- a/nova/tests/unit/__init__.py +++ b/nova/tests/unit/__init__.py @@ -24,4 +24,15 @@ import eventlet +from nova import objects + eventlet.monkey_patch(os=False) + +# NOTE(alaski): Make sure this is done after eventlet monkey patching otherwise +# the threading.local() store used in oslo_messaging will be initialized to +# threadlocal storage rather than greenthread local. This will cause context +# sets and deletes in that storage to clobber each other. +# NOTE(comstud): Make sure we have all of the objects loaded. We do this +# at module import time, because we may be using mock decorators in our +# tests that run at import time. +objects.register_all()