Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import time | 10 import time |
| 11 import traceback | 11 import traceback |
| 12 | 12 |
| 13 import buildbot_report | 13 import buildbot_report |
| 14 import constants | 14 import constants |
| 15 import flakiness_dashboard_results_uploader | 15 from pylib.utils import flakiness_dashboard_results_uploader |
| 16 | |
| 17 | |
| 18 _STAGING_SERVER = 'chrome-android-staging' | |
| 16 | 19 |
| 17 | 20 |
| 18 class BaseTestResult(object): | 21 class BaseTestResult(object): |
| 19 """A single result from a unit test.""" | 22 """A single result from a unit test.""" |
| 20 | 23 |
| 21 def __init__(self, name, log): | 24 def __init__(self, name, log): |
| 22 self.name = name | 25 self.name = name |
| 23 self.log = log.replace('\r', '') | 26 self.log = log.replace('\r', '') |
| 24 | 27 |
| 25 | 28 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 'failed': [t.name for t in self.failed], | 163 'failed': [t.name for t in self.failed], |
| 161 'crashed': [t.name for t in self.failed], | 164 'crashed': [t.name for t in self.failed], |
| 162 'unknown': [t.name for t in self.unknown],} | 165 'unknown': [t.name for t in self.unknown],} |
| 163 json_file_path = os.path.join(log_file_path, 'results.json') | 166 json_file_path = os.path.join(log_file_path, 'results.json') |
| 164 with open(json_file_path, 'a') as json_file: | 167 with open(json_file_path, 'a') as json_file: |
| 165 print >> json_file, json.dumps(content) | 168 print >> json_file, json.dumps(content) |
| 166 logging.info('Writing results to %s.' % json_file_path) | 169 logging.info('Writing results to %s.' % json_file_path) |
| 167 | 170 |
| 168 def _LogToFlakinessDashboard(self, test_type, test_package, flakiness_server): | 171 def _LogToFlakinessDashboard(self, test_type, test_package, flakiness_server): |
| 169 """Upload results to the flakiness dashboard""" | 172 """Upload results to the flakiness dashboard""" |
| 170 # TODO(frankf): Fix upstream/downstream reporting for both test types. | 173 logging.info('Upload results for test type "%s", test package "%s" to %s' % |
| 171 logging.info('Upload %s %s to %s' % (test_type, test_package, | 174 (test_type, test_package, flakiness_server)) |
| 172 flakiness_server)) | 175 |
| 173 flakiness_dashboard_results_uploader.Upload( | 176 # TODO(frankf): Enable uploading for gtests. |
| 174 flakiness_server, 'Chromium_Android_Instrumentation', self) | 177 if test_type != 'Instrumentation': |
| 178 raise Exception('Invalid test type.') | |
|
mkosiba (inactive)
2013/01/14 12:07:55
maybe just log && return?
frankf
2013/01/14 18:54:41
Done.
| |
| 179 | |
| 180 try: | |
| 181 # TODO(frankf): Temp server for initial testing upstream. | |
| 182 # Use http://test-results.appspot.com once we're confidant this works. | |
|
mkosiba (inactive)
2013/01/14 12:07:55
nit: confident
frankf
2013/01/14 18:54:41
Indeed. Done.
On 2013/01/14 12:07:55, Martin Kosib
| |
| 183 if _STAGING_SERVER in flakiness_server: | |
| 184 assert test_package in ['ContentShellTest', | |
| 185 'ChromiumTestShell', | |
| 186 'AndroidWebViewTest'] | |
| 187 dashboard_test_type = ('%s_instrumentation_tests' % | |
| 188 test_package.lower().rstrip('test')) | |
| 189 # Downstream prod server. | |
| 190 else: | |
| 191 dashboard_test_type = 'Chromium_Android_Instrumentation' | |
| 192 | |
| 193 flakiness_dashboard_results_uploader.Upload( | |
| 194 flakiness_server, dashboard_test_type, self) | |
| 195 except Exception as e: | |
| 196 logging.error(e) | |
| 175 | 197 |
| 176 def LogFull(self, test_type, test_package, annotation=None, | 198 def LogFull(self, test_type, test_package, annotation=None, |
| 177 build_type='Debug', all_tests=None, flakiness_server=None): | 199 build_type='Debug', all_tests=None, flakiness_server=None): |
| 178 """Log the tests results for the test suite. | 200 """Log the tests results for the test suite. |
| 179 | 201 |
| 180 The results will be logged three different ways: | 202 The results will be logged three different ways: |
| 181 1. Log to stdout. | 203 1. Log to stdout. |
| 182 2. Log to local files for aggregating multiple test steps | 204 2. Log to local files for aggregating multiple test steps |
| 183 (on buildbots only). | 205 (on buildbots only). |
| 184 3. Log to flakiness dashboard (on buildbots only). | 206 3. Log to flakiness dashboard (on buildbots only). |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 | 271 |
| 250 if flakiness_server: | 272 if flakiness_server: |
| 251 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) | 273 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) |
| 252 | 274 |
| 253 def PrintAnnotation(self): | 275 def PrintAnnotation(self): |
| 254 """Print buildbot annotations for test results.""" | 276 """Print buildbot annotations for test results.""" |
| 255 if self.failed or self.crashed or self.overall_fail or self.timed_out: | 277 if self.failed or self.crashed or self.overall_fail or self.timed_out: |
| 256 buildbot_report.PrintError() | 278 buildbot_report.PrintError() |
| 257 else: | 279 else: |
| 258 print 'Step success!' # No annotation needed | 280 print 'Step success!' # No annotation needed |
| OLD | NEW |