diff options
author | nednguyen <nednguyen@google.com> | 2016-03-02 23:55:52 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-03 07:57:23 +0000 |
commit | 91da72fe17e3d7466c36f9b1f6a07998516a3264 (patch) | |
tree | 6fd514aaddcfe0a4a69ee14633e05ab55c3f75c9 /tools/perf | |
parent | 5958ca8683dd9478a780d516205355a36c48c5aa (diff) | |
download | chromium_src-91da72fe17e3d7466c36f9b1f6a07998516a3264.zip chromium_src-91da72fe17e3d7466c36f9b1f6a07998516a3264.tar.gz chromium_src-91da72fe17e3d7466c36f9b1f6a07998516a3264.tar.bz2 |
[tools/perf] Skip try job run if trybot config file does not change
Sometime, users run trybot job against many bots of different platforms
(e.g: platforms win & winx64). Sometimes the configs of these different
platforms are the same because they happens to share the same bot.
In this case, we will skip the trybot run if the config file does not change.
BUG=591613
Review URL: https://codereview.chromium.org/1765483002
Cr-Commit-Position: refs/heads/master@{#378979}
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/core/trybot_command.py | 21 | ||||
-rw-r--r-- | tools/perf/core/trybot_command_unittest.py | 21 |
2 files changed, 36 insertions, 6 deletions
diff --git a/tools/perf/core/trybot_command.py b/tools/perf/core/trybot_command.py index 8d145f0..8769939 100644 --- a/tools/perf/core/trybot_command.py +++ b/tools/perf/core/trybot_command.py @@ -244,14 +244,19 @@ class Trybot(command_line.ArgParseCommand): url if success, otherwise throws TrybotError exception. """ config = self._GetPerfConfig(bot_platform, arguments) + config_to_write = 'config = %s' % json.dumps( + config, sort_keys=True, indent=2, separators=(',', ': ')) + try: - config_file = open(cfg_file_path, 'w') + with open(cfg_file_path, 'r') as config_file: + if config_to_write == config_file.read(): + return NO_CHANGES, '' except IOError: msg = 'Cannot find %s. Please run from src dir.' % cfg_file_path return (ERROR, msg) - config_file.write('config = %s' % json.dumps( - config, sort_keys=True, indent=2, separators=(',', ': '))) - config_file.close() + + with open(cfg_file_path, 'w') as config_file: + config_file.write(config_to_write) # Commit the config changes locally. returncode, out, err = _RunProcess( ['git', 'commit', '-a', '-m', 'bisect config: %s' % bot_platform]) @@ -394,8 +399,12 @@ class Trybot(command_line.ArgParseCommand): if results == ERROR: logging.error(output) return ERROR - print ('Uploaded %s try job to rietveld for %s platform. ' - 'View progress at %s' % (source_repo, bot_platform, output)) + elif results == NO_CHANGES: + print ('Skip the try job run on %s because it has been tried in ' + 'previous try job run. ' % bot_platform) + else: + print ('Uploaded %s try job to rietveld for %s platform. ' + 'View progress at %s' % (source_repo, bot_platform, output)) except TrybotError, err: print err logging.error(err) diff --git a/tools/perf/core/trybot_command_unittest.py b/tools/perf/core/trybot_command_unittest.py index b18b0fd..f26d9de 100644 --- a/tools/perf/core/trybot_command_unittest.py +++ b/tools/perf/core/trybot_command_unittest.py @@ -55,6 +55,9 @@ class TrybotCommandTest(unittest.TestCase): counter = [-1] def side_effect(args, **kwargs): + if not expected_args_list: + self.fail( + 'Not expect any Popen() call but got a Popen call with %s\n' % args) del kwargs # unused counter[0] += 1 expected_args, expected_responses = expected_args_list[counter[0]] @@ -487,6 +490,24 @@ class TrybotCommandTest(unittest.TestCase): trybot_command.TrybotError, command._UpdateConfigAndRunTryjob, 'android', cfg_filename, []) + 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", + "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 testUpdateConfigGitTry(self): self._MockTryserverJson({'android_nexus4_perf_bisect': 'stuff'}) command = trybot_command.Trybot() |