Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2017 The Chromium Authors. All rights reserved. | 1 # Copyright 2017 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 google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 6 | 6 |
| 7 from common.pipeline_wrapper import BasePipeline | 7 from common.pipeline_wrapper import BasePipeline |
| 8 from model.flake.flake_try_job import FlakeTryJob | 8 from gae_libs.http.http_client_appengine import HttpClientAppengine |
| 9 from model.flake.master_flake_analysis import DataPoint | 9 from model.flake.master_flake_analysis import DataPoint |
| 10 from waterfall import swarming_util | |
| 11 | |
| 12 | |
| 13 def _GetSwarmingTaskIdForTryJob(report, revision, step_name): | |
| 14 """Check json output for each task and return id of the one with test result. | |
| 15 """ | |
| 16 if not report: | |
| 17 return None | |
| 18 | |
| 19 http_client = HttpClientAppengine() | |
| 20 task_ids = report.get('result', {}).get(revision, {}).get( | |
|
stgao
2017/01/12 07:43:27
If there is only one task id, do we still have to
chanli
2017/01/12 20:28:29
Good point. Just updated.
stgao
2017/01/13 02:18:18
Example: a test is newly added in the suspected bu
| |
| 21 step_name, {}).get('step_metadata', {}).get('swarm_task_ids', []) | |
| 22 | |
| 23 for task_id in task_ids: | |
| 24 output_json = swarming_util.GetIsolatedOutputForTask(task_id, http_client) | |
| 25 if output_json: | |
| 26 for data in output_json.get('per_iteration_data', []): | |
| 27 # If this task doesn't have result, per_iteration_data will look like | |
| 28 # [{}, {}, ...] | |
| 29 if data: | |
| 30 return task_id | |
| 31 | |
| 32 return None | |
| 10 | 33 |
| 11 | 34 |
| 12 class ProcessFlakeTryJobResultPipeline(BasePipeline): | 35 class ProcessFlakeTryJobResultPipeline(BasePipeline): |
| 13 """A pipeline for processing a flake try job result.""" | 36 """A pipeline for processing a flake try job result.""" |
| 14 | 37 |
| 15 # Arguments number differs from overridden method - pylint: disable=W0221 | 38 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 16 def run(self, revision, commit_position, try_job_result, urlsafe_try_job_key, | 39 def run(self, revision, commit_position, try_job_result, urlsafe_try_job_key, |
| 17 urlsafe_flake_analysis_key): | 40 urlsafe_flake_analysis_key): |
| 18 """Extracts pass rate information and updates flake analysis. | 41 """Extracts pass rate information and updates flake analysis. |
| 19 | 42 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 tries = pass_count + fail_count | 81 tries = pass_count + fail_count |
| 59 pass_rate = float(pass_count) / tries | 82 pass_rate = float(pass_count) / tries |
| 60 else: # Test does not exist. | 83 else: # Test does not exist. |
| 61 pass_rate = -1 | 84 pass_rate = -1 |
| 62 | 85 |
| 63 data_point = DataPoint() | 86 data_point = DataPoint() |
| 64 data_point.commit_position = commit_position | 87 data_point.commit_position = commit_position |
| 65 data_point.pass_rate = pass_rate | 88 data_point.pass_rate = pass_rate |
| 66 data_point.try_job_id = try_job.try_job_ids[-1] | 89 data_point.try_job_id = try_job.try_job_ids[-1] |
| 67 data_point.try_job_url = try_job.flake_results[-1].get('url') | 90 data_point.try_job_url = try_job.flake_results[-1].get('url') |
| 68 # TODO: Add swarming task data. | 91 data_point.task_id = _GetSwarmingTaskIdForTryJob( |
| 92 try_job.flake_results[-1].get('report'), revision, step_name) | |
| 69 flake_analysis.data_points.append(data_point) | 93 flake_analysis.data_points.append(data_point) |
| OLD | NEW |