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 logging.warning('Invalid test type.') |
| 179 return |
| 180 |
| 181 try: |
| 182 # TODO(frankf): Temp server for initial testing upstream. |
| 183 # Use http://test-results.appspot.com once we're confident this works. |
| 184 if _STAGING_SERVER in flakiness_server: |
| 185 assert test_package in ['ContentShellTest', |
| 186 'ChromiumTestShellTest', |
| 187 'AndroidWebViewTest'] |
| 188 dashboard_test_type = ('%s_instrumentation_tests' % |
| 189 test_package.lower().rstrip('test')) |
| 190 # Downstream prod server. |
| 191 else: |
| 192 dashboard_test_type = 'Chromium_Android_Instrumentation' |
| 193 |
| 194 flakiness_dashboard_results_uploader.Upload( |
| 195 flakiness_server, dashboard_test_type, self) |
| 196 except Exception as e: |
| 197 logging.error(e) |
175 | 198 |
176 def LogFull(self, test_type, test_package, annotation=None, | 199 def LogFull(self, test_type, test_package, annotation=None, |
177 build_type='Debug', all_tests=None, flakiness_server=None): | 200 build_type='Debug', all_tests=None, flakiness_server=None): |
178 """Log the tests results for the test suite. | 201 """Log the tests results for the test suite. |
179 | 202 |
180 The results will be logged three different ways: | 203 The results will be logged three different ways: |
181 1. Log to stdout. | 204 1. Log to stdout. |
182 2. Log to local files for aggregating multiple test steps | 205 2. Log to local files for aggregating multiple test steps |
183 (on buildbots only). | 206 (on buildbots only). |
184 3. Log to flakiness dashboard (on buildbots only). | 207 3. Log to flakiness dashboard (on buildbots only). |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 272 |
250 if flakiness_server: | 273 if flakiness_server: |
251 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) | 274 self._LogToFlakinessDashboard(test_type, test_package, flakiness_server) |
252 | 275 |
253 def PrintAnnotation(self): | 276 def PrintAnnotation(self): |
254 """Print buildbot annotations for test results.""" | 277 """Print buildbot annotations for test results.""" |
255 if self.failed or self.crashed or self.overall_fail or self.timed_out: | 278 if self.failed or self.crashed or self.overall_fail or self.timed_out: |
256 buildbot_report.PrintError() | 279 buildbot_report.PrintError() |
257 else: | 280 else: |
258 print 'Step success!' # No annotation needed | 281 print 'Step success!' # No annotation needed |
OLD | NEW |