From 539c2fab9ec97a0bf63ceade47cab78d680a9ca8 Mon Sep 17 00:00:00 2001 From: Hemanth Makkapati Date: Wed, 22 Mar 2017 10:42:01 -0500 Subject: [PATCH] Fix tests in stable/ocata Backport fixes due to distro changes affecting py27 causing stable maintenance check jobs to fail. This patch includes the following changes: - Invoke Monkey Patching for All Tests (cherry picked from commit 630402204e83b9e36c6822fc251fa06cf28963ac) - eventlet issue <0.22.0 (impacts functional tests) - fixtures must be imported absolutely or they aren't monkey patched (these two were cherry picked from commit 3a638140ca7162902cea0405a7174dfad5868280) - extending eventlet issue <0.22.0 fix to glare (new in this patch, not required in pike or master) Closes-bug: #1747305 Change-Id: Ib9f8a52136e25d1cb609d465ca5d859523d9acc6 --- glance/cmd/api.py | 6 ++++++ glance/cmd/glare.py | 6 ++++++ glance/cmd/registry.py | 6 ++++++ glance/cmd/scrubber.py | 6 ++++++ glance/tests/__init__.py | 9 +++++++++ glance/tests/functional/__init__.py | 4 ++++ glance/tests/integration/legacy_functional/base.py | 4 ++++ glance/tests/integration/v2/base.py | 4 ++++ glance/tests/unit/common/test_config.py | 4 ++++ glance/tests/unit/common/test_swift_store_utils.py | 4 ++++ glance/tests/unit/common/test_wsgi.py | 4 ++++ glance/tests/unit/test_glance_replicator.py | 4 ++++ glance/tests/unit/test_image_cache.py | 4 ++++ glance/tests/unit/test_manage.py | 4 ++++ glance/tests/utils.py | 4 ++++ 15 files changed, 73 insertions(+) diff --git a/glance/cmd/api.py b/glance/cmd/api.py index 6ab3367fa6..b6b5988b20 100644 --- a/glance/cmd/api.py +++ b/glance/cmd/api.py @@ -29,6 +29,12 @@ from oslo_utils import encodeutils # Monkey patch socket, time, select, threads +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() eventlet.patcher.monkey_patch(all=False, socket=True, time=True, select=True, thread=True, os=True) diff --git a/glance/cmd/glare.py b/glance/cmd/glare.py index 5abc4420ee..10f30d5607 100644 --- a/glance/cmd/glare.py +++ b/glance/cmd/glare.py @@ -28,6 +28,12 @@ import eventlet from oslo_utils import encodeutils +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() eventlet.patcher.monkey_patch(all=False, socket=True, time=True, select=True, thread=True, os=True) diff --git a/glance/cmd/registry.py b/glance/cmd/registry.py index 42cfb8d6e2..2f6fa0deb7 100644 --- a/glance/cmd/registry.py +++ b/glance/cmd/registry.py @@ -28,6 +28,12 @@ import eventlet from oslo_utils import encodeutils # Monkey patch socket and time +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=True) # If ../glance/__init__.py exists, add ../ to Python search path, so that diff --git a/glance/cmd/scrubber.py b/glance/cmd/scrubber.py index 8eadb4ee98..cea0d49e88 100644 --- a/glance/cmd/scrubber.py +++ b/glance/cmd/scrubber.py @@ -38,6 +38,12 @@ from oslo_log import log as logging from glance.common import config from glance import scrubber +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() eventlet.patcher.monkey_patch(all=False, socket=True, time=True, select=True, thread=True, os=True) diff --git a/glance/tests/__init__.py b/glance/tests/__init__.py index 557340aa49..028781dd6b 100644 --- a/glance/tests/__init__.py +++ b/glance/tests/__init__.py @@ -31,3 +31,12 @@ formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) + +import eventlet +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() +eventlet.patcher.monkey_patch() diff --git a/glance/tests/functional/__init__.py b/glance/tests/functional/__init__.py index cd6c8f8ec4..72e5c14a53 100644 --- a/glance/tests/functional/__init__.py +++ b/glance/tests/functional/__init__.py @@ -21,6 +21,10 @@ and Registry server, grabbing the logs of each, cleaning up pidfiles, and spinning down the servers. """ +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import atexit import datetime import errno diff --git a/glance/tests/integration/legacy_functional/base.py b/glance/tests/integration/legacy_functional/base.py index 174e3e69d6..96aa1b2a64 100644 --- a/glance/tests/integration/legacy_functional/base.py +++ b/glance/tests/integration/legacy_functional/base.py @@ -10,6 +10,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import atexit import os.path import tempfile diff --git a/glance/tests/integration/v2/base.py b/glance/tests/integration/v2/base.py index 71cec787fa..9bb83c9c5d 100644 --- a/glance/tests/integration/v2/base.py +++ b/glance/tests/integration/v2/base.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import atexit import os.path import tempfile diff --git a/glance/tests/unit/common/test_config.py b/glance/tests/unit/common/test_config.py index 0888b0507f..b4774cef47 100644 --- a/glance/tests/unit/common/test_config.py +++ b/glance/tests/unit/common/test_config.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import os.path import shutil diff --git a/glance/tests/unit/common/test_swift_store_utils.py b/glance/tests/unit/common/test_swift_store_utils.py index 199fe609a3..3b4f5cccb2 100644 --- a/glance/tests/unit/common/test_swift_store_utils.py +++ b/glance/tests/unit/common/test_swift_store_utils.py @@ -12,6 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import fixtures from glance.common import exception diff --git a/glance/tests/unit/common/test_wsgi.py b/glance/tests/unit/common/test_wsgi.py index 03a6b8bc7d..c30a4fb31f 100644 --- a/glance/tests/unit/common/test_wsgi.py +++ b/glance/tests/unit/common/test_wsgi.py @@ -14,6 +14,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import datetime import gettext import os diff --git a/glance/tests/unit/test_glance_replicator.py b/glance/tests/unit/test_glance_replicator.py index 8c10fdfd57..816fa2be3e 100644 --- a/glance/tests/unit/test_glance_replicator.py +++ b/glance/tests/unit/test_glance_replicator.py @@ -12,6 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import copy import os import sys diff --git a/glance/tests/unit/test_image_cache.py b/glance/tests/unit/test_image_cache.py index 89d86f5f16..0e86c1e22e 100644 --- a/glance/tests/unit/test_image_cache.py +++ b/glance/tests/unit/test_image_cache.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + from contextlib import contextmanager import datetime import hashlib diff --git a/glance/tests/unit/test_manage.py b/glance/tests/unit/test_manage.py index 80b0c670ae..3972ba5242 100644 --- a/glance/tests/unit/test_manage.py +++ b/glance/tests/unit/test_manage.py @@ -13,6 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import fixtures import mock diff --git a/glance/tests/utils.py b/glance/tests/utils.py index 61472721da..fa41b7fea3 100644 --- a/glance/tests/utils.py +++ b/glance/tests/utils.py @@ -15,6 +15,10 @@ """Common utilities used in testing""" +# NOTE(rosmaita): mriedem says this is needed for importing from fixtures, +# and he's right! +from __future__ import absolute_import + import errno import functools import os