| 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 logging | 6 import logging |
| 7 | 7 |
| 8 from common import appengine_util | 8 from common import appengine_util |
| 9 from model import wf_analysis_status | 9 from common import constants |
| 10 from model import analysis_status |
| 10 from model.wf_try_job import WfTryJob | 11 from model.wf_try_job import WfTryJob |
| 11 from pipeline_wrapper import BasePipeline | 12 from pipeline_wrapper import BasePipeline |
| 12 from pipeline_wrapper import pipeline | 13 from pipeline_wrapper import pipeline |
| 13 from waterfall import try_job_pipeline | 14 from waterfall import try_job_pipeline |
| 14 from waterfall.try_job_type import TryJobType | 15 from waterfall.try_job_type import TryJobType |
| 15 | 16 |
| 16 | 17 |
| 17 # TODO(chanli): Need to figure out why try-job-queue doesn't work. | |
| 18 TRY_JOB_PIPELINE_QUEUE_NAME = 'build-failure-analysis-queue' | |
| 19 | |
| 20 | |
| 21 def _GetReliableTargetedTests(targeted_tests, classified_tests_by_step): | 18 def _GetReliableTargetedTests(targeted_tests, classified_tests_by_step): |
| 22 """Returns a dict containing a list of reliable tests for each failed step.""" | 19 """Returns a dict containing a list of reliable tests for each failed step.""" |
| 23 reliable_tests = defaultdict(list) | 20 reliable_tests = defaultdict(list) |
| 24 for step_name, tests in targeted_tests.iteritems(): | 21 for step_name, tests in targeted_tests.iteritems(): |
| 25 if step_name in classified_tests_by_step: # Swarming step. | 22 if step_name in classified_tests_by_step: # Swarming step. |
| 26 # If the step is swarming but there is no result for it, it's highly | 23 # If the step is swarming but there is no result for it, it's highly |
| 27 # likely that there is some error with the task. | 24 # likely that there is some error with the task. |
| 28 # Thus skip this step for no insights from task to avoid false positive. | 25 # Thus skip this step for no insights from task to avoid false positive. |
| 29 step_name_no_platform = classified_tests_by_step[step_name][0] | 26 step_name_no_platform = classified_tests_by_step[step_name][0] |
| 30 classified_tests = classified_tests_by_step[step_name][1] | 27 classified_tests = classified_tests_by_step[step_name][1] |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 if try_job_type == TryJobType.TEST: | 65 if try_job_type == TryJobType.TEST: |
| 69 targeted_tests = _GetReliableTargetedTests( | 66 targeted_tests = _GetReliableTargetedTests( |
| 70 targeted_tests, dict(classified_tests_by_step)) | 67 targeted_tests, dict(classified_tests_by_step)) |
| 71 if targeted_tests or try_job_type == TryJobType.COMPILE: | 68 if targeted_tests or try_job_type == TryJobType.COMPILE: |
| 72 new_try_job_pipeline = try_job_pipeline.TryJobPipeline( | 69 new_try_job_pipeline = try_job_pipeline.TryJobPipeline( |
| 73 master_name, builder_name, build_number, good_revision, | 70 master_name, builder_name, build_number, good_revision, |
| 74 bad_revision, blame_list, try_job_type, compile_targets, | 71 bad_revision, blame_list, try_job_type, compile_targets, |
| 75 targeted_tests) | 72 targeted_tests) |
| 76 | 73 |
| 77 new_try_job_pipeline.target = appengine_util.GetTargetNameForModule( | 74 new_try_job_pipeline.target = appengine_util.GetTargetNameForModule( |
| 78 'build-failure-analysis') | 75 constants.WATERFALL_BACKEND) |
| 79 new_try_job_pipeline.start() | 76 new_try_job_pipeline.start(queue_name=constants.WATERFALL_TRY_JOB_QUEUE) |
| 80 logging.info('Try-job was scheduled for build %s, %s, %s: %s', | 77 logging.info('Try-job was scheduled for build %s, %s, %s: %s', |
| 81 master_name, builder_name, build_number, | 78 master_name, builder_name, build_number, |
| 82 new_try_job_pipeline.pipeline_status_path) | 79 new_try_job_pipeline.pipeline_status_path) |
| 83 else: # pragma: no cover | 80 else: # pragma: no cover |
| 84 # No need to start try job, mark it as skipped. | 81 # No need to start try job, mark it as skipped. |
| 85 try_job_result = WfTryJob.Get( | 82 try_job_result = WfTryJob.Get( |
| 86 master_name, builder_name, build_number) | 83 master_name, builder_name, build_number) |
| 87 if try_job_result: | 84 if try_job_result: |
| 88 try_job_result.status = wf_analysis_status.SKIPPED | 85 try_job_result.status = analysis_status.SKIPPED |
| 89 try_job_result.put() | 86 try_job_result.put() |
| 90 return | 87 return |
| OLD | NEW |