From 9049c32c7c7314e05250551807b4164082da4695 Mon Sep 17 00:00:00 2001 From: Attila Czira Date: Fri, 17 Mar 2017 11:43:11 +0100 Subject: [PATCH] Stabilizing process monitor function test case The problem seems to be that the TC is starting new processes parallelly but it does not wait for them to start properly instead it tries to kill one of them immediately but in some cases if the startup phase is delayed the process that is about to be killed is not started yet. The fix is to introduce a waiting phase until all the child processes are up and running right after the initial spawning phase. As the problem is not functional the fix is difficult to test. I executed this TC in a loop with this fix for a 5000 times and the problem has not appeared. Without the fix I had 3.8% failure rate. Change-Id: I19a8a4c35efc35a002478204fd24910d73c9c8c2 closes-bug: #1513771 --- .../tests/functional/agent/linux/test_process_monitor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neutron/tests/functional/agent/linux/test_process_monitor.py b/neutron/tests/functional/agent/linux/test_process_monitor.py index 03a06beae2c..145b8aa9ca9 100644 --- a/neutron/tests/functional/agent/linux/test_process_monitor.py +++ b/neutron/tests/functional/agent/linux/test_process_monitor.py @@ -76,7 +76,7 @@ class BaseTestProcessMonitor(base.BaseTestCase): def _kill_last_child(self): self._child_processes[-1].disable() - def wait_for_all_children_respawned(self): + def wait_for_all_children_spawned(self): def all_children_active(): return all(pm.active for pm in self._child_processes) @@ -93,7 +93,7 @@ class BaseTestProcessMonitor(base.BaseTestCase): all_children_active, timeout=max_wait_time, sleep=0.01, - exception=RuntimeError('Not all children respawned.')) + exception=RuntimeError('Not all children (re)spawned.')) def cleanup_spawned_children(self): self._process_monitor.stop() @@ -105,5 +105,6 @@ class TestProcessMonitor(BaseTestProcessMonitor): def test_respawn_handler(self): self.spawn_n_children(2) + self.wait_for_all_children_spawned() self._kill_last_child() - self.wait_for_all_children_respawned() + self.wait_for_all_children_spawned()