From 31e7e04294a9c4e7f8e1ce64d57b28c677f3758a Mon Sep 17 00:00:00 2001 From: Eric K Date: Fri, 5 Apr 2019 17:51:59 -0700 Subject: [PATCH] Resolve instability in json_ingester test_execute_exec_api_rows Occassionally the unit test congress.tests.datasources.json_ingester. test_exec_api.TestExecApiManager.test_execute_exec_api_rows fails inside eventlet code even though the eventlet call is mocked out. This patch adds a new mock path because eventlet.spawn_n somehow redirects there. Hopefully it resolves the occassional instability gets. Sample error: File "/home/zuul/src/git.openstack.org/openstack/congress/.tox/py27/local/lib/python2.7/site-packages/eventlet/greenpool.py", line 115, in spawn_n function, args, kwargs, True) File "/home/zuul/src/git.openstack.org/openstack/congress/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1062, in __call__ return _mock_self._mock_call(*args, **kwargs) File "/home/zuul/src/git.openstack.org/openstack/congress/.tox/py27/local/lib/python2.7/site-packages/mock/mock.py", line 1128, in _mock_call ret_val = effect(*args, **kwargs) File "congress/tests/datasources/json_ingester/test_exec_api.py", line 27, in mock_spawn_execute return func(*args, **kwargs) File "/home/zuul/src/git.openstack.org/openstack/congress/.tox/py27/local/lib/python2.7/site-packages/eventlet/greenpool.py", line 99, in _spawn_n_impl self._spawn_done(coro) File "/home/zuul/src/git.openstack.org/openstack/congress/.tox/py27/local/lib/python2.7/site-packages/eventlet/greenpool.py", line 131, in _spawn_done self.coroutines_running.remove(coro) KeyError: Change-Id: I72e11a67cf1cd3ff3fbc574f2d6e91df17d63d9c --- congress/tests/datasources/json_ingester/test_exec_api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/congress/tests/datasources/json_ingester/test_exec_api.py b/congress/tests/datasources/json_ingester/test_exec_api.py index bf4cf2b65..43c5c52a9 100644 --- a/congress/tests/datasources/json_ingester/test_exec_api.py +++ b/congress/tests/datasources/json_ingester/test_exec_api.py @@ -158,8 +158,11 @@ class TestExecApiManager(base.TestCase): self.test_exec_mgr._execute_exec_api_rows.assert_called_once_with( test_rows2 - test_rows1) + @mock.patch('eventlet.greenpool.GreenPool.spawn_n', + side_effect=mock_spawn_execute) + # Note: Adding the above mock because eventlet.spawn_n redirects there @mock.patch('eventlet.spawn_n', side_effect=mock_spawn_execute) - def test_execute_exec_api_rows(self, mock_spawn): + def test_execute_exec_api_rows(self, mock_spawn, mock_spawn2): test_row1 = ('test1', 'path1', 'method1', '["body1"]', '["params1"]', '["headers1"]') test_row2a = ('test2', 'path2a', 'method2a', '["body2a"]',