[autotest] Suite scheduler files bugs for exceptions raised in create_suite_job
This CL is to make suite scheduler file bugs using our bug filer for
several types of exceptions raised by create_suite_job. The exceptions are:
- ControlFileNotFound
- NoControlFileList
- ControlFileEmpty
- ControlFileMalformed
To enable bug filing, use '-b' option of suite_scheduler.py
Bug will be assgined to Lab sheriff.
This CL changes the private method _create_bug_report to public in
server/cros/dynamic_suite/reporting.py, so that we can file a general
bug that is not a test failure. After crbug.com/254256 is fixed,
the bug filing logic in deduping_scheduler.py should be modified.
This CL also moves ParseBuildName() from base_event.py to site_utils,
to avoid import loop. Callers of this methods are updated.
BUG=chromium:242569
TEST=deduping_scheduler_unittest.py;driver_unittest.py;base_event_unittest.py;
ran on chromeos-lab1.hot and confirm bug are properly filed.
DEPLOY=suite_scheduler
Change-Id: Ia57a2e625b7b39dcfe51892c208613c927f3a54e
Reviewed-on: https://gerrit.chromium.org/gerrit/60158
Commit-Queue: Fang Deng <fdeng@chromium.org>
Reviewed-by: Fang Deng <fdeng@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index 62caf1b..580b6d5 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -22,6 +22,26 @@
LAB_GOOD_STATES = ('open', 'throttled')
+class ParseBuildNameException(Exception):
+ """Raised when ParseBuildName() cannot parse a build name."""
+ pass
+
+
+def ParseBuildName(name):
+ """Format a build name, given board, type, milestone, and manifest num.
+
+ @param name: a build name, e.g. 'x86-alex-release/R20-2015.0.0'
+ @return board: board the manifest is for, e.g. x86-alex.
+ @return type: one of 'release', 'factory', or 'firmware'
+ @return milestone: (numeric) milestone the manifest was associated with.
+ @return manifest: manifest number, e.g. '2015.0.0'
+ """
+ match = re.match(r'([\w-]+)-(\w+)/R(\d+)-([\d.ab-]+)', name)
+ if match and len(match.groups()) == 4:
+ return match.groups()
+ raise ParseBuildNameException('%s is a malformed build name.' % name)
+
+
def ping(host, deadline=None, tries=None, timeout=60):
"""Attempt to ping |host|.