Autotest: Use Lab Status to Disable Certain Boards
Now that we have the Lab Status Page up, we would like to make more
use of it by allowing it to be able to disable running new suites
on certain boards.
This becomes useful should a bug starts bringing down DUT's for a
specific subset of boards.
Now the status message should follow the format of:
Lab is 'status' [boards_disabled] (comment)
For example:
Lab is Open [stumpy, kiev, x86-alex] (power_resume bug bringing down
DUT's)
BUG=chromium-os:37346
TEST=local setup
Change-Id: Ib2e4960f8cac427db1606f56477305d82bc110d4
Reviewed-on: https://gerrit.chromium.org/gerrit/40940
Reviewed-by: Scott Zawalski <scottz@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Brian Harring <ferringb@chromium.org>
diff --git a/client/common_lib/error.py b/client/common_lib/error.py
index ca1a2c7..2783fd1 100644
--- a/client/common_lib/error.py
+++ b/client/common_lib/error.py
@@ -565,6 +565,11 @@
pass
+class BoardIsDisabledException(Exception):
+ """Raised when a certain board is disabled in the Lab"""
+ pass
+
+
# This MUST remain at the end of the file.
# Limit 'from error import *' to only import the exception instances.
for _name, _thing in locals().items():
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index 36442d8..f3db295 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -220,20 +220,39 @@
return result
-def check_lab_status():
+def check_lab_status(board=None):
"""Check if the lab is up and if we can schedule suites to run.
+ Also checks if the lab is disabled for that particular board, and if so
+ will raise an error to prevent new suites from being scheduled for that
+ board.
+
+ @param board: board name that we want to check the status of.
+
@raises error.LabIsDownException if the lab is not up.
+ @raises error.BoardIsDisabledException if the desired board is currently
+ disabled.
"""
# Ensure we are trying to schedule on the actual lab.
if not (global_config.global_config.get_config_value('SERVER',
'hostname').startswith('cautotest')):
return
- # TODO (sbasi): crosbug.com/37346 - Currently just check's the lab status.
- # Will be expanded to check status for individual platforms as well.
+ # First check if the lab is up.
lab_status = get_lab_status()
if not lab_status['lab_is_up']:
raise error.LabIsDownException('Chromium OS Lab is currently not up: '
'%s.' % lab_status['message'])
+
+ # Check if the board we wish to use is disabled.
+ # Lab messages should be in the format of:
+ # Lab is 'status' [boards not to be ran] (comment). Example:
+ # Lab is Open [stumpy, kiev, x86-alex] (power_resume rtc causing duts to go
+ # down)
+ boards_are_disabled = re.search('\[(.*)\]', lab_status['message'])
+ if board and boards_are_disabled:
+ if board in boards_are_disabled.group(1):
+ raise error.BoardIsDisabledException('Chromium OS Lab is '
+ 'currently not allowing suites to be scheduled on board '
+ '%s: %s' % (board, lab_status['message']))
return
\ No newline at end of file