Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from google.appengine.ext import ndb | |
| 6 | |
| 7 from common.pipeline_wrapper import BasePipeline | |
| 8 from model.flake.master_flake_analysis import DataPoint | |
| 9 | |
| 10 | |
| 11 class ProcessFlakeTryJobResultPipeline(BasePipeline): | |
| 12 """A pipeline for processing a flake try job result.""" | |
| 13 | |
| 14 # Arguments number differs from overridden method - pylint: disable=W0221 | |
| 15 def run(self, revision, commit_position, try_job_result, urlsafe_try_job_key, | |
| 16 urlsafe_flake_analysis_key): | |
| 17 """Extracts pass rate information and updates flake analysis. | |
| 18 | |
| 19 Args: | |
| 20 revision (str): The git hash the try job was run against. | |
| 21 commit_position (int): The commit position corresponding to |revision|. | |
| 22 try_job_result (dict): The 'result' dict reported by buildbucket. | |
| 23 Example: | |
| 24 { | |
| 25 'cafed52c5f3313646b8e04e05601b5cb98f305b3': { | |
| 26 'browser_tests': { | |
| 27 'status': 'failed', | |
| 28 'failures': ['TabCaptureApiTest.FullscreenEvents'], | |
| 29 'valid': True, | |
| 30 'pass_fail_counts': { | |
| 31 'TabCaptureApiTest.FullscreenEvents': { | |
| 32 'pass_count': 28, | |
| 33 'fail_count': 72 | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 } | |
| 38 } | |
| 39 urlsafe_try_job_key (str): The urlsafe key to the corresponding try job | |
| 40 entity. | |
| 41 urlsafe_flake_analysis_key (str): The urlsafe key for the master flake | |
| 42 analysis entity to be updated. | |
| 43 """ | |
| 44 flake_analysis = ndb.Key(urlsafe=urlsafe_flake_analysis_key).get() | |
| 45 try_job = ndb.Key(urlsafe=urlsafe_try_job_key).get() | |
| 46 assert flake_analysis | |
| 47 assert try_job | |
| 48 | |
| 49 step_name = flake_analysis.step_name | |
| 50 test_name = flake_analysis.test_name | |
| 51 pass_fail_counts = try_job_result[revision][step_name]['pass_fail_counts'] | |
| 52 | |
| 53 if pass_fail_counts: | |
| 54 test_results = pass_fail_counts[test_name] | |
| 55 pass_count = test_results['pass_count'] | |
| 56 fail_count = test_results['fail_count'] | |
| 57 tries = pass_count + fail_count | |
| 58 pass_rate = float(pass_count) / tries | |
| 59 else: # Test does not exist. | |
| 60 pass_rate = -1 | |
| 61 | |
| 62 data_point = DataPoint() | |
| 63 data_point.commit_position = commit_position | |
| 64 data_point.pass_rate = pass_rate | |
| 65 data_point.try_job_id = try_job.try_job_ids[-1] | |
| 66 data_point.try_job_url = try_job.flake_results[-1].get('url') | |
| 67 # TODO: Add swarming task data. | |
| 68 flake_analysis.data_points.append(data_point) | |
|
stgao
2017/01/12 08:04:16
Do we need a put to update it in NDB?
lijeffrey
2017/01/12 09:52:52
good catch. Done.
| |
| OLD | NEW |