From f4a76a7a26c0902d61f4fe61091e7fe556923592 Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Mon, 14 Sep 2015 14:54:34 +0000 Subject: [PATCH] func: Don't use private method of AsyncProcess In functional test we simulate crash of AsyncProcess by calling _kill_process(). This method is a private method and such usage introduced a race where process was respawned prior to calling wait() of killed process, leading to infinite wait on newly spawned process. This patch adds manual send of kill and then active waiting for process to be respawned, similarly like done with recent keepalived patch [1]. [1] https://review.openstack.org/#/c/222460/7/neutron/tests/functional/agent/linux/test_keepalived.py Closes-Bug: #1477860 Change-Id: I1c91393304d65a0695311416ecc5b64fd549b192 --- .../tests/functional/agent/linux/test_async_process.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/neutron/tests/functional/agent/linux/test_async_process.py b/neutron/tests/functional/agent/linux/test_async_process.py index 89c2bec89..a1bb40d91 100644 --- a/neutron/tests/functional/agent/linux/test_async_process.py +++ b/neutron/tests/functional/agent/linux/test_async_process.py @@ -15,6 +15,7 @@ import eventlet from neutron.agent.linux import async_process +from neutron.agent.linux import utils from neutron.tests import base @@ -67,5 +68,11 @@ class TestAsyncProcess(AsyncProcessTestFramework): # Ensure that the same output is read twice self._check_stdout(proc) - proc._kill_process(proc.pid) + pid = proc.pid + utils.execute(['kill', '-9', pid]) + utils.wait_until_true( + lambda: proc.is_active() and pid != proc.pid, + timeout=5, + sleep=0.01, + exception=RuntimeError(_("Async process didn't respawn"))) self._check_stdout(proc) -- 2.45.2