Wait for the watch process in test case

Because the _watch_process and the failing_process are asynchronous,
there might be a chance that failing_process exit and _watch_process
is not executed.

If the _watch_process is blocked, the method that will be asserted
will not be called. This will fail the UT, but it is intermittent.

Change-Id: Ic951c1b91c5a10462f548544a5e8d482c52ad665
Closes-Bug: #1519160
Related-Bug: #1543040
Related Bug: #1506021
(cherry picked from commit dcd0498c17)
This commit is contained in:
Hong Hui Xiao 2015-11-24 09:01:48 -05:00 committed by Nir Magnezi
parent e43f6d4960
commit 306636e64d
1 changed files with 3 additions and 0 deletions

View File

@ -291,4 +291,7 @@ class TestFailingAsyncProcess(base.BaseTestCase):
as handle_error_mock:
self.process.start()
self.process._process.wait()
# Wait for the monitor process to complete
for thread in self.process._watchers:
thread.wait()
self.assertEqual(1, handle_error_mock.call_count)