From e140c53248a29ed13d3e2a811df04a11e9efdd82 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 14:19:19 +0100 Subject: [PATCH 1/8] Upgrade eventlet to the latest version (0.22.1). --- fixed-requirements.txt | 2 +- requirements.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fixed-requirements.txt b/fixed-requirements.txt index d18c44b8f8..fa0eb9fe6f 100644 --- a/fixed-requirements.txt +++ b/fixed-requirements.txt @@ -3,7 +3,7 @@ greenlet==0.4.12 # Note: 0.20.0 removed select.poll() on which some of our code and libraries we # depend on rely -eventlet==0.19.0 +eventlet==0.22.1 gunicorn==19.7.1 kombu==4.1.0 # Note: amqp is used by kombu diff --git a/requirements.txt b/requirements.txt index 3ae548afe6..1610f2f6ce 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ apscheduler==3.4.0 argcomplete bcrypt -eventlet==0.19.0 +eventlet==0.22.1 flex==6.11.1 git+https://github.com/Kami/logshipper.git@stackstorm_patched#egg=logshipper git+https://github.com/StackStorm/python-mistralclient.git#egg=python-mistralclient From 3202a808f147005d36e9a6ba836d037c078fd4af Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 14:31:24 +0100 Subject: [PATCH 2/8] Add a work around for test case which failed with new version of eventlet where poll() method has been removed from select module because it's blocking. Note: This issue only affects tests. --- st2common/tests/unit/test_pack_management.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/st2common/tests/unit/test_pack_management.py b/st2common/tests/unit/test_pack_management.py index 0fc2459de4..226b021a6f 100644 --- a/st2common/tests/unit/test_pack_management.py +++ b/st2common/tests/unit/test_pack_management.py @@ -14,10 +14,16 @@ # limitations under the License. from __future__ import absolute_import + import os import sys +import subprocess import unittest2 +import eventlet + +from st2common.util.monkey_patch import monkey_patch +monkey_patch() BASE_DIR = os.path.dirname(os.path.abspath(__file__)) PACK_ACTIONS_DIR = os.path.join(BASE_DIR, '../../../contrib/packs/actions') @@ -25,8 +31,16 @@ sys.path.insert(0, PACK_ACTIONS_DIR) +# Work around to get tests to pass with eventlet >= 0.20.0 +sys.modules['select'] = eventlet.patcher.original('select') +subprocess.select = eventlet.patcher.original('select') + from pack_mgmt.download import DownloadGitRepoAction +__all__ = [ + 'InstallPackTestCase' +] + class InstallPackTestCase(unittest2.TestCase): From b577269e990d0eda18d03ec129f0ae65a796befe Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 14:54:20 +0100 Subject: [PATCH 3/8] Only perform work around when running under nose tests. --- st2common/tests/unit/test_pack_management.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/st2common/tests/unit/test_pack_management.py b/st2common/tests/unit/test_pack_management.py index 226b021a6f..560a7dce7f 100644 --- a/st2common/tests/unit/test_pack_management.py +++ b/st2common/tests/unit/test_pack_management.py @@ -32,8 +32,9 @@ sys.path.insert(0, PACK_ACTIONS_DIR) # Work around to get tests to pass with eventlet >= 0.20.0 -sys.modules['select'] = eventlet.patcher.original('select') -subprocess.select = eventlet.patcher.original('select') +if 'nose' in sys.modules.keys(): + sys.modules['select'] = eventlet.patcher.original('select') + subprocess.select = eventlet.patcher.original('select') from pack_mgmt.download import DownloadGitRepoAction From dd703fbce064e871392af844fa40ab1d1a075102 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 15:06:12 +0100 Subject: [PATCH 4/8] Remove code which we don't need. --- st2common/tests/unit/test_pack_management.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/st2common/tests/unit/test_pack_management.py b/st2common/tests/unit/test_pack_management.py index 560a7dce7f..45e33ba3fc 100644 --- a/st2common/tests/unit/test_pack_management.py +++ b/st2common/tests/unit/test_pack_management.py @@ -22,9 +22,6 @@ import unittest2 import eventlet -from st2common.util.monkey_patch import monkey_patch -monkey_patch() - BASE_DIR = os.path.dirname(os.path.abspath(__file__)) PACK_ACTIONS_DIR = os.path.join(BASE_DIR, '../../../contrib/packs/actions') PACK_ACTIONS_DIR = os.path.abspath(PACK_ACTIONS_DIR) From fcfd35188238f2ec064e38cb304195198aca0e22 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 15:31:36 +0100 Subject: [PATCH 5/8] Use select.poll() workaround in more tests. --- contrib/packs/tests/test_action_download.py | 9 +++++++++ contrib/packs/tests/test_action_unload.py | 6 ++++++ st2common/st2common/util/monkey_patch.py | 16 ++++++++++++++++ st2common/tests/unit/test_pack_management.py | 6 ++---- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/contrib/packs/tests/test_action_download.py b/contrib/packs/tests/test_action_download.py index f12d51757a..376e670891 100644 --- a/contrib/packs/tests/test_action_download.py +++ b/contrib/packs/tests/test_action_download.py @@ -16,10 +16,19 @@ # limitations under the License. import os +import sys import mock import shutil import tempfile import hashlib +import subprocess + +import eventlet +# Work around to get tests to pass with eventlet >= 0.20.0 +if 'nose' in sys.modules.keys(): + sys.modules['select'] = eventlet.patcher.original('select') + subprocess.select = eventlet.patcher.original('select') + from lockfile import LockFile from lockfile import LockTimeout diff --git a/contrib/packs/tests/test_action_unload.py b/contrib/packs/tests/test_action_unload.py index df8657eaa6..e08bf1eb6e 100644 --- a/contrib/packs/tests/test_action_unload.py +++ b/contrib/packs/tests/test_action_unload.py @@ -16,9 +16,15 @@ # limitations under the License. import os +import sys +import subprocess +import eventlet from oslo_config import cfg +from st2common.util.monkey_patch import use_select_poll_workaround +use_select_poll_workaround() + from st2common.content.bootstrap import register_content from st2common.persistence.pack import Pack from st2common.persistence.pack import Config diff --git a/st2common/st2common/util/monkey_patch.py b/st2common/st2common/util/monkey_patch.py index 3989cabffe..d3e0254b22 100644 --- a/st2common/st2common/util/monkey_patch.py +++ b/st2common/st2common/util/monkey_patch.py @@ -23,6 +23,7 @@ __all__ = [ 'monkey_patch', + 'use_select_poll_workaround', 'is_use_debugger_flag_provided' ] @@ -44,6 +45,21 @@ def monkey_patch(): eventlet.monkey_patch(os=True, select=True, socket=True, thread=patch_thread, time=True) +def use_select_poll_workaround(): + """ + Work around for some tests which injects original select module with select.poll() + available to sys.modules. + """ + import sys + import subprocess + import eventlet + + # Work around to get tests to pass with eventlet >= 0.20.0 + if 'nose' in sys.modules.keys(): + sys.modules['select'] = eventlet.patcher.original('select') + subprocess.select = eventlet.patcher.original('select') + + def is_use_debugger_flag_provided(): # 1. Check sys.argv directly if USE_DEBUGGER_FLAG in sys.argv: diff --git a/st2common/tests/unit/test_pack_management.py b/st2common/tests/unit/test_pack_management.py index 45e33ba3fc..2c0e165be6 100644 --- a/st2common/tests/unit/test_pack_management.py +++ b/st2common/tests/unit/test_pack_management.py @@ -28,10 +28,8 @@ sys.path.insert(0, PACK_ACTIONS_DIR) -# Work around to get tests to pass with eventlet >= 0.20.0 -if 'nose' in sys.modules.keys(): - sys.modules['select'] = eventlet.patcher.original('select') - subprocess.select = eventlet.patcher.original('select') +from st2common.util.monkey_patch import use_select_poll_workaround +use_select_poll_workaround() from pack_mgmt.download import DownloadGitRepoAction From 7c507104a716cf226bdcc5ca6108927b15b42b19 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Mon, 19 Feb 2018 15:33:38 +0100 Subject: [PATCH 6/8] Remove unused imports. --- contrib/packs/tests/test_action_download.py | 10 ++-------- contrib/packs/tests/test_action_unload.py | 3 --- st2common/tests/unit/test_pack_management.py | 2 -- 3 files changed, 2 insertions(+), 13 deletions(-) diff --git a/contrib/packs/tests/test_action_download.py b/contrib/packs/tests/test_action_download.py index 376e670891..e18ce64d43 100644 --- a/contrib/packs/tests/test_action_download.py +++ b/contrib/packs/tests/test_action_download.py @@ -16,19 +16,13 @@ # limitations under the License. import os -import sys import mock import shutil import tempfile import hashlib -import subprocess - -import eventlet -# Work around to get tests to pass with eventlet >= 0.20.0 -if 'nose' in sys.modules.keys(): - sys.modules['select'] = eventlet.patcher.original('select') - subprocess.select = eventlet.patcher.original('select') +from st2common.util.monkey_patch import use_select_poll_workaround +use_select_poll_workaround() from lockfile import LockFile from lockfile import LockTimeout diff --git a/contrib/packs/tests/test_action_unload.py b/contrib/packs/tests/test_action_unload.py index e08bf1eb6e..2fe6dbbcec 100644 --- a/contrib/packs/tests/test_action_unload.py +++ b/contrib/packs/tests/test_action_unload.py @@ -16,10 +16,7 @@ # limitations under the License. import os -import sys -import subprocess -import eventlet from oslo_config import cfg from st2common.util.monkey_patch import use_select_poll_workaround diff --git a/st2common/tests/unit/test_pack_management.py b/st2common/tests/unit/test_pack_management.py index 2c0e165be6..0f15b49a60 100644 --- a/st2common/tests/unit/test_pack_management.py +++ b/st2common/tests/unit/test_pack_management.py @@ -17,10 +17,8 @@ import os import sys -import subprocess import unittest2 -import eventlet BASE_DIR = os.path.dirname(os.path.abspath(__file__)) PACK_ACTIONS_DIR = os.path.join(BASE_DIR, '../../../contrib/packs/actions') From 43cb4acba106d05e1924da98c45dacfdc084b17f Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Tue, 20 Feb 2018 10:04:32 +0100 Subject: [PATCH 7/8] Fix broken / invalid test, we were overwritting same key over again. --- contrib/packs/tests/test_action_download.py | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/contrib/packs/tests/test_action_download.py b/contrib/packs/tests/test_action_download.py index e18ce64d43..c951089c09 100644 --- a/contrib/packs/tests/test_action_download.py +++ b/contrib/packs/tests/test_action_download.py @@ -318,18 +318,18 @@ def side_effect(ref): self.repo_instance.commit.side_effect = side_effect - edge_cases = { - 'master': '1.2.3', - 'master': 'some-branch', - 'master': 'default-branch', - 'master': None, - 'default-branch': '1.2.3', - 'default-branch': 'some-branch', - 'default-branch': 'default-branch', - 'default-branch': None - } - - for default_branch, ref in edge_cases.items(): + edge_cases = [ + ('master', '1.2.3'), + ('master', 'some-branch'), + ('master', 'default-branch'), + ('master', None), + ('default-branch', '1.2.3'), + ('default-branch', 'some-branch'), + ('default-branch', 'default-branch'), + ('default-branch', None) + ] + + for default_branch, ref in edge_cases: self.repo_instance.git = mock.MagicMock( branch=(lambda *args: default_branch), checkout=(lambda *args: True) From d2ced5014228783da47895c472daea12b080770f Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Tue, 20 Feb 2018 21:39:28 +0100 Subject: [PATCH 8/8] Add changelog entry. --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 926b2ce9ae..fd8b231a24 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -22,6 +22,7 @@ Changed packages. Also add support for multiple runners (runner modules) inside a single Python package and consolidate Python packages from two to one for the following runners: local runners, remote runners, windows runners. (improvement) #3999 +* Upgrade eventlet library to the latest stable version (0.22.1) (improvement) #4007 Fixed ~~~~~