[autotest] Enable polling on and locking hosts in multiple jobs
job_status.wait_*() should handle a list of jobs instead of just one.
BUG=chromium-os:22060
TEST=unit
TEST=run_suite; ensure DUTs get locked during reimage, but that tests still run.
Change-Id: I1bd5dfcd18c61f72717eb00694e35a1265e4bc9b
Reviewed-on: https://gerrit.chromium.org/gerrit/28216
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Chris Sosa <sosa@chromium.org>
Commit-Ready: Chris Masone <cmasone@chromium.org>
diff --git a/server/cros/dynamic_suite_unittest.py b/server/cros/dynamic_suite_unittest.py
index 4078724..752b18e 100755
--- a/server/cros/dynamic_suite_unittest.py
+++ b/server/cros/dynamic_suite_unittest.py
@@ -286,10 +286,10 @@
self.mox.StubOutWithMock(self.reimager, '_count_usable_hosts')
self.mox.StubOutWithMock(self.reimager, '_clear_build_state')
- self.mox.StubOutWithMock(job_status, 'wait_for_job_to_start')
+ self.mox.StubOutWithMock(job_status, 'wait_for_jobs_to_start')
self.mox.StubOutWithMock(job_status, 'wait_for_and_lock_job_hosts')
self.mox.StubOutWithMock(job_status, 'gather_job_hostnames')
- self.mox.StubOutWithMock(job_status, 'wait_for_job_to_finish')
+ self.mox.StubOutWithMock(job_status, 'wait_for_jobs_to_finish')
self.mox.StubOutWithMock(job_status, 'gather_per_host_results')
self.mox.StubOutWithMock(job_status, 'record_and_report_results')
@@ -303,15 +303,15 @@
self.reimager._count_usable_hosts(
mox.IgnoreArg()).AndReturn(self._NUM)
- job_status.wait_for_job_to_start(self.afe, canary_job)
+ job_status.wait_for_jobs_to_start(self.afe, [canary_job])
job_status.wait_for_and_lock_job_hosts(
- self.afe, canary_job, self.manager).AndReturn(statuses.keys())
+ self.afe, [canary_job], self.manager).AndReturn(statuses.keys())
if ex:
- job_status.wait_for_job_to_finish(self.afe, canary_job).AndRaise(ex)
+ job_status.wait_for_jobs_to_finish(self.afe,
+ [canary_job]).AndRaise(ex)
else:
- job_status.wait_for_job_to_finish(
- self.afe, canary_job).AndReturn([canary_job])
+ job_status.wait_for_jobs_to_finish(self.afe, [canary_job])
job_status.gather_per_host_results(
mox.IgnoreArg(), mox.IgnoreArg(), [canary_job],
mox.StrContains(dynamic_suite.REIMAGE_JOB_NAME)).AndReturn(
@@ -327,11 +327,12 @@
def testSuccessfulReimage(self):
"""Should attempt a reimage and record success."""
canary = FakeJob()
- statuses = {canary.hostname: job_status.Status('GOOD', canary.hostname)}
+ statuses = {canary.hostnames[0]: job_status.Status('GOOD',
+ canary.hostnames[0])}
self.expect_attempt(canary, statuses)
rjob = self.mox.CreateMock(base_job.base_job)
- self.reimager._clear_build_state(mox.StrContains(canary.hostname))
+ self.reimager._clear_build_state(mox.StrContains(canary.hostnames[0]))
self.mox.ReplayAll()
self.assertTrue(self.reimager.attempt(self._BUILD, self._BOARD, None,
rjob.record_entry, True,
@@ -342,11 +343,12 @@
def testFailedReimage(self):
"""Should attempt a reimage and record failure."""
canary = FakeJob()
- statuses = {canary.hostname: job_status.Status('FAIL', canary.hostname)}
+ statuses = {canary.hostnames[0]: job_status.Status('FAIL',
+ canary.hostnames[0])}
self.expect_attempt(canary, statuses)
rjob = self.mox.CreateMock(base_job.base_job)
- self.reimager._clear_build_state(mox.StrContains(canary.hostname))
+ self.reimager._clear_build_state(mox.StrContains(canary.hostnames[0]))
self.mox.ReplayAll()
self.assertFalse(self.reimager.attempt(self._BUILD, self._BOARD, None,
rjob.record_entry, True,
@@ -388,11 +390,12 @@
"""Should attempt reimage, ignoring host availability; record success.
"""
canary = FakeJob()
- statuses = {canary.hostname: job_status.Status('GOOD', canary.hostname)}
+ statuses = {canary.hostnames[0]: job_status.Status('GOOD',
+ canary.hostnames[0])}
self.expect_attempt(canary, statuses, check_hosts=False)
rjob = self.mox.CreateMock(base_job.base_job)
- self.reimager._clear_build_state(mox.StrContains(canary.hostname))
+ self.reimager._clear_build_state(mox.StrContains(canary.hostnames[0]))
self.mox.ReplayAll()
self.assertTrue(self.reimager.attempt(self._BUILD, self._BOARD, None,
rjob.record_entry, False,