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: <greenlet.greenlet object at 0x7fd975681cd0>

Change-Id: I72e11a67cf1cd3ff3fbc574f2d6e91df17d63d9c
This commit is contained in:
Eric K 2019-04-05 17:51:59 -07:00
parent 8a54c3c193
commit 31e7e04294
1 changed files with 4 additions and 1 deletions

View File

@ -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"]',