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 """Uploads the results to the flakiness dashboard server.""" | 5 """Uploads the results to the flakiness dashboard server.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 buildbot_branch = os.environ.get('BUILDBOT_BRANCH') | 146 buildbot_branch = os.environ.get('BUILDBOT_BRANCH') |
147 if not buildbot_branch: | 147 if not buildbot_branch: |
148 buildbot_branch = 'master' | 148 buildbot_branch = 'master' |
149 self._master_name = '%s-%s' % (self._build_name, buildbot_branch) | 149 self._master_name = '%s-%s' % (self._build_name, buildbot_branch) |
150 | 150 |
151 self._test_results_map = {} | 151 self._test_results_map = {} |
152 | 152 |
153 def AddResults(self, test_results): | 153 def AddResults(self, test_results): |
154 # TODO(frankf): Differentiate between fail/crash/timeouts. | 154 # TODO(frankf): Differentiate between fail/crash/timeouts. |
155 conversion_map = [ | 155 conversion_map = [ |
156 (test_results.ok, False, | 156 (test_results.GetPass(), False, |
157 json_results_generator.JSONResultsGeneratorBase.PASS_RESULT), | 157 json_results_generator.JSONResultsGeneratorBase.PASS_RESULT), |
158 (test_results.failed, True, | 158 (test_results.GetFail(), True, |
159 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), | 159 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), |
160 (test_results.crashed, True, | 160 (test_results.GetCrash(), True, |
161 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), | 161 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), |
162 (test_results.timed_out, True, | 162 (test_results.GetTimeout(), True, |
163 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), | 163 json_results_generator.JSONResultsGeneratorBase.FAIL_RESULT), |
164 (test_results.unknown, True, | 164 (test_results.GetUnknown(), True, |
165 json_results_generator.JSONResultsGeneratorBase.NO_DATA_RESULT), | 165 json_results_generator.JSONResultsGeneratorBase.NO_DATA_RESULT), |
166 ] | 166 ] |
167 | 167 |
168 for results_list, failed, modifier in conversion_map: | 168 for results_list, failed, modifier in conversion_map: |
169 for single_test_result in results_list: | 169 for single_test_result in results_list: |
170 test_result = json_results_generator.TestResult( | 170 test_result = json_results_generator.TestResult( |
171 test=single_test_result.name, | 171 test=single_test_result.GetName(), |
172 failed=failed, | 172 failed=failed, |
173 elapsed_time=single_test_result.dur / 1000) | 173 elapsed_time=single_test_result.GetDur() / 1000) |
174 # The WebKit TestResult object sets the modifier it based on test name. | 174 # The WebKit TestResult object sets the modifier it based on test name. |
175 # Since we don't use the same test naming convention as WebKit the | 175 # Since we don't use the same test naming convention as WebKit the |
176 # modifier will be wrong, so we need to overwrite it. | 176 # modifier will be wrong, so we need to overwrite it. |
177 test_result.modifier = modifier | 177 test_result.modifier = modifier |
178 | 178 |
179 self._test_results_map[single_test_result.name] = test_result | 179 self._test_results_map[single_test_result.GetName()] = test_result |
180 | 180 |
181 def Upload(self, test_results_server): | 181 def Upload(self, test_results_server): |
182 if not self._test_results_map: | 182 if not self._test_results_map: |
183 return | 183 return |
184 | 184 |
185 tmp_folder = tempfile.mkdtemp() | 185 tmp_folder = tempfile.mkdtemp() |
186 | 186 |
187 try: | 187 try: |
188 results_generator = JSONResultsGenerator( | 188 results_generator = JSONResultsGenerator( |
189 port=PortDummy(), | 189 port=PortDummy(), |
190 builder_name=self._builder_name, | 190 builder_name=self._builder_name, |
191 build_name=self._build_name, | 191 build_name=self._build_name, |
192 build_number=self._build_number, | 192 build_number=self._build_number, |
193 tmp_folder=tmp_folder, | 193 tmp_folder=tmp_folder, |
194 test_results_map=self._test_results_map, | 194 test_results_map=self._test_results_map, |
195 test_results_server=test_results_server, | 195 test_results_server=test_results_server, |
196 test_type=self._tests_type, | 196 test_type=self._tests_type, |
197 master_name=self._master_name) | 197 master_name=self._master_name) |
198 | 198 |
199 json_files = ["incremental_results.json", "times_ms.json"] | 199 json_files = ["incremental_results.json", "times_ms.json"] |
200 results_generator.generate_json_output() | 200 results_generator.generate_json_output() |
201 results_generator.generate_times_ms_file() | 201 results_generator.generate_times_ms_file() |
202 results_generator.upload_json_files(json_files) | 202 results_generator.upload_json_files(json_files) |
203 except Exception as e: | 203 except Exception as e: |
204 logging.error("Uploading results to test server failed: %s." % e); | 204 logging.error("Uploading results to test server failed: %s." % e); |
205 finally: | 205 finally: |
206 shutil.rmtree(tmp_folder) | 206 shutil.rmtree(tmp_folder) |
207 | 207 |
208 | 208 |
209 def Upload(flakiness_dashboard_server, test_type, results): | 209 def Upload(results, flakiness_dashboard_server, test_type): |
210 """Reports test results to the flakiness dashboard for Chrome for Android. | 210 """Reports test results to the flakiness dashboard for Chrome for Android. |
211 | 211 |
212 Args: | 212 Args: |
| 213 results: test results. |
213 flakiness_dashboard_server: the server to upload the results to. | 214 flakiness_dashboard_server: the server to upload the results to. |
214 test_type: the type of the tests (as displayed by the flakiness dashboard). | 215 test_type: the type of the tests (as displayed by the flakiness dashboard). |
215 results: test results. | |
216 """ | 216 """ |
217 uploader = ResultsUploader(test_type) | 217 uploader = ResultsUploader(test_type) |
218 uploader.AddResults(results) | 218 uploader.AddResults(results) |
219 uploader.Upload(flakiness_dashboard_server) | 219 uploader.Upload(flakiness_dashboard_server) |
OLD | NEW |