Chromium Code Reviews| Index: appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py |
| diff --git a/appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py b/appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py |
| index 2a5fb799d056b705a018a87b9a376221e355ba68..0c34193ccdfebbeca1b1d5ad51704d3f8c16d93b 100644 |
| --- a/appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py |
| +++ b/appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py |
| @@ -5,8 +5,31 @@ |
| from google.appengine.ext import ndb |
| from common.pipeline_wrapper import BasePipeline |
| -from model.flake.flake_try_job import FlakeTryJob |
| +from gae_libs.http.http_client_appengine import HttpClientAppengine |
| from model.flake.master_flake_analysis import DataPoint |
| +from waterfall import swarming_util |
| + |
| + |
| +def _GetSwarmingTaskIdForTryJob(report, revision, step_name): |
| + """Check json output for each task and return id of the one with test result. |
| + """ |
| + if not report: |
| + return None |
| + |
| + http_client = HttpClientAppengine() |
| + 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
|
| + step_name, {}).get('step_metadata', {}).get('swarm_task_ids', []) |
| + |
| + for task_id in task_ids: |
| + output_json = swarming_util.GetIsolatedOutputForTask(task_id, http_client) |
| + if output_json: |
| + for data in output_json.get('per_iteration_data', []): |
| + # If this task doesn't have result, per_iteration_data will look like |
| + # [{}, {}, ...] |
| + if data: |
| + return task_id |
| + |
| + return None |
| class ProcessFlakeTryJobResultPipeline(BasePipeline): |
| @@ -65,5 +88,6 @@ class ProcessFlakeTryJobResultPipeline(BasePipeline): |
| data_point.pass_rate = pass_rate |
| data_point.try_job_id = try_job.try_job_ids[-1] |
| data_point.try_job_url = try_job.flake_results[-1].get('url') |
| - # TODO: Add swarming task data. |
| + data_point.task_id = _GetSwarmingTaskIdForTryJob( |
| + try_job.flake_results[-1].get('report'), revision, step_name) |
| flake_analysis.data_points.append(data_point) |