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
This commit is contained in:
parent
d82827f179
commit
9049c32c7c
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue