| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 """A command to fetch new baselines from try jobs for a Rietveld issue. | 5 """A command to fetch new baselines from try jobs for a Rietveld issue. |
| 6 | 6 |
| 7 This command interacts with the Rietveld API to get information about try jobs | 7 This command interacts with the Rietveld API to get information about try jobs |
| 8 with layout test results. | 8 with layout test results. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 import json |
| 11 import logging | 12 import logging |
| 12 import optparse | 13 import optparse |
| 13 | 14 |
| 14 from webkitpy.common.net.rietveld import Rietveld | 15 from webkitpy.common.net.rietveld import Rietveld |
| 15 from webkitpy.common.net.web import Web | 16 from webkitpy.common.net.web import Web |
| 16 from webkitpy.common.net.git_cl import GitCL | 17 from webkitpy.common.net.git_cl import GitCL |
| 17 from webkitpy.common.webkit_finder import WebKitFinder | 18 from webkitpy.common.webkit_finder import WebKitFinder |
| 18 from webkitpy.layout_tests.models.test_expectations import BASELINE_SUFFIX_LIST | 19 from webkitpy.layout_tests.models.test_expectations import BASELINE_SUFFIX_LIST |
| 19 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand | 20 from webkitpy.tool.commands.rebaseline import AbstractParallelRebaselineCommand |
| 20 | 21 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 builds = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) | 177 builds = self.rietveld.latest_try_jobs(issue_number, self._try_bots()) |
| 177 if not builds: | 178 if not builds: |
| 178 _log.debug('No try job results for builders in: %r.', self._try_bots
()) | 179 _log.debug('No try job results for builders in: %r.', self._try_bots
()) |
| 179 return {build: self._tests_to_rebaseline(build) for build in builds} | 180 return {build: self._tests_to_rebaseline(build) for build in builds} |
| 180 | 181 |
| 181 def _try_bots(self): | 182 def _try_bots(self): |
| 182 """Returns a collection of try bot builders to fetch results for.""" | 183 """Returns a collection of try bot builders to fetch results for.""" |
| 183 return self._tool.builders.all_try_builder_names() | 184 return self._tool.builders.all_try_builder_names() |
| 184 | 185 |
| 185 def _tests_to_rebaseline(self, build): | 186 def _tests_to_rebaseline(self, build): |
| 186 """Fetches a list of LayoutTestResult objects for unexpected results wit
h new baselines.""" | 187 """Fetches a list of tests that should be rebaselined.""" |
| 187 buildbot = self._tool.buildbot | 188 buildbot = self._tool.buildbot |
| 188 results_url = buildbot.results_url(build.builder_name, build.build_numbe
r) | 189 results_url = buildbot.results_url(build.builder_name, build.build_numbe
r) |
| 189 layout_test_results = buildbot.fetch_layout_test_results(results_url) | 190 layout_test_results = buildbot.fetch_layout_test_results(results_url) |
| 190 if layout_test_results is None: | 191 if layout_test_results is None: |
| 191 _log.warning('Failed to request layout test results from "%s".', res
ults_url) | 192 _log.warning('Failed to request layout test results from "%s".', res
ults_url) |
| 192 return [] | 193 return [] |
| 193 failure_results = layout_test_results.unexpected_mismatch_results() | 194 failure_results = layout_test_results.unexpected_mismatch_results() |
| 194 missing_results = layout_test_results.missing_results() | 195 missing_results = layout_test_results.missing_results() |
| 195 return sorted(r.test_name() for r in failure_results + missing_results) | 196 tests = sorted(r.test_name() for r in failure_results + missing_results) |
| 197 |
| 198 new_failures = self._fetch_tests_with_new_failures(build) |
| 199 if new_failures is None: |
| 200 _log.warning('No retry summary available for build %s.', build) |
| 201 else: |
| 202 tests = [t for t in tests if t in new_failures] |
| 203 return tests |
| 204 |
| 205 def _fetch_tests_with_new_failures(self, build): |
| 206 """Fetches a list of tests that failed with a patch in a given try job b
ut not without.""" |
| 207 buildbot = self._tool.buildbot |
| 208 content = buildbot.fetch_retry_summary_json(build) |
| 209 if content is None: |
| 210 return None |
| 211 try: |
| 212 retry_summary = json.loads(content) |
| 213 return retry_summary['failures'] |
| 214 except (ValueError, KeyError): |
| 215 _log.warning('Unexepected retry summary content:\n%s', content) |
| 216 return None |
| 196 | 217 |
| 197 @staticmethod | 218 @staticmethod |
| 198 def _log_test_prefix_list(test_prefix_list): | 219 def _log_test_prefix_list(test_prefix_list): |
| 199 """Logs the tests to download new baselines for.""" | 220 """Logs the tests to download new baselines for.""" |
| 200 if not test_prefix_list: | 221 if not test_prefix_list: |
| 201 _log.info('No tests to rebaseline; exiting.') | 222 _log.info('No tests to rebaseline; exiting.') |
| 202 return | 223 return |
| 203 _log.info('Tests to rebaseline:') | 224 _log.debug('Tests to rebaseline:') |
| 204 for test, builds in test_prefix_list.iteritems(): | 225 for test, builds in test_prefix_list.iteritems(): |
| 205 builds_str = ', '.join(sorted('%s (%s)' % (b.builder_name, b.build_n
umber) for b in builds)) | 226 _log.debug(' %s:', test) |
| 206 _log.info(' %s: %s', test, builds_str) | 227 for build in sorted(builds): |
| 228 _log.debug(' %s', build) |
| OLD | NEW |