def testConstructorTrybotAll(self): self._MockTryserverJson({ 'android_nexus4_perf_bisect': 'stuff', 'android_nexus5_perf_bisect': 'stuff2', 'android_webview_nexus6_aosp_perf_bisect': 'stuff3', 'mac_10_9_perf_bisect': 'otherstuff', 'mac_perf_bisect': 'otherstuff1', 'win_perf_bisect': 'otherstuff2', 'linux_perf_bisect': 'otherstuff3', 'win_x64_perf_bisect': 'otherstuff4', 'win_perf_bisect_builder': 'not a trybot', }) command = trybot_command.Trybot() command._InitializeBuilderNames('all') self.assertEquals( ['android', 'android-webview', 'linux', 'mac', 'win', 'win-x64'], sorted(command._builder_names)) self.assertEquals( ['android_nexus4_perf_bisect', 'android_nexus5_perf_bisect'], sorted(command._builder_names.get('android'))) self.assertEquals(['android_webview_nexus6_aosp_perf_bisect'], sorted( command._builder_names.get('android-webview'))) self.assertEquals(['mac_10_9_perf_bisect', 'mac_perf_bisect'], sorted(command._builder_names.get('mac'))) self.assertEquals(['linux_perf_bisect'], sorted(command._builder_names.get('linux'))) self.assertEquals(['win_perf_bisect'], sorted(command._builder_names.get('win'))) self.assertEquals(['win_x64_perf_bisect'], sorted(command._builder_names.get('win-x64')))
def testConstructorTrybotAllWin(self): self._MockTryserverJson({ 'android_nexus4_perf_bisect': 'stuff', 'android_nexus5_perf_bisect': 'stuff2', 'win_8_perf_bisect': 'otherstuff', 'win_perf_bisect': 'otherstuff2', 'linux_perf_bisect': 'otherstuff3', 'win_x64_perf_bisect': 'otherstuff4', 'win_perf_bisect_builder': 'not a trybot', 'win_x64_10_perf_bisect': 'otherstuff4', 'winx64ati_perf_bisect': 'not a trybot', 'winx64nvidia_perf_bisect': 'not a trybot', }) command = trybot_command.Trybot() command._InitializeBuilderNames('all-win') self.assertEquals(['win', 'win-x64'], sorted(command._builder_names)) self.assertEquals(['win_8_perf_bisect', 'win_perf_bisect'], sorted(command._builder_names.get('win'))) self.assertNotIn('win_x64_perf_bisect', sorted(command._builder_names.get('win'))) self.assertEquals( sorted([ 'win_x64_perf_bisect', 'win_x64_10_perf_bisect', 'winx64ati_perf_bisect', 'winx64nvidia_perf_bisect' ]), sorted(command._builder_names.get('win-x64')))
def testUpdateConfigGitTry(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) command = trybot_command.Trybot() command._InitializeBuilderNames('android-nexus4') self._ExpectProcesses( ((['git', 'commit', '-a', '-m', 'bisect config: android'], (0, 'None', None)), ([ 'git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 'CL for perf tryjob on android' ], (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), ([ 'git', 'cl', 'try', '-m', 'tryserver.chromium.perf', '-b', 'android_nexus4_perf_bisect' ], (0, None, None)))) cfg_filename = 'tools/run-perf-test.cfg' cfg = StringIO.StringIO() self._stubs.open.files = {cfg_filename: cfg} self.assertEquals( (0, 'https://codereview.chromium.org/12345'), command._UpdateConfigAndRunTryjob('android', cfg_filename, [])) cfg.seek(0) config = '''config = { "command": "./tools/perf/run_benchmark --browser=android-chromium", "max_time_minutes": "120", "repeat_count": "1", "target_arch": "ia32", "truncate_percent": "0" }''' self.assertEquals(cfg.read(), config)
def testBranchCheckoutFails(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) self._ExpectProcesses(( (['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'br', None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, 'logs here', None)), (['git', 'checkout', '-b', 'telemetry-tryjob'], (1, None, 'fatal: A branch named \'telemetry-try\' already exists.')), )) command = trybot_command.Trybot() options = argparse.Namespace(trybot='android-nexus4', benchmark_name='foo') command.Run(options, []) self.assertEquals( ('Error creating branch telemetry-tryjob. ' 'Please delete it if it exists.\n' 'fatal: A branch named \'telemetry-try\' already exists.\n'), self.log_output.getvalue())
def testNoLocalCommits(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) command = trybot_command.Trybot() command._InitializeBuilderNames('android-nexus4') self._ExpectProcesses(( (['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'br', None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, '', None)), (['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'br', None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, '', None)), )) options = argparse.Namespace(trybot='android-nexus4', benchmark_name='foo') command.Run(options) self.assertEquals( ('No local changes found in chromium or blink trees. ' 'browser=android-nexus4 argument sends local changes to the ' 'perf trybot(s): ' '[[\'android_nexus4_perf_bisect\']].\n'), self.log_output.getvalue())
def testConstructor(self): self._MockTryserverJson({ 'android_nexus4_perf_bisect': 'stuff', 'mac_10_9_perf_bisect': 'otherstuff', 'win_perf_bisect_builder': 'not a trybot', }) command = trybot_command.Trybot() command._InitializeBuilderNames('android-nexus4') self.assertTrue('android' in command._builder_names) self.assertEquals(['android_nexus4_perf_bisect'], command._builder_names.get('android'))
def _SetupTrybotCommand( self, try_json_dict, trybot, benchmark_name='sunspider', repo_path=trybot_command.CHROMIUM_SRC_PATH, deps_revision=None): self._MockTryserverJson(try_json_dict) command = trybot_command.Trybot() command._InitializeBuilderNames(trybot) opts = argparse.Namespace( trybot=trybot, benchmark_name=benchmark_name, repo_path=repo_path, deps_revision=deps_revision) return command, opts
def testConstructorTrybotAllMac(self): self._MockTryserverJson({ 'android_nexus4_perf_bisect': 'stuff', 'win_8_perf_bisect': 'otherstuff', 'mac_perf_bisect': 'otherstuff2', 'win_perf_bisect_builder': 'not a trybot', }) command = trybot_command.Trybot() command._InitializeBuilderNames('all-mac') self.assertEquals(['mac'], sorted(command._builder_names)) self.assertEquals(['mac_perf_bisect'], sorted(command._builder_names.get('mac')))
def testNoGit(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) command = trybot_command.Trybot() command._InitializeBuilderNames('android-nexus4') self._ExpectProcesses(((['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (128, None, None)), )) options = argparse.Namespace(trybot='android', benchmark_name='dromaeo') command.Run(options) self.assertEquals( 'Must be in a git repository to send changes to trybots.\n', self.log_output.getvalue())
def _GetConfigForTrybot(self, name, platform, branch, cfg_filename, is_blink=False, extra_benchmark_args=None): bot = '%s_perf_bisect' % name.replace('', '').replace('-', '_') self._MockTryserverJson({bot: 'stuff'}) first_processes = () if is_blink: first_processes = ((['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'br', None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, '', None))) self._ExpectProcesses(first_processes + ( (['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, branch, None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, 'logs here', None)), (['git', 'checkout', '-b', 'telemetry-tryjob'], (0, None, None)), (['git', 'branch', '--set-upstream-to', 'origin/master'], (0, None, None)), (['git', 'commit', '-a', '-m', 'bisect config: %s' % platform], (0, None, None)), ([ 'git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 'CL for perf tryjob on %s' % platform ], (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), (['git', 'cl', 'try', '-m', 'tryserver.chromium.perf', '-b', bot], (0, None, None)), (['git', 'checkout', branch], (0, None, None)), (['git', 'branch', '-D', 'telemetry-tryjob'], (0, None, None)))) cfg = StringIO.StringIO() self._stubs.open.files = {cfg_filename: cfg} options = argparse.Namespace(trybot=name, benchmark_name='sunspider') command = trybot_command.Trybot() extra_benchmark_args = extra_benchmark_args or [] command.Run(options, extra_benchmark_args) return cfg.getvalue()
def testDirtyTree(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) self._ExpectProcesses(( (['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'br', None)), (['git', 'update-index', '--refresh', '-q'], ( 0, None, None, )), (['git', 'diff-index', 'HEAD'], (0, 'dirty tree', None)), )) options = argparse.Namespace(trybot='android-nexus4', benchmark_name='foo') command = trybot_command.Trybot() command.Run(options, []) self.assertEquals( 'Cannot send a try job with a dirty tree. Commit locally first.\n', self.log_output.getvalue())
def testUpdateConfigSkipTryjob(self): self._MockTryserverJson({'win_perf_bisect': 'stuff'}) command = trybot_command.Trybot() command._InitializeBuilderNames('win-x64') self._ExpectProcesses(()) cfg_filename = 'tools/run-perf-test.cfg' cfg_data = ('''config = { "command": "python tools\\\\perf\\\\run_benchmark --browser=release_x64''' ''' --verbose", "max_time_minutes": "120", "repeat_count": "1", "target_arch": "x64", "truncate_percent": "0" }''') self._stubs.open.files = {cfg_filename: cfg_data} self.assertEquals( (trybot_command.NO_CHANGES, ''), command._UpdateConfigAndRunTryjob('win-x64', cfg_filename, []))
def testUpdateConfigGitUploadTrybotError(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) command = trybot_command.Trybot() command._InitializeBuilderNames('android-nexus4') self._ExpectProcesses( ((['git', 'commit', '-a', '-m', 'bisect config: android'], (0, 'None', None)), ([ 'git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 'CL for perf tryjob on android' ], (128, None, 'error')), ([ 'git', 'cl', 'try', '-m', 'tryserver.chromium.perf', '-b', 'android_nexus4_perf_bisect' ], (0, None, None)))) cfg_filename = 'tools/run-perf-test.cfg' cfg = StringIO.StringIO() self._stubs.open.files = {cfg_filename: cfg} self.assertRaises(trybot_command.TrybotError, command._UpdateConfigAndRunTryjob, 'android', cfg_filename, [])
def testUpdateConfigGitTryAll(self): self._MockTryserverJson({ 'android_nexus4_perf_bisect': 'stuff', 'win_8_perf_bisect': 'stuff2' }) command = trybot_command.Trybot() command._InitializeBuilderNames('all') self._ExpectProcesses( ((['git', 'rev-parse', '--abbrev-ref', 'HEAD'], (0, 'CURRENT-BRANCH', None)), (['git', 'update-index', '--refresh', '-q'], (0, '', None)), (['git', 'diff-index', 'HEAD'], (0, '', None)), (['git', 'log', 'origin/master..HEAD'], (0, 'abcdef', None)), (['git', 'checkout', '-b', 'telemetry-tryjob'], (0, '', None)), (['git', 'branch', '--set-upstream-to', 'origin/master'], (0, '', None)), (['git', 'commit', '-a', '-m', 'bisect config: win'], (0, 'None', None)), ([ 'git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 'CL for perf tryjob on win' ], (0, 'stuff2 https://codereview.chromium.org/12345 stuff2', None)), ([ 'git', 'cl', 'try', '-m', 'tryserver.chromium.perf', '-b', 'win_8_perf_bisect' ], (0, None, None)), (['git', 'commit', '-a', '-m', 'bisect config: android'], (0, 'None', None)), ([ 'git', 'cl', 'upload', '-f', '--bypass-hooks', '-m', 'CL for perf tryjob on android' ], (0, 'stuff https://codereview.chromium.org/12345 stuff', None)), ([ 'git', 'cl', 'try', '-m', 'tryserver.chromium.perf', '-b', 'android_nexus4_perf_bisect' ], (0, None, None)), (['git', 'checkout', 'CURRENT-BRANCH'], (0, '', None)), (['git', 'branch', '-D', 'telemetry-tryjob'], (0, '', None)))) cfg_filename = 'tools/run-perf-test.cfg' cfg = StringIO.StringIO() self._stubs.open.files = {cfg_filename: cfg} self.assertEquals(0, command._AttemptTryjob(cfg_filename, [])) cfg.seek(0) # The config contains both config for browser release & android-chromium, # but that's because the stub testing does not reset the StringIO. In # reality, the cfg_filename should be overwritten with the new data. config = ('''config = { "command": "python tools\\\\perf\\\\run_benchmark --browser=release", "max_time_minutes": "120", "repeat_count": "1", "target_arch": "ia32", "truncate_percent": "0" }''' '''config = { "command": "./tools/perf/run_benchmark --browser=android-chromium", "max_time_minutes": "120", "repeat_count": "1", "target_arch": "ia32", "truncate_percent": "0" }''') self.assertEquals(cfg.read(), config)