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

Side by Side Diff: appengine/findit/waterfall/process_flake_swarming_task_result_pipeline.py

Issue 2563383002: [Findit] Flake Checker: Extract commit position and git hash and display to UI for each analyzed bu… (Closed)
Patch Set: Addressing comments + rebase Created 4 years 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
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 import json
5 import logging 6 import logging
6 7
8 from libs.gitiles import commit_util
7 from model.flake.flake_swarming_task import FlakeSwarmingTask 9 from model.flake.flake_swarming_task import FlakeSwarmingTask
8 from model.flake.master_flake_analysis import DataPoint 10 from model.flake.master_flake_analysis import DataPoint
9 from model.flake.master_flake_analysis import MasterFlakeAnalysis 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis
12 from waterfall import buildbot
13 from waterfall import build_util
10 from waterfall.process_base_swarming_task_result_pipeline import ( 14 from waterfall.process_base_swarming_task_result_pipeline import (
11 ProcessBaseSwarmingTaskResultPipeline) 15 ProcessBaseSwarmingTaskResultPipeline)
12 16
13 17
18 def _GetCommitPositionAndGitHash(master_name, builder_name, build_number):
19 """Gets the commit position and git hash of a build.
20
21 Args:
22 master_name (str): The name of the master.
23 builder_name (str): The name of the builder.
24 build_number (int): The build number.
25
26 Returns:
27 commit_position (int), git_hash (str): The git commit position corresponding
28 to the last commit in the build, and the git hash itself.
29 """
30 if build_number < 1:
chanli 2016/12/14 03:41:05 Since build_number can be 0, shouldn't this be if
lijeffrey 2016/12/14 22:15:11 You are absolutely right, good catch!
31 return None, None
32
33 build = build_util.DownloadBuildData(master_name, builder_name, build_number)
34
35 if not build.data:
36 return None, None
37
38 build_data = json.loads(build.data)
39 git_hash = buildbot.GetBuildProperty(
40 build_data.get('properties', []), 'got_revision')
41 commit_position = None
42 changes = build_data.get('sourceStamp', {}).get('changes', [])
43
44 if changes: # pragma: no branch
45 last_commit_message = changes[-1].get('comments')
46 commit_position, _ = commit_util.ExtractCommitPositionAndCodeReviewUrl(
47 last_commit_message)
stgao 2016/12/14 07:58:28 Could we reuse https://cs.chromium.org/chromium/in
lijeffrey 2016/12/14 22:15:11 Done.
48
49 return commit_position, git_hash
50
51
14 class ProcessFlakeSwarmingTaskResultPipeline( 52 class ProcessFlakeSwarmingTaskResultPipeline(
15 ProcessBaseSwarmingTaskResultPipeline): 53 ProcessBaseSwarmingTaskResultPipeline):
16 """A pipeline for monitoring swarming task and processing task result. 54 """A pipeline for monitoring swarming task and processing task result.
17 55
18 This pipeline waits for result for a swarming task and processes the result to 56 This pipeline waits for result for a swarming task and processes the result to
19 generate a dict for statuses for each test run. 57 generate a dict for statuses for each test run.
20 """ 58 """
21 59
22 # Arguments number differs from overridden method - pylint: disable=W0221 60 # Arguments number differs from overridden method - pylint: disable=W0221
23 def _CheckTestsRunStatuses(self, output_json, master_name, 61 def _CheckTestsRunStatuses(self, output_json, master_name,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 flake_swarming_task = FlakeSwarmingTask.Get( 106 flake_swarming_task = FlakeSwarmingTask.Get(
69 master_name, builder_name, build_number, step_name, test_name) 107 master_name, builder_name, build_number, step_name, test_name)
70 flake_swarming_task.tries = tries 108 flake_swarming_task.tries = tries
71 flake_swarming_task.successes = successes 109 flake_swarming_task.successes = successes
72 flake_swarming_task.put() 110 flake_swarming_task.put()
73 111
74 data_point = DataPoint() 112 data_point = DataPoint()
75 data_point.build_number = build_number 113 data_point.build_number = build_number
76 data_point.pass_rate = pass_rate 114 data_point.pass_rate = pass_rate
77 data_point.task_id = flake_swarming_task.task_id 115 data_point.task_id = flake_swarming_task.task_id
116
117 # Include git commit position information about each build that was run.
118 previous_commit, previous_git_hash = _GetCommitPositionAndGitHash(
119 master_name, builder_name, build_number - 1)
120 data_point.previous_commit_position = previous_commit
121 data_point.previous_git_hash = previous_git_hash
122
123 commit_position, git_hash = _GetCommitPositionAndGitHash(
124 master_name, builder_name, build_number)
125 data_point.commit_position = commit_position
126 data_point.git_hash = git_hash
127
78 master_flake_analysis.data_points.append(data_point) 128 master_flake_analysis.data_points.append(data_point)
79 129
80 results = flake_swarming_task.GetFlakeSwarmingTaskData() 130 results = flake_swarming_task.GetFlakeSwarmingTaskData()
81 # TODO(lijeffrey): Determine whether or not this flake swarming task 131 # TODO(lijeffrey): Determine whether or not this flake swarming task
82 # was a cache hit (already ran results for more iterations than were 132 # was a cache hit (already ran results for more iterations than were
83 # requested) and update results['cache_hit'] accordingly. 133 # requested) and update results['cache_hit'] accordingly.
84 master_flake_analysis.swarming_rerun_results.append(results) 134 master_flake_analysis.swarming_rerun_results.append(results)
85 master_flake_analysis.put() 135 master_flake_analysis.put()
86 136
87 return tests_statuses 137 return tests_statuses
88 138
89 def _GetArgs(self, master_name, builder_name, build_number, 139 def _GetArgs(self, master_name, builder_name, build_number,
90 step_name, *args): 140 step_name, *args):
91 master_build_number = args[0] 141 master_build_number = args[0]
92 test_name = args[1] 142 test_name = args[1]
93 version_number = args[2] 143 version_number = args[2]
94 return (master_name, builder_name, build_number, step_name, 144 return (master_name, builder_name, build_number, step_name,
95 master_build_number, test_name, version_number) 145 master_build_number, test_name, version_number)
96 146
97 # Unused Argument - pylint: disable=W0612,W0613 147 # Unused Argument - pylint: disable=W0612,W0613
98 # Arguments number differs from overridden method - pylint: disable=W0221 148 # Arguments number differs from overridden method - pylint: disable=W0221
99 def _GetSwarmingTask(self, master_name, builder_name, build_number, 149 def _GetSwarmingTask(self, master_name, builder_name, build_number,
100 step_name, master_build_number, test_name, _): 150 step_name, master_build_number, test_name, _):
101 # Gets the appropriate kind of swarming task (FlakeSwarmingTask). 151 # Gets the appropriate kind of swarming task (FlakeSwarmingTask).
102 return FlakeSwarmingTask.Get(master_name, builder_name, build_number, 152 return FlakeSwarmingTask.Get(master_name, builder_name, build_number,
103 step_name, test_name) 153 step_name, test_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698