| 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 | 4 |
| 5 import json | 5 import json |
| 6 import tempfile | 6 import tempfile |
| 7 import os | 7 import os |
| 8 import uuid | 8 import uuid |
| 9 | 9 |
| 10 from . import revision_state | 10 from . import revision_state |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 api.m.file.write('Saving diff patch for ' + str(self.revision_string), | 50 api.m.file.write('Saving diff patch for ' + str(self.revision_string), |
| 51 file_name, self.deps_patch + self.deps_sha_patch) | 51 file_name, self.deps_patch + self.deps_sha_patch) |
| 52 return file_name | 52 return file_name |
| 53 | 53 |
| 54 def _request_build(self): | 54 def _request_build(self): |
| 55 """Posts a request to buildbot to build this revision and archive it.""" | 55 """Posts a request to buildbot to build this revision and archive it.""" |
| 56 # TODO: Rewrite using the trigger module. | 56 # TODO: Rewrite using the trigger module. |
| 57 api = self.bisector.api | 57 api = self.bisector.api |
| 58 bot_name = self.bisector.get_builder_bot_for_this_platform() | 58 bot_name = self.bisector.get_builder_bot_for_this_platform() |
| 59 if self.bisector.dummy_builds: | 59 if self.bisector.dummy_builds: |
| 60 self.build_job_name = self.commit_hash + '-build' | 60 self.job_name = self.commit_hash + '-build' |
| 61 else: # pragma: no cover | 61 else: # pragma: no cover |
| 62 self.build_job_name = uuid.uuid4().hex | 62 self.job_name = uuid.uuid4().hex |
| 63 if self.needs_patch: | 63 if self.needs_patch: |
| 64 self.patch_file = self._write_deps_patch_file( | 64 self.patch_file = self._write_deps_patch_file( |
| 65 self.build_job_name) | 65 self.job_name) |
| 66 else: | 66 else: |
| 67 self.patch_file = '/dev/null' | 67 self.patch_file = '/dev/null' |
| 68 try_cmd = [ | 68 try_cmd = [ |
| 69 'try', | 69 'try', |
| 70 '--bot', bot_name, | 70 '--bot', bot_name, |
| 71 '--revision', self.commit_hash, | 71 '--revision', self.commit_hash, |
| 72 '--name', self.build_job_name, | 72 '--name', self.job_name, |
| 73 '--svn_repo', api.SVN_REPO_URL, | 73 '--svn_repo', api.SVN_REPO_URL, |
| 74 '--diff', self.patch_file, | 74 '--diff', self.patch_file, |
| 75 ] | 75 ] |
| 76 try: | 76 try: |
| 77 if not self.bisector.bisect_config.get('skip_gclient_ops'): | 77 if not self.bisector.bisect_config.get('skip_gclient_ops'): |
| 78 self.bisector.ensure_sync_master_branch() | 78 self.bisector.ensure_sync_master_branch() |
| 79 api.m.git( | 79 api.m.git( |
| 80 *try_cmd, name='Requesting build for %s via git try.' | 80 *try_cmd, name='Requesting build for %s via git try.' |
| 81 % str(self.commit_hash), git_config_options={ | 81 % str(self.commit_hash), git_config_options={ |
| 82 'user.email': 'FAKE_PERF_PUMPKIN@chromium.org', | 82 'user.email': 'FAKE_PERF_PUMPKIN@chromium.org', |
| (...skipping 19 matching lines...) Expand all Loading... |
| 102 } | 102 } |
| 103 for k, v in self.bisector.bisect_config.iteritems(): | 103 for k, v in self.bisector.bisect_config.iteritems(): |
| 104 if k in required_test_properties: | 104 if k in required_test_properties: |
| 105 result[k] = v | 105 result[k] = v |
| 106 self._test_config = result | 106 self._test_config = result |
| 107 return result | 107 return result |
| 108 | 108 |
| 109 def _do_test(self): | 109 def _do_test(self): |
| 110 """Posts a request to buildbot to download and perf-test this build.""" | 110 """Posts a request to buildbot to download and perf-test this build.""" |
| 111 if self.bisector.dummy_builds: | 111 if self.bisector.dummy_builds: |
| 112 self.test_job_name = self.commit_hash + '-test' | 112 self.job_name = self.commit_hash + '-test' |
| 113 elif 'CACHE_TEST_RESULTS' in os.environ: # pragma: no cover | 113 elif 'CACHE_TEST_RESULTS' in os.environ: # pragma: no cover |
| 114 self.test_job_name = test_results_cache.make_id( | 114 self.job_name = test_results_cache.make_id( |
| 115 self.revision_string, self._get_bisect_config_for_tester()) | 115 self.revision_string, self._get_bisect_config_for_tester()) |
| 116 else: # pragma: no cover | 116 else: # pragma: no cover |
| 117 self.test_job_name = uuid.uuid4().hex | 117 self.job_name = uuid.uuid4().hex |
| 118 api = self.bisector.api | 118 api = self.bisector.api |
| 119 perf_test_properties = { | 119 perf_test_properties = { |
| 120 'builder_name': self.bisector.get_perf_tester_name(), | 120 'builder_name': self.bisector.get_perf_tester_name(), |
| 121 'properties': { | 121 'properties': { |
| 122 'revision': self.commit_hash, | 122 'revision': self.commit_hash, |
| 123 'parent_got_revision': self.commit_hash, | 123 'parent_got_revision': self.commit_hash, |
| 124 'parent_build_archive_url': self.build_url, | 124 'parent_build_archive_url': self.build_url, |
| 125 'bisect_config': self._get_bisect_config_for_tester(), | 125 'bisect_config': self._get_bisect_config_for_tester(), |
| 126 'job_name': self.test_job_name, | 126 'job_name': self.job_name, |
| 127 }, | 127 }, |
| 128 } | 128 } |
| 129 if 'CACHE_TEST_RESULTS' in os.environ and test_results_cache.has_results( | 129 if 'CACHE_TEST_RESULTS' in os.environ and test_results_cache.has_results( |
| 130 self.test_job_name): # pragma: no cover | 130 self.job_name): # pragma: no cover |
| 131 return | 131 return |
| 132 step_name = 'Triggering test job for ' + str(self.revision_string) | 132 step_name = 'Triggering test job for ' + str(self.revision_string) |
| 133 self.test_results_url = (self.bisector.api.GS_RESULTS_URL + | 133 self.test_results_url = (self.bisector.api.GS_RESULTS_URL + |
| 134 self.test_job_name + '.results') | 134 self.job_name + '.results') |
| 135 api.m.trigger(perf_test_properties, name=step_name) | 135 api.m.trigger(perf_test_properties, name=step_name) |
| 136 | 136 |
| 137 def get_next_url(self): | 137 def get_next_url(self): |
| 138 if self.status == PerfRevisionState.BUILDING: | 138 if self.status == PerfRevisionState.BUILDING: |
| 139 return self.build_url | 139 return self.build_url |
| 140 if self.status == PerfRevisionState.TESTING: | 140 if self.status == PerfRevisionState.TESTING: |
| 141 return self.test_results_url | 141 return self.test_results_url |
| 142 | 142 |
| 143 def get_buildbot_locator(self): | 143 def get_buildbot_locator(self): |
| 144 if self.status not in (PerfRevisionState.BUILDING, |
| 145 PerfRevisionState.TESTING): # pragma: no cover |
| 146 return None |
| 147 # TODO(robertocn): Remove hardcoded master. |
| 148 master = 'tryserver.chromium.perf' |
| 144 if self.status == PerfRevisionState.BUILDING: | 149 if self.status == PerfRevisionState.BUILDING: |
| 145 # TODO(robertocn): Remove hardcoded master. | 150 builder = self.bisector.get_builder_bot_for_this_platform() |
| 146 master = 'tryserver.chromium.perf' | |
| 147 bot_name = self.bisector.get_builder_bot_for_this_platform() | |
| 148 job_name = self.build_job_name | |
| 149 return 'bb:%s:%s:%s' % (master, bot_name, job_name) | |
| 150 if self.status == PerfRevisionState.TESTING: | 151 if self.status == PerfRevisionState.TESTING: |
| 151 master = 'tryserver.chromium.perf' | 152 builder = self.bisector.get_perf_tester_name() |
| 152 bot_name = self.bisector.get_perf_tester_name() | 153 return { |
| 153 job_name = self.test_job_name | 154 'type': 'buildbot', |
| 154 return 'bb:%s:%s:%s' % (master, bot_name, job_name) | 155 'master': master, |
| 156 'builder': builder, |
| 157 'job_name': self.job_name, |
| 158 } |
| 155 | 159 |
| 156 def _get_test_results(self): | 160 def _get_test_results(self): |
| 157 """Tries to get the results of a test job from cloud storage.""" | 161 """Tries to get the results of a test job from cloud storage.""" |
| 158 api = self.bisector.api | 162 api = self.bisector.api |
| 159 try: | 163 try: |
| 160 stdout = api.m.raw_io.output() | 164 stdout = api.m.raw_io.output() |
| 161 name = 'Get test results for build ' + self.commit_hash | 165 name = 'Get test results for build ' + self.commit_hash |
| 162 step_result = api.m.gsutil.cat(self.test_results_url, stdout=stdout, | 166 step_result = api.m.gsutil.cat(self.test_results_url, stdout=stdout, |
| 163 name=name) | 167 name=name) |
| 164 except api.m.step.StepFailure: # pragma: no cover | 168 except api.m.step.StepFailure: # pragma: no cover |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 True if this revision is closer to the initial good revision's value than | 180 True if this revision is closer to the initial good revision's value than |
| 177 to the initial bad revision's value. False otherwise. | 181 to the initial bad revision's value. False otherwise. |
| 178 """ | 182 """ |
| 179 # TODO: Reevaluate this approach | 183 # TODO: Reevaluate this approach |
| 180 bisector = self.bisector | 184 bisector = self.bisector |
| 181 distance_to_good = abs(self.mean_value - bisector.good_rev.mean_value) | 185 distance_to_good = abs(self.mean_value - bisector.good_rev.mean_value) |
| 182 distance_to_bad = abs(self.mean_value - bisector.bad_rev.mean_value) | 186 distance_to_bad = abs(self.mean_value - bisector.bad_rev.mean_value) |
| 183 if distance_to_good < distance_to_bad: | 187 if distance_to_good < distance_to_bad: |
| 184 return True | 188 return True |
| 185 return False | 189 return False |
| OLD | NEW |