]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
func: Don't use private method of AsyncProcess
authorJakub Libosvar <libosvar@redhat.com>
Mon, 14 Sep 2015 14:54:34 +0000 (14:54 +0000)
committerJakub Libosvar <libosvar@redhat.com>
Tue, 15 Sep 2015 08:53:57 +0000 (08:53 +0000)
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

neutron/tests/functional/agent/linux/test_async_process.py

index 89c2bec890f254c428a6830faa47b623d5af914c..a1bb40d919db70faa8ee609cc39cc581b3ab891a 100644 (file)
@@ -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)