Commit e84ed4a9 authored by samuong's avatar samuong Committed by Commit bot

[chromedriver] Fix git migration issue and remove svn support from run_buildbot_steps.py

BUG=418590
NOTRY=true

Review URL: https://codereview.chromium.org/615563003

Cr-Commit-Position: refs/heads/master@{#297453}
parent 86026521
...@@ -52,14 +52,14 @@ from slave import slave_utils ...@@ -52,14 +52,14 @@ from slave import slave_utils
import util import util
def _ArchivePrebuilts(revision): def _ArchivePrebuilts(commit_position):
"""Uploads the prebuilts to google storage.""" """Uploads the prebuilts to google storage."""
util.MarkBuildStepStart('archive prebuilts') util.MarkBuildStepStart('archive prebuilts')
zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir(['chromedriver']), zip_path = util.Zip(os.path.join(chrome_paths.GetBuildDir(['chromedriver']),
'chromedriver')) 'chromedriver'))
if slave_utils.GSUtilCopy( if slave_utils.GSUtilCopy(
zip_path, zip_path,
'%s/%s' % (GS_PREBUILTS_URL, 'r%s.zip' % revision)): '%s/%s' % (GS_PREBUILTS_URL, 'r%s.zip' % commit_position)):
util.MarkBuildStepError() util.MarkBuildStepError()
...@@ -96,7 +96,7 @@ def _GetTestResultsLog(platform): ...@@ -96,7 +96,7 @@ def _GetTestResultsLog(platform):
platform: The platform that the test results log is for. platform: The platform that the test results log is for.
Returns: Returns:
A dictionary where the keys are SVN revisions and the values are booleans A dictionary where the keys are commit positions and the values are booleans
indicating whether the tests passed. indicating whether the tests passed.
""" """
temp_log = tempfile.mkstemp()[1] temp_log = tempfile.mkstemp()[1]
...@@ -122,20 +122,23 @@ def _PutTestResultsLog(platform, test_results_log): ...@@ -122,20 +122,23 @@ def _PutTestResultsLog(platform, test_results_log):
raise Exception('Failed to upload test results log to google storage') raise Exception('Failed to upload test results log to google storage')
def _UpdateTestResultsLog(platform, revision, passed): def _UpdateTestResultsLog(platform, commit_position, passed):
"""Updates the test results log for the given platform. """Updates the test results log for the given platform.
Args: Args:
platform: The platform name. platform: The platform name.
revision: The SVN revision number. commit_position: The commit position number.
passed: Boolean indicating whether the tests passed at this revision. passed: Boolean indicating whether the tests passed at this commit position.
""" """
assert isinstance(revision, int), 'The revision must be an integer'
assert commit_position.isdigit(), 'The commit position must be a number'
commit_position = int(commit_position)
log = _GetTestResultsLog(platform) log = _GetTestResultsLog(platform)
if len(log) > 500: if len(log) > 500:
del log[min(log.keys())] del log[min(log.keys())]
assert revision not in log, 'Results already exist for revision %s' % revision assert commit_position not in log, \
log[revision] = bool(passed) 'Results already exist for commit position %s' % commit_position
log[commit_position] = bool(passed)
_PutTestResultsLog(platform, log) _PutTestResultsLog(platform, log)
...@@ -163,39 +166,39 @@ def _GetSupportedChromeVersions(): ...@@ -163,39 +166,39 @@ def _GetSupportedChromeVersions():
return (chrome_min_version, chrome_max_version) return (chrome_min_version, chrome_max_version)
def _RevisionState(test_results_log, revision): def _CommitPositionState(test_results_log, commit_position):
"""Check the state of tests at a given SVN revision. """Check the state of tests at a given commit position.
Considers tests as having passed at a revision if they passed at revisons both Considers tests as having passed at a commit position if they passed at
before and after. revisons both before and after.
Args: Args:
test_results_log: A test results log dictionary from _GetTestResultsLog(). test_results_log: A test results log dictionary from _GetTestResultsLog().
revision: The revision to check at. commit_position: The commit position to check at.
Returns: Returns:
'passed', 'failed', or 'unknown' 'passed', 'failed', or 'unknown'
""" """
assert isinstance(revision, int), 'The revision must be an integer' assert isinstance(commit_position, int), 'The commit position must be an int'
keys = sorted(test_results_log.keys()) keys = sorted(test_results_log.keys())
# Return passed if the exact revision passed on Android. # Return passed if the exact commit position passed on Android.
if revision in test_results_log: if commit_position in test_results_log:
return 'passed' if test_results_log[revision] else 'failed' return 'passed' if test_results_log[commit_position] else 'failed'
# Tests were not run on this exact revision on Android. # Tests were not run on this exact commit position on Android.
index = bisect.bisect_right(keys, revision) index = bisect.bisect_right(keys, commit_position)
# Tests have not yet run on Android at or above this revision. # Tests have not yet run on Android at or above this commit position.
if index == len(test_results_log): if index == len(test_results_log):
return 'unknown' return 'unknown'
# No log exists for any prior revision, assume it failed. # No log exists for any prior commit position, assume it failed.
if index == 0: if index == 0:
return 'failed' return 'failed'
# Return passed if the revisions on both sides passed. # Return passed if the commit position on both sides passed.
if test_results_log[keys[index]] and test_results_log[keys[index - 1]]: if test_results_log[keys[index]] and test_results_log[keys[index - 1]]:
return 'passed' return 'passed'
return 'failed' return 'failed'
def _ArchiveGoodBuild(platform, revision): def _ArchiveGoodBuild(platform, commit_position):
"""Archive chromedriver binary if the build is green.""" """Archive chromedriver binary if the build is green."""
assert platform != 'android' assert platform != 'android'
util.MarkBuildStepStart('archive build') util.MarkBuildStepStart('archive build')
...@@ -207,7 +210,7 @@ def _ArchiveGoodBuild(platform, revision): ...@@ -207,7 +210,7 @@ def _ArchiveGoodBuild(platform, revision):
server_name)) server_name))
build_name = 'chromedriver_%s_%s.%s.zip' % ( build_name = 'chromedriver_%s_%s.%s.zip' % (
platform, _GetVersion(), revision) platform, _GetVersion(), commit_position)
build_url = '%s/%s' % (GS_CONTINUOUS_URL, build_name) build_url = '%s/%s' % (GS_CONTINUOUS_URL, build_name)
if slave_utils.GSUtilCopy(zip_path, build_url): if slave_utils.GSUtilCopy(zip_path, build_url):
util.MarkBuildStepError() util.MarkBuildStepError()
...@@ -262,17 +265,19 @@ def _MaybeRelease(platform): ...@@ -262,17 +265,19 @@ def _MaybeRelease(platform):
# In this way, if a hot fix is needed, we can delete the release from # In this way, if a hot fix is needed, we can delete the release from
# the chromedriver bucket instead of bumping up the release version number. # the chromedriver bucket instead of bumping up the release version number.
candidates.sort(reverse=True) candidates.sort(reverse=True)
for revision in candidates: for commit_position in candidates:
android_result = _RevisionState(android_test_results, revision) android_result = _CommitPositionState(android_test_results, commit_position)
if android_result == 'failed': if android_result == 'failed':
print 'Android tests did not pass at revision', revision print 'Android tests did not pass at commit position', commit_position
elif android_result == 'passed': elif android_result == 'passed':
print 'Android tests passed at revision', revision print 'Android tests passed at commit position', commit_position
candidate = 'chromedriver_%s_%s.%s.zip' % (platform, version, revision) candidate = 'chromedriver_%s_%s.%s.zip' % (
platform, version, commit_position)
_Release('%s/%s' % (GS_CONTINUOUS_URL, candidate), version, platform) _Release('%s/%s' % (GS_CONTINUOUS_URL, candidate), version, platform)
break break
else: else:
print 'Android tests have not run at a revision as recent as', revision print 'Android tests have not run at a commit position as recent as', \
commit_position
def _Release(build, version, platform): def _Release(build, version, platform):
...@@ -403,7 +408,7 @@ def _GetCommitPositionFromGitHash(snapshot_hashcode): ...@@ -403,7 +408,7 @@ def _GetCommitPositionFromGitHash(snapshot_hashcode):
result = search_pattern.search(message[len(message)-1]) result = search_pattern.search(message[len(message)-1])
if result: if result:
return result.group(1) return result.group(1)
util.PrintAndFlush('Failed to get svn revision number for %s' % util.PrintAndFlush('Failed to get commit position number for %s' %
snapshot_hashcode) snapshot_hashcode)
return None return None
...@@ -425,24 +430,17 @@ def _GetGitHashFromCommitPosition(commit_position): ...@@ -425,24 +430,17 @@ def _GetGitHashFromCommitPosition(commit_position):
return None return None
def _WaitForLatestSnapshot(revision): def _WaitForLatestSnapshot(commit_position):
util.MarkBuildStepStart('wait_for_snapshot') util.MarkBuildStepStart('wait_for_snapshot')
def _IsRevisionNumber(revision):
if isinstance(revision, int):
return True
else:
return revision.isdigit()
while True: while True:
snapshot_revision = archive.GetLatestSnapshotVersion() snapshot_position = archive.GetLatestSnapshotVersion()
if not _IsRevisionNumber(snapshot_revision): if commit_position is not None and snapshot_position is not None:
snapshot_revision = _GetCommitPositionFromGitHash(snapshot_revision) if int(snapshot_position) >= int(commit_position):
if revision is not None and snapshot_revision is not None:
if int(snapshot_revision) >= int(revision):
break break
util.PrintAndFlush('Waiting for snapshot >= %s, found %s' % util.PrintAndFlush('Waiting for snapshot >= %s, found %s' %
(revision, snapshot_revision)) (commit_position, snapshot_position))
time.sleep(60) time.sleep(60)
util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision) util.PrintAndFlush('Got snapshot commit position %s' % snapshot_position)
def _AddToolsToPath(platform_name): def _AddToolsToPath(platform_name):
...@@ -481,7 +479,7 @@ def main(): ...@@ -481,7 +479,7 @@ def main():
help=('Comma separated list of application package names, ' help=('Comma separated list of application package names, '
'if running tests on Android.')) 'if running tests on Android.'))
parser.add_option( parser.add_option(
'-r', '--revision', help='Chromium revision') '-r', '--revision', help='Chromium git revision hash')
parser.add_option( parser.add_option(
'', '--update-log', action='store_true', '', '--update-log', action='store_true',
help='Update the test results log (only applicable to Android)') help='Update the test results log (only applicable to Android)')
...@@ -498,8 +496,6 @@ def main(): ...@@ -498,8 +496,6 @@ def main():
if not options.revision: if not options.revision:
commit_position = None commit_position = None
elif options.revision.isdigit():
commit_position = options.revision
else: else:
commit_position = _GetCommitPositionFromGitHash(options.revision) commit_position = _GetCommitPositionFromGitHash(options.revision)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment