[autotest] Fix test.CanRun() failures.
Previous code assumed that GetHosts would return |[]| instead of |None|
that actually is returned if no matching hosts were found. Made CanRun
return the list of hosts that match the board and pool requirement, and
then renamed CanRun to AvailableHosts to match its new functionality.
BUG=chromium-os:32436
TEST=unit
Change-Id: I84ae0a31c0dc123ad5cf2187b99ea6cbefbabce8
Reviewed-on: https://gerrit.chromium.org/gerrit/27043
Tested-by: Alex Miller <milleral@chromium.org>
Reviewed-by: Chris Masone <cmasone@chromium.org>
Commit-Ready: Alex Miller <milleral@chromium.org>
diff --git a/site_utils/suite_scheduler/task.py b/site_utils/suite_scheduler/task.py
index 346989e..3935946 100644
--- a/site_utils/suite_scheduler/task.py
+++ b/site_utils/suite_scheduler/task.py
@@ -204,20 +204,20 @@
return hash(str(self))
- def CanRun(self, scheduler, board):
- """Check and see if this test is able to be scheduled on this board.
+ def AvailableHosts(self, scheduler, board):
+ """Query what hosts are able to run a test on a board and pool
+ combination.
@param scheduler: an instance of DedupingScheduler, as defined in
deduping_scheduler.py
@param board: the board against which one wants to run the test.
- @return True if the test can be successfully scheduled, false if
- scheduling the test will result in the test never being run."""
+ @return The list of hosts meeting the board and pool requirements,
+ or None if no hosts were found."""
labels = [Labels.BOARD_PREFIX + board]
if self._pool:
labels.append(Labels.POOL_PREFIX + self._pool)
- hosts = scheduler.GetHosts(multiple_labels=labels)
- return len(hosts) != 0
+ return scheduler.GetHosts(multiple_labels=labels)
def Run(self, scheduler, branch_builds, board, force=False):