| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import argparse | 4 import argparse |
| 5 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import StringIO | 8 import StringIO |
| 9 import sys | 9 import sys |
| 10 import tempfile |
| 10 import unittest | 11 import unittest |
| 11 | 12 |
| 12 from core import trybot_command | 13 from core import trybot_command |
| 13 import mock | 14 import mock |
| 14 from telemetry import benchmark | 15 from telemetry import benchmark |
| 15 | 16 |
| 16 | 17 |
| 17 class FakeProcess(object): | 18 class FakeProcess(object): |
| 18 | 19 |
| 19 def __init__(self, expected_responses): | 20 def __init__(self, expected_responses): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 32 # pylint: disable=protected-access | 33 # pylint: disable=protected-access |
| 33 | 34 |
| 34 def setUp(self): | 35 def setUp(self): |
| 35 self.log_output = StringIO.StringIO() | 36 self.log_output = StringIO.StringIO() |
| 36 self.stream_handler = logging.StreamHandler(self.log_output) | 37 self.stream_handler = logging.StreamHandler(self.log_output) |
| 37 logging.getLogger().addHandler(self.stream_handler) | 38 logging.getLogger().addHandler(self.stream_handler) |
| 38 self._subprocess_patcher = mock.patch('core.trybot_command.subprocess') | 39 self._subprocess_patcher = mock.patch('core.trybot_command.subprocess') |
| 39 self._mock_subprocess = self._subprocess_patcher.start() | 40 self._mock_subprocess = self._subprocess_patcher.start() |
| 40 self._urllib2_patcher = mock.patch('core.trybot_command.urllib2') | 41 self._urllib2_patcher = mock.patch('core.trybot_command.urllib2') |
| 41 self._urllib2_mock = self._urllib2_patcher.start() | 42 self._urllib2_mock = self._urllib2_patcher.start() |
| 43 self._tempfile_patcher = mock.patch('core.trybot_command.tempfile') |
| 44 self._tempfile_mock = self._tempfile_patcher.start() |
| 42 # Always set git command to 'git' to simplify testing across platforms. | 45 # Always set git command to 'git' to simplify testing across platforms. |
| 43 self._original_git_cmd = trybot_command._GIT_CMD | 46 self._original_git_cmd = trybot_command._GIT_CMD |
| 44 trybot_command._GIT_CMD = 'git' | 47 trybot_command._GIT_CMD = 'git' |
| 45 | 48 |
| 46 def tearDown(self): | 49 def tearDown(self): |
| 47 logging.getLogger().removeHandler(self.stream_handler) | 50 logging.getLogger().removeHandler(self.stream_handler) |
| 48 self.log_output.close() | 51 self.log_output.close() |
| 49 self._subprocess_patcher.stop() | 52 self._subprocess_patcher.stop() |
| 50 self._urllib2_patcher.stop() | 53 self._urllib2_patcher.stop() |
| 54 self._tempfile_patcher.stop() |
| 51 # Reset the cached builders in trybot_command | 55 # Reset the cached builders in trybot_command |
| 52 trybot_command.Trybot._builders = None | 56 trybot_command.Trybot._builders = None |
| 53 trybot_command._GIT_CMD = self._original_git_cmd | 57 trybot_command._GIT_CMD = self._original_git_cmd |
| 54 | 58 |
| 55 def _ExpectProcesses(self, expected_args_list): | 59 def _ExpectProcesses(self, expected_args_list): |
| 56 counter = [-1] | 60 counter = [-1] |
| 57 def side_effect(args, **kwargs): | 61 def side_effect(args, **kwargs): |
| 58 if not expected_args_list: | 62 if not expected_args_list: |
| 59 self.fail( | 63 self.fail( |
| 60 'Not expect any Popen() call but got a Popen call with %s\n' % args) | 64 'Not expect any Popen() call but got a Popen call with %s\n' % args) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 71 def _MockBuilderList(self): | 75 def _MockBuilderList(self): |
| 72 excluded_bots = trybot_command.EXCLUDED_BOTS | 76 excluded_bots = trybot_command.EXCLUDED_BOTS |
| 73 builders = [bot for bot in self._builder_list if bot not in excluded_bots] | 77 builders = [bot for bot in self._builder_list if bot not in excluded_bots] |
| 74 return builders | 78 return builders |
| 75 | 79 |
| 76 def _MockTryserverJson(self, bots_dict): | 80 def _MockTryserverJson(self, bots_dict): |
| 77 data = mock.Mock() | 81 data = mock.Mock() |
| 78 data.read.return_value = json.dumps(bots_dict) | 82 data.read.return_value = json.dumps(bots_dict) |
| 79 self._urllib2_mock.urlopen.return_value = data | 83 self._urllib2_mock.urlopen.return_value = data |
| 80 | 84 |
| 85 def _MockTempFile(self, issue, issue_url): |
| 86 fd, temp_file = tempfile.mkstemp(suffix='.json', prefix='cl') |
| 87 with open(temp_file, 'w') as f: |
| 88 json.dump({"issue": issue, "issue_url": issue_url}, f) |
| 89 self._tempfile_mock.mkstemp.return_value = (fd, temp_file) |
| 90 return temp_file |
| 91 |
| 81 def _AssertTryBotExceptions(self, message, func, *args): | 92 def _AssertTryBotExceptions(self, message, func, *args): |
| 82 with self.assertRaises(trybot_command.TrybotError) as e: | 93 with self.assertRaises(trybot_command.TrybotError) as e: |
| 83 func(*args) | 94 func(*args) |
| 84 self.assertIn(message, e.exception.message) | 95 self.assertIn(message, e.exception.message) |
| 85 | 96 |
| 86 def _SetupTrybotCommand( | 97 def _SetupTrybotCommand( |
| 87 self, try_json_dict, trybot, benchmark_name='sunspider', | 98 self, try_json_dict, trybot, benchmark_name='sunspider', |
| 88 repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None): | 99 repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None): |
| 89 self._MockTryserverJson(try_json_dict) | 100 self._MockTryserverJson(try_json_dict) |
| 90 command = trybot_command.Trybot() | 101 command = trybot_command.Trybot() |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 (0, '/root/path_to/repo/src\nbr\n', None)), | 344 (0, '/root/path_to/repo/src\nbr\n', None)), |
| 334 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 345 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 335 (['git', 'diff-index', 'HEAD'], (0, 'dirty tree', None)), | 346 (['git', 'diff-index', 'HEAD'], (0, 'dirty tree', None)), |
| 336 )) | 347 )) |
| 337 self._AssertTryBotExceptions( | 348 self._AssertTryBotExceptions( |
| 338 'Cannot send a try job with a dirty tree.', | 349 'Cannot send a try job with a dirty tree.', |
| 339 command._GetRepoAndBranchName, | 350 command._GetRepoAndBranchName, |
| 340 options.repo_path | 351 options.repo_path |
| 341 ) | 352 ) |
| 342 | 353 |
| 343 def testNoLocalCommits(self): | |
| 344 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | |
| 345 'linux') | |
| 346 self._ExpectProcesses(( | |
| 347 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | |
| 348 (0, '/root/path_to/repo/src\nbr\n', None)), | |
| 349 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | |
| 350 (['git', 'diff-index', 'HEAD'], (0, '', None)), | |
| 351 (['git', 'footers', 'HEAD'], (0, 'CL footers', None)), | |
| 352 )) | |
| 353 self._AssertTryBotExceptions( | |
| 354 'No local changes found in %s repository.' % options.repo_path, | |
| 355 command._GetRepoAndBranchName, | |
| 356 options.repo_path | |
| 357 ) | |
| 358 | |
| 359 def testGetRepoAndBranchName(self): | 354 def testGetRepoAndBranchName(self): |
| 360 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | 355 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 361 'linux') | 356 'linux') |
| 362 self._ExpectProcesses(( | 357 self._ExpectProcesses(( |
| 363 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 358 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 364 (0, '/root/path_to/repo/src\nbr\n', None)), | 359 (0, '/root/path_to/repo/src\nbr\n', None)), |
| 365 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 360 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 366 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 361 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 367 (['git', 'footers', 'HEAD'], (0, '', None)), | |
| 368 )) | 362 )) |
| 369 self.assertEquals( | 363 self.assertEquals( |
| 370 command._GetRepoAndBranchName(options.repo_path), ('src', 'br')) | 364 command._GetRepoAndBranchName(options.repo_path), ('src', 'br')) |
| 371 | 365 |
| 372 def testErrorOnBrowserArgSpecified(self): | 366 def testErrorOnBrowserArgSpecified(self): |
| 373 parser = trybot_command.Trybot.CreateParser() | 367 parser = trybot_command.Trybot.CreateParser() |
| 374 options, extra_args = parser.parse_known_args( | 368 options, extra_args = parser.parse_known_args( |
| 375 ['sunspider', '--trybot=android-all', '--browser=mac']) | 369 ['sunspider', '--trybot=android-all', '--browser=mac']) |
| 376 with self.assertRaises(SystemExit): | 370 with self.assertRaises(SystemExit): |
| 377 trybot_command.Trybot.ProcessCommandLineArgs( | 371 trybot_command.Trybot.ProcessCommandLineArgs( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 }, config) | 429 }, config) |
| 436 | 430 |
| 437 def testUnsupportedTrybot(self): | 431 def testUnsupportedTrybot(self): |
| 438 self.assertRaises( | 432 self.assertRaises( |
| 439 trybot_command.TrybotError, | 433 trybot_command.TrybotError, |
| 440 trybot_command._GetBuilderNames, | 434 trybot_command._GetBuilderNames, |
| 441 'arms-nvidia', | 435 'arms-nvidia', |
| 442 {'win_perf_bisect': 'stuff'} | 436 {'win_perf_bisect': 'stuff'} |
| 443 ) | 437 ) |
| 444 | 438 |
| 445 def testUploadPatchToRietveldGitCommandFailed(self): | 439 def testGetChangeListCommandError(self): |
| 446 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | 440 temp_file = self._MockTempFile(None, None) |
| 447 'linux') | 441 command, _ = self._SetupTrybotCommand( |
| 442 {'linux_perf_bisect': 'stuff'}, 'linux') |
| 448 self._ExpectProcesses(( | 443 self._ExpectProcesses(( |
| 449 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 444 (['git', 'cl', 'issue', '--json', temp_file], (128, None, None)), |
| 450 ('CL for src perf tryjob to run sunspider benchmark on linux ' | |
| 451 'platform(s)')], | |
| 452 (128, None, None)), | |
| 453 )) | 445 )) |
| 454 self._AssertTryBotExceptions( | 446 self._AssertTryBotExceptions( |
| 455 'Could not upload to rietveld for src', | 447 'Failed to run "git cl issue" command.', |
| 456 command._UploadPatchToRietveld, | 448 command._GetChangeList) |
| 457 'src', | |
| 458 options | |
| 459 ) | |
| 460 | 449 |
| 461 def testUploadPatchToRietveldNoURLMatchFound(self): | 450 def testGetChangeListNoIssues(self): |
| 462 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | 451 temp_file = self._MockTempFile(None, None) |
| 463 'linux') | 452 command, _ = self._SetupTrybotCommand( |
| 453 {'linux_perf_bisect': 'stuff'}, 'linux') |
| 464 self._ExpectProcesses(( | 454 self._ExpectProcesses(( |
| 465 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 455 (['git', 'cl', 'issue', '--json', temp_file], |
| 466 ('CL for src perf tryjob to run sunspider benchmark on linux ' | 456 (0, 'Issue number: None (None)', None)), |
| 467 'platform(s)')], | |
| 468 (0, 'stuff https://dummy.chromium.org/12345 stuff', None)), | |
| 469 )) | 457 )) |
| 470 self._AssertTryBotExceptions( | 458 self._AssertTryBotExceptions( |
| 471 'Could not upload CL to rietveld for src!', | 459 ('PLEASE NOTE: The workflow for Perf Try jobs is changed. ' |
| 472 command._UploadPatchToRietveld, | 460 'In order to run the perf try job, you must first upload your ' |
| 473 'src', | 461 'changes to rietveld.'), |
| 474 options | 462 command._GetChangeList) |
| 475 ) | |
| 476 | 463 |
| 477 def testUploadPatchToRietveldOnSuccess(self): | 464 def testGetChangeListWithIssue(self): |
| 478 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | 465 temp_file = self._MockTempFile( |
| 479 'linux') | 466 12345, 'https://codereview.chromium.org/12345') |
| 467 command, _ = self._SetupTrybotCommand( |
| 468 {'linux_perf_bisect': 'stuff'}, 'linux') |
| 480 self._ExpectProcesses(( | 469 self._ExpectProcesses(( |
| 481 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 470 (['git', 'cl', 'issue', '--json', temp_file], |
| 482 ('CL for src perf tryjob to run sunspider benchmark on linux ' | |
| 483 'platform(s)')], | |
| 484 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 471 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 485 )) | 472 )) |
| 486 self.assertEquals(command._UploadPatchToRietveld('src', options), | 473 self.assertEquals('https://codereview.chromium.org/12345', |
| 487 'https://codereview.chromium.org/12345') | 474 command._GetChangeList()) |
| 488 | 475 |
| 489 def testRunTryJobFailed(self): | 476 def testRunTryJobFailed(self): |
| 490 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 477 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 491 command, options = self._SetupTrybotCommand( | 478 command, options = self._SetupTrybotCommand( |
| 492 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='path_to_repo/src') | 479 {'linux_perf_bisect': 'stuff'}, 'linux', repo_path='path_to_repo/src') |
| 493 arguments = [options.benchmark_name] + [] | 480 arguments = [options.benchmark_name] + [] |
| 494 self._ExpectProcesses(( | 481 self._ExpectProcesses(( |
| 495 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 482 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 496 '-p', test_args, | 483 '-p', test_args, |
| 497 '-b', | 484 '-b', |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 (['git', 'rev-parse', 'br1@{upstream}'], | 588 (['git', 'rev-parse', 'br1@{upstream}'], |
| 602 (0, 'feedbeed', None)), | 589 (0, 'feedbeed', None)), |
| 603 )) | 590 )) |
| 604 self._AssertTryBotExceptions( | 591 self._AssertTryBotExceptions( |
| 605 ('URL http://non_maching_repo/git/url.git on remote origin is not ' | 592 ('URL http://non_maching_repo/git/url.git on remote origin is not ' |
| 606 'recognized on branch'), | 593 'recognized on branch'), |
| 607 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') | 594 command._GetBaseGitHashForRepo, 'br', 'http://repo/git/url.git') |
| 608 | 595 |
| 609 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) | 596 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 610 @mock.patch('core.trybot_command.os.path.exists', | 597 @mock.patch('core.trybot_command.os.path.exists', |
| 611 mock.MagicMock(return_value='True')) | 598 mock.MagicMock(return_value=True)) |
| 612 @mock.patch('core.trybot_command.os.path.abspath', | |
| 613 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH)) | |
| 614 def testAttemptTryjobForCrRepo(self): | 599 def testAttemptTryjobForCrRepo(self): |
| 615 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 600 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 616 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, | 601 command, options = self._SetupTrybotCommand({'linux_perf_bisect': 'stuff'}, |
| 617 'linux') | 602 'linux') |
| 603 temp_file = self._MockTempFile( |
| 604 12345, 'https://codereview.chromium.org/12345') |
| 605 |
| 618 self._ExpectProcesses(( | 606 self._ExpectProcesses(( |
| 619 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 607 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 620 (0, '/root/path_to/repo/src\nbr\n', None)), | 608 (0, '/root/path_to/repo/src\nbr\n', None)), |
| 621 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 609 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 622 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 610 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 623 (['git', 'footers', 'HEAD'], (0, '', None)), | 611 (['git', 'cl', 'issue', '--json', temp_file], |
| 624 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | |
| 625 ('CL for src perf tryjob to run sunspider benchmark on linux ' | |
| 626 'platform(s)')], | |
| 627 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 612 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 628 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 613 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 629 '-p', test_args, '-b', 'linux_perf_bisect'], (0, '', None)) | 614 '-p', test_args, '-b', 'linux_perf_bisect'], (0, '', None)) |
| 630 )) | 615 )) |
| 631 command._AttemptTryjob(options, []) | |
| 632 | 616 |
| 633 output = ('Uploaded try job to rietveld.\n' | 617 with mock.patch('core.trybot_command.os.path.abspath', |
| 618 return_value=trybot_command.CHROMIUM_SRC_PATH): |
| 619 command._AttemptTryjob(options, []) |
| 620 |
| 621 output = ('Running try job....\n' |
| 634 'view progress here https://codereview.chromium.org/12345.\n' | 622 'view progress here https://codereview.chromium.org/12345.\n' |
| 635 '\tRepo Name: src\n' | 623 '\tRepo Name: src\n' |
| 636 '\tPath: %s\n' | 624 '\tPath: %s\n' |
| 637 '\tBranch: br\n' | 625 '\tBranch: br\n' |
| 638 'Perf Try job sent to rietveld for linux platform.') % ( | 626 'Perf Try job sent to rietveld for linux platform.') % ( |
| 639 options.repo_path) | 627 options.repo_path) |
| 640 self.assertEquals(output, sys.stdout.getvalue().strip()) | 628 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 641 | 629 |
| 642 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) | 630 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 643 @mock.patch('core.trybot_command.os.path.exists', | 631 @mock.patch('core.trybot_command.os.path.exists', |
| 644 mock.MagicMock(return_value='True')) | 632 mock.MagicMock(return_value='True')) |
| 645 @mock.patch('core.trybot_command.os.path.abspath', | |
| 646 mock.MagicMock(return_value=trybot_command.CHROMIUM_SRC_PATH)) | |
| 647 def testAttemptTryjobAllForCrRepo(self): | 633 def testAttemptTryjobAllForCrRepo(self): |
| 648 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') | 634 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 649 winx64_config = self._ExpectedGitTryTestArgs( | 635 winx64_config = self._ExpectedGitTryTestArgs( |
| 650 'sunspider', 'release_x64', 'x64') | 636 'sunspider', 'release_x64', 'x64') |
| 651 android_config = self._ExpectedGitTryTestArgs( | 637 android_config = self._ExpectedGitTryTestArgs( |
| 652 'sunspider', 'android-chromium', 'ia32') | 638 'sunspider', 'android-chromium', 'ia32') |
| 653 | |
| 654 command, options = self._SetupTrybotCommand( | 639 command, options = self._SetupTrybotCommand( |
| 655 {'linux_perf_bisect': 'stuff', | 640 {'linux_perf_bisect': 'stuff', |
| 656 'win_perf_bisect': 'stuff', | 641 'win_perf_bisect': 'stuff', |
| 657 'winx64_perf_bisect': 'stuff', | 642 'winx64_perf_bisect': 'stuff', |
| 658 'android_perf_bisect': 'stuff', | 643 'android_perf_bisect': 'stuff', |
| 659 'mac_perf_bisect': 'stuff'}, 'all') | 644 'mac_perf_bisect': 'stuff'}, 'all') |
| 645 temp_file = self._MockTempFile( |
| 646 12345, 'https://codereview.chromium.org/12345') |
| 647 |
| 660 self._ExpectProcesses(( | 648 self._ExpectProcesses(( |
| 661 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 649 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 662 (0, '/root/path_to/repo/src\nbr\n', None)), | 650 (0, '/root/path_to/repo/src\nbr\n', None)), |
| 663 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 651 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 664 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 652 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 665 (['git', 'footers', 'HEAD'], (0, '', None)), | 653 (['git', 'cl', 'issue', '--json', temp_file], |
| 666 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | |
| 667 ('CL for src perf tryjob to run sunspider benchmark on all ' | |
| 668 'platform(s)')], | |
| 669 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 654 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 670 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 655 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 671 '-p', default_config, '-b', 'win_perf_bisect'], (0, '', None)), | 656 '-p', default_config, '-b', 'win_perf_bisect'], (0, '', None)), |
| 672 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 657 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 673 '-p', android_config, '-b', 'android_perf_bisect'], (0, '', None)), | 658 '-p', android_config, '-b', 'android_perf_bisect'], (0, '', None)), |
| 674 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 659 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 675 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, '', None)), | 660 '-p', winx64_config, '-b', 'winx64_perf_bisect'], (0, '', None)), |
| 676 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 661 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 677 '-p', default_config, '-b', 'mac_perf_bisect'], (0, '', None)), | 662 '-p', default_config, '-b', 'mac_perf_bisect'], (0, '', None)), |
| 678 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 663 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 679 '-p', default_config, '-b', 'linux_perf_bisect'], (0, '', None)), | 664 '-p', default_config, '-b', 'linux_perf_bisect'], (0, '', None)), |
| 680 )) | 665 )) |
| 681 command._AttemptTryjob(options, []) | 666 |
| 682 output = ('Uploaded try job to rietveld.\n' | 667 with mock.patch('core.trybot_command.os.path.abspath', |
| 668 return_value=trybot_command.CHROMIUM_SRC_PATH): |
| 669 command._AttemptTryjob(options, []) |
| 670 |
| 671 output = ('Running try job....\n' |
| 683 'view progress here https://codereview.chromium.org/12345.\n' | 672 'view progress here https://codereview.chromium.org/12345.\n' |
| 684 '\tRepo Name: src\n' | 673 '\tRepo Name: src\n' |
| 685 '\tPath: %s\n' | 674 '\tPath: %s\n' |
| 686 '\tBranch: br\n' | 675 '\tBranch: br\n' |
| 687 'Perf Try job sent to rietveld for win platform.\n' | 676 'Perf Try job sent to rietveld for win platform.\n' |
| 688 'Perf Try job sent to rietveld for android platform.\n' | 677 'Perf Try job sent to rietveld for android platform.\n' |
| 689 'Perf Try job sent to rietveld for win-x64 platform.\n' | 678 'Perf Try job sent to rietveld for win-x64 platform.\n' |
| 690 'Perf Try job sent to rietveld for mac platform.\n' | 679 'Perf Try job sent to rietveld for mac platform.\n' |
| 691 'Perf Try job sent to rietveld for linux platform.') % ( | 680 'Perf Try job sent to rietveld for linux platform.') % ( |
| 692 options.repo_path) | 681 options.repo_path) |
| 693 self.assertEquals(output, sys.stdout.getvalue().strip()) | 682 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 694 | 683 |
| 695 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) | 684 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 696 @mock.patch('core.trybot_command.os.path.exists', | 685 @mock.patch('core.trybot_command.os.path.exists', |
| 697 mock.MagicMock(return_value='True')) | 686 mock.MagicMock(return_value='True')) |
| 698 @mock.patch('core.trybot_command.os.path.abspath', | |
| 699 mock.MagicMock(return_value='root/path_to/repo/v8')) | |
| 700 def testAttemptTryjobForDepsRepo(self): | 687 def testAttemptTryjobForDepsRepo(self): |
| 701 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 688 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 702 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' | 689 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 703 command, options = self._SetupTrybotCommand( | 690 command, options = self._SetupTrybotCommand( |
| 704 {'linux_perf_bisect': 'stuff'}, 'linux', | 691 {'linux_perf_bisect': 'stuff'}, 'linux', |
| 705 repo_path='root/path_to/repo/v8') | 692 repo_path='root/path_to/repo/v8') |
| 693 temp_file = self._MockTempFile( |
| 694 12345, 'https://codereview.chromium.org/12345') |
| 695 |
| 706 self._ExpectProcesses(( | 696 self._ExpectProcesses(( |
| 707 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 697 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 708 (0, 'root/path_to/repo/v8\nbr\n', None)), | 698 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 709 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 699 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 710 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 700 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 711 (['git', 'footers', 'HEAD'], (0, '', None)), | |
| 712 (['git', 'config', 'branch.br.remote'], (0, '.', None)), | 701 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 713 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], | 702 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 714 (0, 'br1', None,)), | 703 (0, 'br1', None,)), |
| 715 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), | 704 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 716 (['git', 'config', 'remote.origin.url'], | 705 (['git', 'config', 'remote.origin.url'], |
| 717 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), | 706 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), |
| 718 (['git', 'rev-parse', 'br1@{upstream}'], (0, 'feedbeed', None)), | 707 (['git', 'rev-parse', 'br1@{upstream}'], (0, 'feedbeed', None)), |
| 719 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 708 (['git', 'cl', 'issue', '--json', temp_file], |
| 720 ('CL for v8 perf tryjob to run sunspider benchmark on linux ' | |
| 721 'platform(s)')], | |
| 722 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 709 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 723 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 710 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 724 '-p', test_args, '-p', deps_override_arg, | 711 '-p', test_args, '-p', deps_override_arg, |
| 725 '-b', 'linux_perf_bisect'], (0, '', None)) | 712 '-b', 'linux_perf_bisect'], (0, '', None)) |
| 726 )) | 713 )) |
| 727 command._AttemptTryjob(options, []) | |
| 728 | 714 |
| 729 output = ('Uploaded try job to rietveld.\n' | 715 with mock.patch('core.trybot_command.os.path.abspath', |
| 716 return_value='root/path_to/repo/v8'): |
| 717 command._AttemptTryjob(options, []) |
| 718 |
| 719 output = ('Running try job....\n' |
| 730 'view progress here https://codereview.chromium.org/12345.\n' | 720 'view progress here https://codereview.chromium.org/12345.\n' |
| 731 '\tRepo Name: v8\n' | 721 '\tRepo Name: v8\n' |
| 732 '\tPath: root/path_to/repo/v8\n' | 722 '\tPath: root/path_to/repo/v8\n' |
| 733 '\tBranch: br\n' | 723 '\tBranch: br\n' |
| 734 'Perf Try job sent to rietveld for linux platform.') | 724 'Perf Try job sent to rietveld for linux platform.') |
| 735 self.assertEquals(output, sys.stdout.getvalue().strip()) | 725 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 736 | 726 |
| 737 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) | 727 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 738 @mock.patch('core.trybot_command.os.path.exists', | 728 @mock.patch('core.trybot_command.os.path.exists', |
| 739 mock.MagicMock(return_value='True')) | 729 mock.MagicMock(return_value='True')) |
| 740 @mock.patch('core.trybot_command.os.path.abspath', | |
| 741 mock.MagicMock(return_value='root/path_to/repo/v8')) | |
| 742 def testAttemptTryjobAllForDepsRepo(self): | 730 def testAttemptTryjobAllForDepsRepo(self): |
| 743 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') | 731 default_config = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 744 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' | 732 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 745 winx64_config = self._ExpectedGitTryTestArgs( | 733 winx64_config = self._ExpectedGitTryTestArgs( |
| 746 'sunspider', 'release_x64', 'x64') | 734 'sunspider', 'release_x64', 'x64') |
| 747 android_config = self._ExpectedGitTryTestArgs( | 735 android_config = self._ExpectedGitTryTestArgs( |
| 748 'sunspider', 'android-chromium', 'ia32') | 736 'sunspider', 'android-chromium', 'ia32') |
| 749 command, options = self._SetupTrybotCommand( | 737 command, options = self._SetupTrybotCommand( |
| 750 {'linux_perf_bisect': 'stuff', | 738 {'linux_perf_bisect': 'stuff', |
| 751 'winx64_perf_bisect': 'stuff', | 739 'winx64_perf_bisect': 'stuff', |
| 752 'android_perf_bisect': 'stuff'}, | 740 'android_perf_bisect': 'stuff'}, |
| 753 'all', repo_path='root/path_to/repo/v8') | 741 'all', repo_path='root/path_to/repo/v8') |
| 742 temp_file = self._MockTempFile( |
| 743 12345, 'https://codereview.chromium.org/12345') |
| 754 | 744 |
| 755 self._ExpectProcesses(( | 745 self._ExpectProcesses(( |
| 756 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 746 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 757 (0, 'root/path_to/repo/v8\nbr\n', None)), | 747 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 758 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 748 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 759 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 749 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 760 (['git', 'footers', 'HEAD'], (0, '', None)), | |
| 761 (['git', 'config', 'branch.br.remote'], (0, '.', None)), | 750 (['git', 'config', 'branch.br.remote'], (0, '.', None)), |
| 762 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], | 751 (['git', 'rev-parse', '--abbrev-ref', 'br@{upstream}'], |
| 763 (0, 'br1', None,)), | 752 (0, 'br1', None,)), |
| 764 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), | 753 (['git', 'config', 'branch.br1.remote'], (0, 'origin', None)), |
| 765 (['git', 'config', 'remote.origin.url'], | 754 (['git', 'config', 'remote.origin.url'], |
| 766 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), | 755 (0, 'https://chromium.googlesource.com/v8/v8.git', None)), |
| 767 (['git', 'rev-parse', 'br1@{upstream}'], | 756 (['git', 'rev-parse', 'br1@{upstream}'], |
| 768 (0, 'feedbeed', None)), | 757 (0, 'feedbeed', None)), |
| 769 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | 758 (['git', 'cl', 'issue', '--json', temp_file], |
| 770 ('CL for v8 perf tryjob to run sunspider benchmark on all ' | |
| 771 'platform(s)')], | |
| 772 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 759 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 773 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 760 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 774 '-p', android_config, '-p', deps_override_arg, | 761 '-p', android_config, '-p', deps_override_arg, |
| 775 '-b', 'android_perf_bisect'], (0, '', None)), | 762 '-b', 'android_perf_bisect'], (0, '', None)), |
| 776 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 763 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 777 '-p', winx64_config, '-p', deps_override_arg, | 764 '-p', winx64_config, '-p', deps_override_arg, |
| 778 '-b', 'winx64_perf_bisect'], (0, '', None)), | 765 '-b', 'winx64_perf_bisect'], (0, '', None)), |
| 779 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 766 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 780 '-p', default_config, '-p', deps_override_arg, | 767 '-p', default_config, '-p', deps_override_arg, |
| 781 '-b', 'linux_perf_bisect'], (0, '', None)), | 768 '-b', 'linux_perf_bisect'], (0, '', None)), |
| 782 )) | 769 )) |
| 783 command._AttemptTryjob(options, []) | 770 |
| 784 output = ('Uploaded try job to rietveld.\n' | 771 with mock.patch('core.trybot_command.os.path.abspath', |
| 772 return_value='root/path_to/repo/v8'): |
| 773 command._AttemptTryjob(options, []) |
| 774 |
| 775 output = ('Running try job....\n' |
| 785 'view progress here https://codereview.chromium.org/12345.\n' | 776 'view progress here https://codereview.chromium.org/12345.\n' |
| 786 '\tRepo Name: v8\n' | 777 '\tRepo Name: v8\n' |
| 787 '\tPath: root/path_to/repo/v8\n' | 778 '\tPath: root/path_to/repo/v8\n' |
| 788 '\tBranch: br\n' | 779 '\tBranch: br\n' |
| 789 'Perf Try job sent to rietveld for android platform.\n' | 780 'Perf Try job sent to rietveld for android platform.\n' |
| 790 'Perf Try job sent to rietveld for win-x64 platform.\n' | 781 'Perf Try job sent to rietveld for win-x64 platform.\n' |
| 791 'Perf Try job sent to rietveld for linux platform.') | 782 'Perf Try job sent to rietveld for linux platform.') |
| 792 self.assertEquals(output, sys.stdout.getvalue().strip()) | 783 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 793 | 784 |
| 794 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) | 785 @mock.patch('core.trybot_command.os.chdir', mock.MagicMock()) |
| 795 @mock.patch('core.trybot_command.os.path.exists', | 786 @mock.patch('core.trybot_command.os.path.exists', |
| 796 mock.MagicMock(return_value='True')) | 787 mock.MagicMock(return_value='True')) |
| 797 @mock.patch('core.trybot_command.os.path.abspath', | |
| 798 mock.MagicMock(return_value='root/path_to/repo/v8')) | |
| 799 def testAttemptTryjobWithDepsRevisionArg(self): | 788 def testAttemptTryjobWithDepsRevisionArg(self): |
| 800 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') | 789 test_args = self._ExpectedGitTryTestArgs('sunspider', 'release') |
| 801 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' | 790 deps_override_arg = 'deps_revision_overrides={"src/v8": "feedbeed"}' |
| 802 command, options = self._SetupTrybotCommand( | 791 command, options = self._SetupTrybotCommand( |
| 803 {'linux_perf_bisect': 'stuff'}, 'linux', | 792 {'linux_perf_bisect': 'stuff'}, 'linux', |
| 804 repo_path='root/path_to/repo/v8', deps_revision='feedbeed') | 793 repo_path='root/path_to/repo/v8', deps_revision='feedbeed') |
| 794 temp_file = self._MockTempFile( |
| 795 12345, 'https://codereview.chromium.org/12345') |
| 796 |
| 805 self._ExpectProcesses(( | 797 self._ExpectProcesses(( |
| 806 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], | 798 (['git', 'rev-parse', '--abbrev-ref', '--show-toplevel', 'HEAD'], |
| 807 (0, 'root/path_to/repo/v8\nbr\n', None)), | 799 (0, 'root/path_to/repo/v8\nbr\n', None)), |
| 808 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), | 800 (['git', 'update-index', '--refresh', '-q'], (0, '', None,)), |
| 809 (['git', 'diff-index', 'HEAD'], (0, '', None)), | 801 (['git', 'diff-index', 'HEAD'], (0, '', None)), |
| 810 (['git', 'footers', 'HEAD'], (0, '', None)), | 802 (['git', 'cl', 'issue', '--json', temp_file], |
| 811 (['git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', | |
| 812 ('CL for v8 perf tryjob to run sunspider benchmark on linux ' | |
| 813 'platform(s)')], | |
| 814 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), | 803 (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), |
| 815 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', | 804 (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', |
| 816 '-p', test_args, '-p', deps_override_arg, | 805 '-p', test_args, '-p', deps_override_arg, |
| 817 '-b', 'linux_perf_bisect'], (0, '', None)) | 806 '-b', 'linux_perf_bisect'], (0, '', None)) |
| 818 )) | 807 )) |
| 819 command._AttemptTryjob(options, []) | 808 with mock.patch('core.trybot_command.os.path.abspath', |
| 809 return_value='root/path_to/repo/v8'): |
| 810 command._AttemptTryjob(options, []) |
| 820 | 811 |
| 821 output = ('Uploaded try job to rietveld.\n' | 812 output = ('Running try job....\n' |
| 822 'view progress here https://codereview.chromium.org/12345.\n' | 813 'view progress here https://codereview.chromium.org/12345.\n' |
| 823 '\tRepo Name: v8\n' | 814 '\tRepo Name: v8\n' |
| 824 '\tPath: root/path_to/repo/v8\n' | 815 '\tPath: root/path_to/repo/v8\n' |
| 825 '\tBranch: br\n' | 816 '\tBranch: br\n' |
| 826 'Perf Try job sent to rietveld for linux platform.') | 817 'Perf Try job sent to rietveld for linux platform.') |
| 827 self.assertEquals(output, sys.stdout.getvalue().strip()) | 818 self.assertEquals(output, sys.stdout.getvalue().strip()) |
| 828 | 819 |
| 829 | 820 |
| 830 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase): | 821 class IsBenchmarkDisabledOnTrybotPlatformTest(unittest.TestCase): |
| 831 | 822 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 @benchmark.Enabled('win', 'mac') | 859 @benchmark.Enabled('win', 'mac') |
| 869 class FooBenchmark(benchmark.Benchmark): | 860 class FooBenchmark(benchmark.Benchmark): |
| 870 pass | 861 pass |
| 871 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all')) | 862 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all')) |
| 872 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac')) | 863 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'all-mac')) |
| 873 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati')) | 864 self.assertFalse(self.IsBenchmarkDisabled(FooBenchmark, 'winx64ati')) |
| 874 | 865 |
| 875 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5')) | 866 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'android-s5')) |
| 876 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux')) | 867 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'linux')) |
| 877 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux')) | 868 self.assertTrue(self.IsBenchmarkDisabled(FooBenchmark, 'all-linux')) |
| OLD | NEW |