| 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 from collections import defaultdict | 5 from collections import defaultdict |
| 6 import copy | 6 import copy |
| 7 | 7 |
| 8 from handlers import result_status | 8 from handlers import result_status |
| 9 from model import analysis_status | 9 from model import analysis_status |
| 10 from model.wf_analysis import WfAnalysis | 10 from model.wf_analysis import WfAnalysis |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 try_job_info['try_job_build_number'] = ( | 223 try_job_info['try_job_build_number'] = ( |
| 224 _GetTryJobBuildNumber(try_job_result['url'])) | 224 _GetTryJobBuildNumber(try_job_result['url'])) |
| 225 | 225 |
| 226 if (try_job_result.get('culprit') and | 226 if (try_job_result.get('culprit') and |
| 227 try_job_result['culprit'].get(ref_name)): | 227 try_job_result['culprit'].get(ref_name)): |
| 228 # Saves try job culprits information. | 228 # Saves try job culprits information. |
| 229 | 229 |
| 230 # Uses culprits to group tests. | 230 # Uses culprits to group tests. |
| 231 culprit_tests_map = _OrganizeTryJobResultByCulprits( | 231 culprit_tests_map = _OrganizeTryJobResultByCulprits( |
| 232 try_job_result['culprit'][ref_name]) | 232 try_job_result['culprit'][ref_name]) |
| 233 unrgouped_tests = try_job_info['tests'] | 233 ungrouped_tests = try_job_info['tests'] |
| 234 list_of_culprits = [] | 234 list_of_culprits = [] |
| 235 for culprit_info in culprit_tests_map.values(): | 235 for culprit_info in culprit_tests_map.values(): |
| 236 failed_tests = culprit_info['failed_tests'] | 236 failed_tests = culprit_info['failed_tests'] |
| 237 list_of_culprits.append(culprit_info) | 237 list_of_culprits.append(culprit_info) |
| 238 # Gets tests that haven't been grouped. | 238 # Gets tests that haven't been grouped. |
| 239 unrgouped_tests = list( | 239 ungrouped_tests = list( |
| 240 set(unrgouped_tests) ^ set(failed_tests)) | 240 set(ungrouped_tests) ^ set(failed_tests)) |
| 241 if not unrgouped_tests: | 241 if not ungrouped_tests: |
| 242 # All tests have been grouped. | 242 # All tests have been grouped. |
| 243 break | 243 break |
| 244 | 244 |
| 245 index_start = 1 | 245 index_start = 1 |
| 246 if unrgouped_tests: | 246 if ungrouped_tests: |
| 247 # There are tests don't have try job culprits. | 247 # There are tests don't have try job culprits. |
| 248 # Group these tests together. | 248 # Group these tests together. |
| 249 # Save them in current try_job_info. | 249 # Save them in current try_job_info. |
| 250 try_job_info['tests'] = unrgouped_tests | 250 try_job_info['tests'] = ungrouped_tests |
| 251 try_job_info['culprit'] = {} | 251 try_job_info['culprit'] = {} |
| 252 # Saves all the tests that have culprits later. | 252 # Saves all the tests that have culprits later. |
| 253 index_start = 0 | 253 index_start = 0 |
| 254 else: | 254 else: |
| 255 # Saves the first culprit in current try_job_info. | 255 # Saves the first culprit in current try_job_info. |
| 256 # Saves all the other culprits later. | 256 # Saves all the other culprits later. |
| 257 try_job_info['culprit'] = { | 257 try_job_info['culprit'] = { |
| 258 'revision': list_of_culprits[0]['revision'], | 258 'revision': list_of_culprits[0]['revision'], |
| 259 'commit_position': list_of_culprits[0]['commit_position'], | 259 'commit_position': list_of_culprits[0]['commit_position'], |
| 260 'review_url': list_of_culprits[0]['review_url'] | 260 'review_url': list_of_culprits[0].get( |
| 261 'url', list_of_culprits[0].get('review_url', None)) |
| 261 } | 262 } |
| 262 try_job_info['tests'] = list_of_culprits[0]['failed_tests'] | 263 try_job_info['tests'] = list_of_culprits[0]['failed_tests'] |
| 263 | 264 |
| 264 for n in xrange(index_start, len(list_of_culprits)): | 265 for n in xrange(index_start, len(list_of_culprits)): |
| 265 # Appends the rest of test groups to step_try_jobs['try_jobs']. | 266 # Appends the rest of test groups to step_try_jobs['try_jobs']. |
| 266 iterate_culprit = list_of_culprits[n] | 267 iterate_culprit = list_of_culprits[n] |
| 267 tmp_try_job_info = copy.deepcopy(try_job_info) | 268 tmp_try_job_info = copy.deepcopy(try_job_info) |
| 268 tmp_try_job_info['culprit'] = { | 269 tmp_try_job_info['culprit'] = { |
| 269 'revision': iterate_culprit['revision'], | 270 'revision': iterate_culprit['revision'], |
| 270 'commit_position': iterate_culprit['commit_position'], | 271 'commit_position': iterate_culprit['commit_position'], |
| 271 'review_url': iterate_culprit['review_url'] | 272 'review_url': iterate_culprit.get( |
| 273 'url', iterate_culprit.get('review_url', None)) |
| 272 } | 274 } |
| 273 tmp_try_job_info['tests'] = iterate_culprit['failed_tests'] | 275 tmp_try_job_info['tests'] = iterate_culprit['failed_tests'] |
| 274 additional_tests_culprit_info.append(tmp_try_job_info) | 276 additional_tests_culprit_info.append(tmp_try_job_info) |
| 275 | 277 |
| 276 if additional_tests_culprit_info: | 278 if additional_tests_culprit_info: |
| 277 step_try_jobs['try_jobs'].extend(additional_tests_culprit_info) | 279 step_try_jobs['try_jobs'].extend(additional_tests_culprit_info) |
| 278 | 280 |
| 279 | 281 |
| 280 def _UpdateTryJobInfoBasedOnSwarming(step_tasks_info, try_jobs): | 282 def _UpdateTryJobInfoBasedOnSwarming(step_tasks_info, try_jobs): |
| 281 """ | 283 """ |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 422 |
| 421 culprits_info[step_name] = { | 423 culprits_info[step_name] = { |
| 422 'try_jobs': [ | 424 'try_jobs': [ |
| 423 { | 425 { |
| 424 'status': result_status.NO_FAILURE_RESULT_MAP, | 426 'status': result_status.NO_FAILURE_RESULT_MAP, |
| 425 'tests': tests | 427 'tests': tests |
| 426 } | 428 } |
| 427 ] | 429 ] |
| 428 } | 430 } |
| 429 return culprits_info | 431 return culprits_info |
| OLD | NEW |