Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Runs all the buildbot steps for ChromeDriver except for update/compile.""" | 6 """Runs all the buildbot steps for ChromeDriver except for update/compile.""" |
| 7 | 7 |
| 8 import bisect | 8 import bisect |
| 9 import csv | 9 import csv |
| 10 import datetime | 10 import datetime |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 24 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 25 GS_CHROMEDRIVER_BUCKET = 'gs://chromedriver' | 25 GS_CHROMEDRIVER_BUCKET = 'gs://chromedriver' |
| 26 GS_CHROMEDRIVER_DATA_BUCKET = 'gs://chromedriver-data' | 26 GS_CHROMEDRIVER_DATA_BUCKET = 'gs://chromedriver-data' |
| 27 GS_CHROMEDRIVER_RELEASE_URL = 'http://chromedriver.storage.googleapis.com' | 27 GS_CHROMEDRIVER_RELEASE_URL = 'http://chromedriver.storage.googleapis.com' |
| 28 GS_CONTINUOUS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/continuous' | 28 GS_CONTINUOUS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/continuous' |
| 29 GS_PREBUILTS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/prebuilts' | 29 GS_PREBUILTS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/prebuilts' |
| 30 GS_SERVER_LOGS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/server_logs' | 30 GS_SERVER_LOGS_URL = GS_CHROMEDRIVER_DATA_BUCKET + '/server_logs' |
| 31 SERVER_LOGS_LINK = ( | 31 SERVER_LOGS_LINK = ( |
| 32 'http://chromedriver-data.storage.googleapis.com/server_logs') | 32 'http://chromedriver-data.storage.googleapis.com/server_logs') |
| 33 TEST_LOG_FORMAT = '%s_log.json' | 33 TEST_LOG_FORMAT = '%s_log.json' |
| 34 GS_GITHASH_TO_SVN_URL = ( | 34 GS_GIT_LOG_URL = ( |
| 35 'https://chromium.googlesource.com/chromium/src/+/%s?format=json') | 35 'https://chromium.googlesource.com/chromium/src/+/%s?format=json') |
| 36 GS_SEARCH_PATTERN = ( | 36 GS_SEARCH_PATTERN = ( |
| 37 r'.*git-svn-id: svn://svn.chromium.org/chrome/trunk/src@(\d+) ') | 37 r'Cr-Commit-Position: refs/heads/master@{#(\d+)}') |
| 38 CR_REV_URL = 'https://cr-rev.appspot.com/_ah/api/crrev/v1/redirect/%s' | |
| 38 | 39 |
| 39 SCRIPT_DIR = os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, os.pardir, | 40 SCRIPT_DIR = os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, os.pardir, |
| 40 os.pardir, os.pardir, os.pardir, 'scripts') | 41 os.pardir, os.pardir, os.pardir, 'scripts') |
| 41 SITE_CONFIG_DIR = os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, | 42 SITE_CONFIG_DIR = os.path.join(_THIS_DIR, os.pardir, os.pardir, os.pardir, |
| 42 os.pardir, os.pardir, os.pardir, os.pardir, | 43 os.pardir, os.pardir, os.pardir, os.pardir, |
| 43 'site_config') | 44 'site_config') |
| 44 sys.path.append(SCRIPT_DIR) | 45 sys.path.append(SCRIPT_DIR) |
| 45 sys.path.append(SITE_CONFIG_DIR) | 46 sys.path.append(SITE_CONFIG_DIR) |
| 46 | 47 |
| 47 import archive | 48 import archive |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 377 for file_name in os.listdir(tmp_dir): | 378 for file_name in os.listdir(tmp_dir): |
| 378 file_path = os.path.join(tmp_dir, file_name) | 379 file_path = os.path.join(tmp_dir, file_name) |
| 379 if os.path.isdir(file_path): | 380 if os.path.isdir(file_path): |
| 380 print 'deleting sub-directory', file_path | 381 print 'deleting sub-directory', file_path |
| 381 shutil.rmtree(file_path, True) | 382 shutil.rmtree(file_path, True) |
| 382 if file_name.startswith('chromedriver_'): | 383 if file_name.startswith('chromedriver_'): |
| 383 print 'deleting file', file_path | 384 print 'deleting file', file_path |
| 384 os.remove(file_path) | 385 os.remove(file_path) |
| 385 | 386 |
| 386 | 387 |
| 387 def _GetSVNRevisionFromGitHash(snapshot_hashcode): | 388 def _GetCommitPositionFromGitHash(snapshot_hashcode): |
| 388 json_url = GS_GITHASH_TO_SVN_URL % snapshot_hashcode | 389 json_url = GS_GIT_LOG_URL % snapshot_hashcode |
| 389 try: | 390 try: |
| 390 response = urllib2.urlopen(json_url) | 391 response = urllib2.urlopen(json_url) |
| 391 except urllib2.HTTPError as error: | 392 except urllib2.HTTPError as error: |
| 392 util.PrintAndFlush('HTTP Error %d' % error.getcode()) | 393 util.PrintAndFlush('HTTP Error %d' % error.getcode()) |
| 393 except urllib2.URLError as error: | 394 except urllib2.URLError as error: |
| 394 util.PrintAndFlush('URL Error %s' % error.message) | 395 util.PrintAndFlush('URL Error %s' % error.message) |
| 395 return None | 396 return None |
| 396 data = json.loads(response.read()[4:]) | 397 data = json.loads(response.read()[4:]) |
| 397 if 'message' in data: | 398 if 'message' in data: |
| 398 message = data['message'].split('\n') | 399 message = data['message'].split('\n') |
| 399 message = [line for line in message if line.strip()] | 400 message = [line for line in message if line.strip()] |
| 400 search_pattern = re.compile(GS_SEARCH_PATTERN) | 401 search_pattern = re.compile(GS_SEARCH_PATTERN) |
| 401 result = search_pattern.search(message[len(message)-1]) | 402 result = search_pattern.search(message[len(message)-1]) |
| 402 if result: | 403 if result: |
| 403 return result.group(1) | 404 return result.group(1) |
| 404 util.PrintAndFlush('Failed to get svn revision number for %s' % | 405 util.PrintAndFlush('Failed to get svn revision number for %s' % |
| 405 snapshot_hashcode) | 406 snapshot_hashcode) |
| 406 return None | 407 return None |
| 407 | 408 |
| 408 | 409 |
| 410 def _GetGitHashFromCommitPosition(commit_position): | |
| 411 json_url = CR_REV_URL % commit_position | |
| 412 try: | |
| 413 response = urllib2.urlopen(json_url) | |
| 414 except urllib2.HTTPError as error: | |
| 415 util.PrintAndFlush('HTTP Error %d' % error.getcode()) | |
|
stgao
2014/08/25 20:41:27
Why no return?
samuong
2014/08/25 20:51:11
I'm not sure. I was blindly copying and pasting co
| |
| 416 except urllib2.URLError as error: | |
| 417 util.PrintAndFlush('URL Error %s' % error.message) | |
| 418 return None | |
| 419 data = json.loads(response.read()) | |
| 420 if 'git_sha' in data: | |
| 421 return data['git_sha'] | |
| 422 util.PrintAndFlush('Failed to get git hash for %s' % commit_position) | |
| 423 return None | |
| 424 | |
| 425 | |
| 409 def _WaitForLatestSnapshot(revision): | 426 def _WaitForLatestSnapshot(revision): |
| 410 util.MarkBuildStepStart('wait_for_snapshot') | 427 util.MarkBuildStepStart('wait_for_snapshot') |
| 411 def _IsRevisionNumber(revision): | 428 def _IsRevisionNumber(revision): |
| 412 if isinstance(revision, int): | 429 if isinstance(revision, int): |
| 413 return True | 430 return True |
| 414 else: | 431 else: |
| 415 return revision.isdigit() | 432 return revision.isdigit() |
| 416 while True: | 433 while True: |
| 417 snapshot_revision = archive.GetLatestSnapshotVersion() | 434 snapshot_revision = archive.GetLatestSnapshotVersion() |
| 418 if not _IsRevisionNumber(revision): | |
| 419 revision = _GetSVNRevisionFromGitHash(revision) | |
| 420 if not _IsRevisionNumber(snapshot_revision): | 435 if not _IsRevisionNumber(snapshot_revision): |
| 421 snapshot_revision = _GetSVNRevisionFromGitHash(snapshot_revision) | 436 snapshot_revision = _GetCommitPositionFromGitHash(snapshot_revision) |
| 422 if revision is not None and snapshot_revision is not None: | 437 if revision is not None and snapshot_revision is not None: |
| 423 if int(snapshot_revision) >= int(revision): | 438 if int(snapshot_revision) >= int(revision): |
| 424 break | 439 break |
| 425 util.PrintAndFlush('Waiting for snapshot >= %s, found %s' % | 440 util.PrintAndFlush('Waiting for snapshot >= %s, found %s' % |
| 426 (revision, snapshot_revision)) | 441 (revision, snapshot_revision)) |
| 427 time.sleep(60) | 442 time.sleep(60) |
| 428 util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision) | 443 util.PrintAndFlush('Got snapshot revision %s' % snapshot_revision) |
| 429 | 444 |
| 430 | 445 |
| 431 def _AddToolsToPath(platform_name): | 446 def _AddToolsToPath(platform_name): |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 457 os.environ['PATH'] += os.pathsep + os.pathsep.join(paths) | 472 os.environ['PATH'] += os.pathsep + os.pathsep.join(paths) |
| 458 | 473 |
| 459 | 474 |
| 460 def main(): | 475 def main(): |
| 461 parser = optparse.OptionParser() | 476 parser = optparse.OptionParser() |
| 462 parser.add_option( | 477 parser.add_option( |
| 463 '', '--android-packages', | 478 '', '--android-packages', |
| 464 help=('Comma separated list of application package names, ' | 479 help=('Comma separated list of application package names, ' |
| 465 'if running tests on Android.')) | 480 'if running tests on Android.')) |
| 466 parser.add_option( | 481 parser.add_option( |
| 467 '-r', '--revision', type='int', help='Chromium revision') | 482 '-r', '--revision', help='Chromium revision') |
| 468 parser.add_option( | 483 parser.add_option( |
| 469 '', '--update-log', action='store_true', | 484 '', '--update-log', action='store_true', |
| 470 help='Update the test results log (only applicable to Android)') | 485 help='Update the test results log (only applicable to Android)') |
| 471 options, _ = parser.parse_args() | 486 options, _ = parser.parse_args() |
| 472 | 487 |
| 473 bitness = '32' | 488 bitness = '32' |
| 474 if util.IsLinux() and platform_module.architecture()[0] == '64bit': | 489 if util.IsLinux() and platform_module.architecture()[0] == '64bit': |
| 475 bitness = '64' | 490 bitness = '64' |
| 476 platform = '%s%s' % (util.GetPlatformName(), bitness) | 491 platform = '%s%s' % (util.GetPlatformName(), bitness) |
| 477 if options.android_packages: | 492 if options.android_packages: |
| 478 platform = 'android' | 493 platform = 'android' |
| 479 | 494 |
| 480 _CleanTmpDir() | 495 _CleanTmpDir() |
| 481 | 496 |
| 497 if not options.revision: | |
| 498 commit_position = None | |
|
stgao
2014/08/25 20:41:27
In this case, I think we should fail the test. Bec
samuong
2014/08/25 20:51:11
I was trying to maintain the script's original beh
stgao
2014/08/25 23:17:12
OK. Sound good.
| |
| 499 elif options.revision.isdigit(): | |
| 500 commit_position = options.revision | |
| 501 else: | |
| 502 commit_position = _GetCommitPositionFromGitHash(options.revision) | |
| 503 | |
| 482 if platform == 'android': | 504 if platform == 'android': |
| 483 if not options.revision and options.update_log: | 505 if not options.revision and options.update_log: |
| 484 parser.error('Must supply a --revision with --update-log') | 506 parser.error('Must supply a --revision with --update-log') |
| 485 _DownloadPrebuilts() | 507 _DownloadPrebuilts() |
| 486 else: | 508 else: |
| 487 if not options.revision: | 509 if not options.revision: |
| 488 parser.error('Must supply a --revision') | 510 parser.error('Must supply a --revision') |
| 489 if platform == 'linux64': | 511 if platform == 'linux64': |
| 490 _ArchivePrebuilts(options.revision) | 512 _ArchivePrebuilts(commit_position) |
| 491 _WaitForLatestSnapshot(options.revision) | 513 _WaitForLatestSnapshot(commit_position) |
| 492 | 514 |
| 493 _AddToolsToPath(platform) | 515 _AddToolsToPath(platform) |
| 494 | 516 |
| 495 cmd = [ | 517 cmd = [ |
| 496 sys.executable, | 518 sys.executable, |
| 497 os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'), | 519 os.path.join(_THIS_DIR, 'test', 'run_all_tests.py'), |
| 498 ] | 520 ] |
| 499 if platform == 'android': | 521 if platform == 'android': |
| 500 cmd.append('--android-packages=' + options.android_packages) | 522 cmd.append('--android-packages=' + options.android_packages) |
| 501 | 523 |
| 502 passed = (util.RunCommand(cmd) == 0) | 524 passed = (util.RunCommand(cmd) == 0) |
| 503 | 525 |
| 504 _ArchiveServerLogs() | 526 _ArchiveServerLogs() |
| 505 | 527 |
| 506 if platform == 'android': | 528 if platform == 'android': |
| 507 if options.update_log: | 529 if options.update_log: |
| 508 util.MarkBuildStepStart('update test result log') | 530 util.MarkBuildStepStart('update test result log') |
| 509 _UpdateTestResultsLog(platform, options.revision, passed) | 531 _UpdateTestResultsLog(platform, commit_position, passed) |
| 510 elif passed: | 532 elif passed: |
| 511 _ArchiveGoodBuild(platform, options.revision) | 533 _ArchiveGoodBuild(platform, commit_position) |
| 512 _MaybeRelease(platform) | 534 _MaybeRelease(platform) |
| 513 | 535 |
| 514 if not passed: | 536 if not passed: |
| 515 # Make sure the build is red if there is some uncaught exception during | 537 # Make sure the build is red if there is some uncaught exception during |
| 516 # running run_all_tests.py. | 538 # running run_all_tests.py. |
| 517 util.MarkBuildStepStart('run_all_tests.py') | 539 util.MarkBuildStepStart('run_all_tests.py') |
| 518 util.MarkBuildStepError() | 540 util.MarkBuildStepError() |
| 519 | 541 |
| 520 # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py | 542 # Add a "cleanup" step so that errors from runtest.py or bb_device_steps.py |
| 521 # (which invoke this script) are kept in thier own build step. | 543 # (which invoke this script) are kept in thier own build step. |
| 522 util.MarkBuildStepStart('cleanup') | 544 util.MarkBuildStepStart('cleanup') |
| 523 | 545 |
| 524 | 546 |
| 525 if __name__ == '__main__': | 547 if __name__ == '__main__': |
| 526 main() | 548 main() |
| OLD | NEW |