Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: appengine/findit/waterfall/flake/process_flake_try_job_result_pipeline.py

Issue 2630433002: Findit] Flake Checker: Pipeline to trigger try jobs to identify flake culprits (Closed)
Patch Set: Addressing comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 'report': {
26 'metadata': {},
27 'result': {
28 'cafed52c5f3313646b8e04e05601b5cb98f305b3': {
29 'browser_tests': {
30 'status': 'failed',
31 'failures': ['TabCaptureApiTest.FullscreenEvents'],
32 'valid': True,
33 'pass_fail_counts': {
34 'TabCaptureApiTest.FullscreenEvents': {
35 'pass_count': 28,
36 'fail_count': 72
37 }
38 }
39 }
40 }
41 }
42 }
43 urlsafe_try_job_key (str): The urlsafe key to the corresponding try job
44 entity.
45 urlsafe_flake_analysis_key (str): The urlsafe key for the master flake
46 analysis entity to be updated.
47 """
48 flake_analysis = ndb.Key(urlsafe=urlsafe_flake_analysis_key).get()
49 try_job = ndb.Key(urlsafe=urlsafe_try_job_key).get()
50 assert flake_analysis
51 assert try_job
52
53 step_name = flake_analysis.step_name
54 test_name = flake_analysis.test_name
55 result = try_job_result['report']['result']
56 pass_fail_counts = result[revision][step_name].get('pass_fail_counts', {})
57
58 if pass_fail_counts:
59 test_results = pass_fail_counts[test_name]
60 pass_count = test_results['pass_count']
61 fail_count = test_results['fail_count']
62 tries = pass_count + fail_count
63 pass_rate = float(pass_count) / tries
64 else: # Test does not exist.
65 pass_rate = -1
66
67 data_point = DataPoint()
68 data_point.commit_position = commit_position
69 data_point.git_hash = revision
70 data_point.pass_rate = pass_rate
71 data_point.try_job_url = try_job.flake_results[-1].get('url')
72 # TODO(chanli): Add swarming task data.
73 flake_analysis.data_points.append(data_point)
74 flake_analysis.put()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698