Search Google Storage for trybot image artifacts.
Sometimes trybot jobs fail in the testing phase, but the build
finished and a build artifact exists. To deal with this, instead
of checking the trybot job status, we just search for the build
artifact in google storage. This also removes the
'--chrome_rev=tot' flag from the buildbot command.
Change-Id: I38c07270d774258953d9b1f1e694aba9730ac92b
Reviewed-on: https://chrome-internal-review.googlesource.com/197366
Reviewed-by: Luis Lozano <llozano@chromium.org>
Tested-by: Caroline Tice <cmtice@google.com>
Commit-Queue: Caroline Tice <cmtice@google.com>
diff --git a/utils/buildbot_utils.py b/utils/buildbot_utils.py
index 6bd431b..15b4a8e 100644
--- a/utils/buildbot_utils.py
+++ b/utils/buildbot_utils.py
@@ -36,7 +36,7 @@
data = webpage.read()
lines = data.split('\n')
for l in lines:
- if l.find("Artifacts") and l.find("trybot"):
+ if l.find("Artifacts") > 0 and l.find("trybot") > 0:
trybot_name = "trybot-%s" % build
start_pos = l.find(trybot_name)
end_pos = l.find("@https://storage")
@@ -44,7 +44,6 @@
return trybot_image
-
def GetBuildData (buildbot_queue, build_id):
"""
Find the Reports stage web page for a trybot build.
@@ -118,6 +117,27 @@
return build_log
+def FindArchiveImage(chromeos_root, build, build_id):
+ """
+ Given a build_id, search Google Storage for a trybot artifact
+ for the correct board with the correct build_id. Return the
+ name of the artifact, if found.
+ """
+ ce = command_executer.GetCommandExecuter()
+ command = ("gsutil ls gs://chromeos-image-archive/trybot-%s/*b%s"
+ "/chromiumos_test_image.tar.xz" % (build, build_id))
+ retval, out, err = ce.ChrootRunCommand(chromeos_root, command, return_output=True,
+ print_to_console=False)
+
+ trybot_image = ""
+ trybot_name = "trybot-%s" % build
+ if out and out.find(trybot_name) > 0:
+ start_pos = out.find(trybot_name)
+ end_pos = out.find("/chromiumos_test_image")
+ trybot_image = out[start_pos:end_pos]
+
+ return trybot_image
+
def GetTrybotImage(chromeos_root, buildbot_name, patch_list, build_tag):
"""
Launch buildbot and get resulting trybot artifact name.
@@ -155,7 +175,7 @@
description = build_tag
command = ("./cbuildbot --remote --nochromesdk --notests %s %s"
" --remote-description=%s"
- " --chrome_rev=tot" % (patch_arg, build, description))
+ % (patch_arg, build, description))
ce.RunCommand(command)
os.chdir(base_dir)
@@ -178,7 +198,7 @@
if "True" in data_dict["completed"]:
build_id = data_dict["number"]
- build_status = data_dict["result"]
+ build_status = int(data_dict["result"])
else:
done = False
@@ -191,18 +211,12 @@
if running_time > TIME_OUT:
done = True
- if done and build_status != 0:
- logger.GetLogger().LogError("Trybot job %s failed with status %s."
- % (description, repr(build_status)))
- return ""
- else:
- trybot_image = ""
- # Buildbot has finished. Look for the log and the trybot image.
- if build_id:
- log_name = GetBuildData(build, build_id)
- if log_name:
- trybot_image = ParseReportLog(log_name, build)
+ trybot_image = FindArchiveImage(chromeos_root, build, build_id)
+ if not trybot_image:
+ logger.GetLogger().LogError("Trybot job %s failed with status %d;"
+ " no trybot image generated."
+ % (description, build_status))
- print "trybot_image is '%s'" % trybot_image
- print "build_status is %s" % repr(build_status)
- return trybot_image
+ logger.GetLogger().LogOutput("trybot_image is '%s'" % trybot_image)
+ logger.GetLogger().LogOutput( "build_status is %d" % build_status)
+ return trybot_image