diff options
author | Matthew Sartori <msartori@chromium.org> | 2015-06-30 14:22:13 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-07-01 03:49:19 +0000 |
commit | a44286e687040526ae24462f8cb7744dc3fcab8e (patch) | |
tree | 66f39e0948f84d8c53bcb89a5dcefd3d2b7c6395 /mobmonitor | |
parent | 4778310cb290b5468e22f233188325f363e03323 (diff) | |
download | chromite-a44286e687040526ae24462f8cb7744dc3fcab8e.tar.gz |
mobmonitor: Correction for flaky test.
The Mob* Monitor has a unittest that verifies restart
behaviour when source files change. The unittest attempts
to spawn the monitor as a subprocess inside of a thread.
The flakiness seems to arise when the thread attempts to
join but the subprocess hasn't terminated.
This CL adds additional checks to make sure the subprocess
is dead before joining.
BUG=chromium:505918
TEST=Unittests.
Change-Id: I82aecd86656a7c5845277e4353c130d7bc9df961
Reviewed-on: https://chromium-review.googlesource.com/282762
Tested-by: Matthew Sartori <msartori@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Commit-Queue: Matthew Sartori <msartori@chromium.org>
Diffstat (limited to 'mobmonitor')
-rw-r--r-- | mobmonitor/checkfile/manager_unittest.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mobmonitor/checkfile/manager_unittest.py b/mobmonitor/checkfile/manager_unittest.py index bfc65436f..b619420b9 100644 --- a/mobmonitor/checkfile/manager_unittest.py +++ b/mobmonitor/checkfile/manager_unittest.py @@ -178,19 +178,26 @@ class RunCommand(threading.Thread): self.timeout = timeout self.p = None + self.proc_stdout = None + self.proc_stderr = None + def run(self): self.p = subprocess.Popen(self.cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - self.p.wait() + self.proc_stdout, self.proc_stderr = self.p.communicate() def Stop(self): self.join(self.timeout) if self.is_alive(): self.p.terminate() - self.join() + self.join(self.timeout) + + if self.is_alive(): + self.p.kill() + self.join(self.timeout) - return self.p.stdout.read() + return self.proc_stdout class CheckFileManagerHelperTest(cros_test_lib.MockTestCase): |