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

Side by Side Diff: appengine/findit/model/flake/master_flake_analysis.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
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 base64 5 import base64
6 6
7 from google.appengine.ext import ndb 7 from google.appengine.ext import ndb
8 8
9 from gae_libs.model.versioned_model import VersionedModel 9 from gae_libs.model.versioned_model import VersionedModel
10 from model import result_status 10 from model import result_status
11 from model import triage_status 11 from model import triage_status
12 from model.base_analysis import BaseAnalysis 12 from model.base_analysis import BaseAnalysis
13 from model.base_build_model import BaseBuildModel 13 from model.base_build_model import BaseBuildModel
14 from model.base_triaged_model import TriagedModel 14 from model.base_triaged_model import TriagedModel
15 from model.flake.flake_culprit import FlakeCulprit 15 from model.flake.flake_culprit import FlakeCulprit
16 from model.flake.flake_swarming_task import FlakeSwarmingTaskData 16 from model.flake.flake_swarming_task import FlakeSwarmingTaskData
17 17
18 18
19 class DataPoint(ndb.Model): 19 class DataPoint(ndb.Model):
20 # The build number corresponding to this data point. Only relevant for
21 # analysis at the at the build level.
chanli 2017/01/13 06:01:51 Nit: at the at the
20 build_number = ndb.IntegerProperty(indexed=False) 22 build_number = ndb.IntegerProperty(indexed=False)
23
24 # The pass rate of the test when run against this commit.
21 pass_rate = ndb.FloatProperty(indexed=False) 25 pass_rate = ndb.FloatProperty(indexed=False)
26
27 # The ID of the swarming task responsible for generating this data.
22 task_id = ndb.StringProperty(indexed=False) 28 task_id = ndb.StringProperty(indexed=False)
29
30 # The commit position of this data point.
23 commit_position = ndb.IntegerProperty(indexed=False) 31 commit_position = ndb.IntegerProperty(indexed=False)
32
33 # The git hash of this data point.
24 git_hash = ndb.StringProperty(indexed=False) 34 git_hash = ndb.StringProperty(indexed=False)
35
36 # The commit position of the build preceding this one. Only relevant if this
37 # data point is generated at the build level.
25 previous_build_commit_position = ndb.IntegerProperty(indexed=False) 38 previous_build_commit_position = ndb.IntegerProperty(indexed=False)
39
40 # The git hash of the data point 1 build before this one. Only relevant if
41 # this data point is generated as the result of a flake swarming task.
26 previous_build_git_hash = ndb.StringProperty(indexed=False) 42 previous_build_git_hash = ndb.StringProperty(indexed=False)
43
44 # The list of revisions between this build and the previous build. Only
45 # relevant if this data point is generated as the result of a flake swarming
46 # task.
27 blame_list = ndb.StringProperty(repeated=True) 47 blame_list = ndb.StringProperty(repeated=True)
28 48
49 # The URL to the try job that generated this data point, if any.
50 try_job_url = ndb.StringProperty(indexed=False)
51
52 def GetCommitPosition(self, revision):
53 """Gets the commit position of a revision within blame_list.
54
55 Args:
56 revision (str): The revision to search for.
57
58 Returns:
59 commit_position (int): The calculated commit position of revision.
60 """
61 assert revision in self.blame_list
62
63 for i in range(0, len(self.blame_list)): # pragma: no branch
64 if revision == self.blame_list[i]:
65 return i + self.previous_build_commit_position + 1
66
67 def GetRevisionAtCommitPosition(self, commit_position):
68 """Gets the corresponding revision to commit_position.
69
70 Args:
71 commit_position (int): The commit position for which to find the
72 corresponding revision within self.blame_list.
73
74 Returns:
75 revision (str): The git revision corresponding to commit_position.
76 """
77 length = len(self.blame_list)
78 assert (commit_position > self.commit_position - length and
79 commit_position <= self.commit_position)
80 return self.blame_list[
81 length - (self.commit_position - commit_position) - 1]
82
29 83
30 class MasterFlakeAnalysis( 84 class MasterFlakeAnalysis(
31 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel): 85 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel):
32 """Represents an analysis of a flaky test on a Waterfall test cycle.""" 86 """Represents an analysis of a flaky test on a Waterfall test cycle."""
33 87
34 @ndb.ComputedProperty 88 @ndb.ComputedProperty
35 def step_name(self): 89 def step_name(self):
36 return self.key.pairs()[0][1].split('/')[3] 90 return self.key.pairs()[0][1].split('/')[3]
37 91
38 @ndb.ComputedProperty 92 @ndb.ComputedProperty
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 223
170 # The suspected build number to have introduced the flakiness. 224 # The suspected build number to have introduced the flakiness.
171 suspected_flake_build_number = ndb.IntegerProperty() 225 suspected_flake_build_number = ndb.IntegerProperty()
172 226
173 # The culprit CL associated with the try job results, if any. 227 # The culprit CL associated with the try job results, if any.
174 culprit = ndb.LocalStructuredProperty(FlakeCulprit) 228 culprit = ndb.LocalStructuredProperty(FlakeCulprit)
175 229
176 # The status of try jobs, if any. None if try jobs have not been triggered. 230 # The status of try jobs, if any. None if try jobs have not been triggered.
177 # Status should be PENDING or STARTED when the first try job is triggered, 231 # Status should be PENDING or STARTED when the first try job is triggered,
178 # and COMPLETED when the last one finishes. If any try job ends in error, 232 # and COMPLETED when the last one finishes. If any try job ends in error,
179 # status will be ERROR. 233 # status will be ERROR.
180 try_job_status = ndb.IntegerProperty(indexed=False) 234 try_job_status = ndb.IntegerProperty(indexed=False)
181 235
182 # The data points used to plot the flakiness graph build over build. 236 # The data points used to plot the flakiness graph build over build.
183 data_points = ndb.LocalStructuredProperty( 237 data_points = ndb.LocalStructuredProperty(
184 DataPoint, repeated=True, compressed=True) 238 DataPoint, repeated=True, compressed=True)
185 239
186 # Whether the analysis was triggered by a manual request through check flake, 240 # Whether the analysis was triggered by a manual request through check flake,
187 # Findit's automatic analysis upon detection, or Findit API. 241 # Findit's automatic analysis upon detection, or Findit API.
188 triggering_source = ndb.IntegerProperty(default=None, indexed=True) 242 triggering_source = ndb.IntegerProperty(default=None, indexed=True)
189 243
190 # Who triggered the analysis. Used for differentiating between manual and 244 # Who triggered the analysis. Used for differentiating between manual and
191 # automatic runs, and determining the most active users to gather feedback. 245 # automatic runs, and determining the most active users to gather feedback.
192 triggering_user_email = ndb.StringProperty(default=None, indexed=False) 246 triggering_user_email = ndb.StringProperty(default=None, indexed=False)
193 247
194 # Overall conclusion of analysis result for the flake. Found untriaged, Found 248 # Overall conclusion of analysis result for the flake. Found untriaged, Found
195 # Correct, etc. used to filter what is displayed on the check flake dashboard. 249 # Correct, etc. used to filter what is displayed on the check flake dashboard.
196 result_status = ndb.IntegerProperty(indexed=True) 250 result_status = ndb.IntegerProperty(indexed=True)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698