diff options
author | Ting-Yuan Huang <laszio@chromium.org> | 2017-04-24 20:34:43 -0700 |
---|---|---|
committer | Manoj Gupta <manojgupta@chromium.org> | 2017-04-25 05:23:19 +0000 |
commit | 99d32c4981138fd11e6b351b6be9311932293464 (patch) | |
tree | 0d2ab38d3643ee1b5de7122d154e18af9bdaaceb /cros_utils/buildbot_utils.py | |
parent | 4ed81bc349a55c918ae59c7dbe3be0d489d9004c (diff) | |
download | toolchain-utils-99d32c4981138fd11e6b351b6be9311932293464.tar.gz |
buildbot_test_toolchains: get latest instead green vanilla build
So as to work around the problem that some builders' latest green
builds are too old.
BUG=chromium:714890
TEST=Tested _GetVanillaImageName locally.
Change-Id: I06571f3d55743fb56977d7ef56a51fcddfdda62e
Reviewed-on: https://chromium-review.googlesource.com/486086
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Ting-Yuan Huang <laszio@chromium.org>
Tested-by: Ting-Yuan Huang <laszio@chromium.org>
Trybot-Ready: Ting-Yuan Huang <laszio@chromium.org>
Diffstat (limited to 'cros_utils/buildbot_utils.py')
-rw-r--r-- | cros_utils/buildbot_utils.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cros_utils/buildbot_utils.py b/cros_utils/buildbot_utils.py index d24ba0d3..f89bb71a 100644 --- a/cros_utils/buildbot_utils.py +++ b/cros_utils/buildbot_utils.py @@ -8,6 +8,7 @@ from __future__ import print_function import base64 import json import os +import re import time import urllib2 @@ -388,3 +389,22 @@ def WaitForImage(chromeos_root, build): logger.GetLogger().LogOutput('Image %s not found, waited for %d hours' % (build, (TIME_OUT / 3600))) raise BuildbotTimeout('Timeout while waiting for image %s' % build) + + +def GetLatestImage(chromeos_root, path): + """Get latest image""" + + fmt = re.compile(r'R([0-9]+)-([0-9]+).([0-9]+).([0-9]+)') + + ce = command_executer.GetCommandExecuter() + command = ('gsutil ls gs://chromeos-image-archive/%s' % path) + _, out, _ = ce.ChrootRunCommandWOutput( + chromeos_root, command, print_to_console=False) + candidates = [l.split('/')[-2] for l in out.split()] + candidates = map(fmt.match, candidates) + candidates = [[int(r) for r in m.group(1, 2, 3, 4)] for m in candidates if m] + candidates.sort(reverse=True) + for c in candidates: + build = '%s/R%d-%d.%d.%d' % (path, c[0], c[1], c[2], c[3]) + if DoesImageExist(chromeos_root, build): + return build |