Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 if this | |
| 21 # data point is generated as the result of a flake swarming task. | |
|
chanli
2017/01/13 00:47:32
Should we mention this is relevant for build level
lijeffrey
2017/01/13 01:39:23
Done.
| |
| 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 git position of this data point. | |
|
chanli
2017/01/13 00:47:33
I don't think git position is the right way to cal
lijeffrey
2017/01/13 01:39:23
Done.
| |
| 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 as the result of a flake swarming taask. | |
|
chanli
2017/01/13 00:47:33
Nit: taask -> task
lijeffrey
2017/01/13 01:39:23
Done.
| |
| 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) |
|
chanli
2017/01/13 00:47:33
Maybe now is a little late.... But why do we need
lijeffrey
2017/01/13 01:39:23
git hash is the useful one, previous build commit
| |
| 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 ID of the try job that generated this data point, if any. | |
| 50 try_job_id = ndb.StringProperty(indexed=False) | |
|
chanli
2017/01/13 00:47:33
As we discussed offline, maybe remove try_job_id f
lijeffrey
2017/01/13 01:39:23
Done.
| |
| 51 | |
| 52 # The URL to the try job that generated this data point, if any. | |
| 53 try_job_url = ndb.StringProperty(indexed=False) | |
| 54 | |
| 55 def GetCommitPosition(self, revision): | |
|
chanli
2017/01/13 00:47:32
I think this function is a little hacky... Althoug
lijeffrey
2017/01/13 01:39:23
Unfortunately blame_list only contains revisions a
| |
| 56 """Gets the commit position of a revision within blame_list. | |
| 57 | |
| 58 Args: | |
| 59 revision (str): The revision to search for. | |
| 60 | |
| 61 Returns: | |
| 62 commit_position (int): The calculated commit position of revision. | |
| 63 """ | |
| 64 assert revision in self.blame_list | |
| 65 | |
| 66 for i in range(0, len(self.blame_list)): # pragma: no branch | |
| 67 if revision == self.blame_list[i]: | |
| 68 return i + self.previous_build_commit_position + 1 | |
| 69 | |
| 70 def GetRevisionAtCommitPosition(self, commit_position): | |
| 71 """Gets the corresponding revision to commit_position. | |
| 72 | |
| 73 Args: | |
| 74 commit_position (int): The commit position for which to find the | |
| 75 corresponding revision within self.blame_list. | |
| 76 | |
| 77 Returns: | |
| 78 revision (str): The git revision corresponding to commit_position. | |
| 79 """ | |
| 80 length = len(self.blame_list) | |
| 81 assert (commit_position > self.commit_position - length and | |
| 82 commit_position <= self.commit_position) | |
| 83 return self.blame_list[ | |
| 84 length - (self.commit_position - commit_position) - 1] | |
| 85 | |
| 29 | 86 |
| 30 class MasterFlakeAnalysis( | 87 class MasterFlakeAnalysis( |
| 31 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel): | 88 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel): |
| 32 """Represents an analysis of a flaky test on a Waterfall test cycle.""" | 89 """Represents an analysis of a flaky test on a Waterfall test cycle.""" |
| 33 | 90 |
| 34 @ndb.ComputedProperty | 91 @ndb.ComputedProperty |
| 35 def step_name(self): | 92 def step_name(self): |
| 36 return self.key.pairs()[0][1].split('/')[3] | 93 return self.key.pairs()[0][1].split('/')[3] |
| 37 | 94 |
| 38 @ndb.ComputedProperty | 95 @ndb.ComputedProperty |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 | 226 |
| 170 # The suspected build number to have introduced the flakiness. | 227 # The suspected build number to have introduced the flakiness. |
| 171 suspected_flake_build_number = ndb.IntegerProperty() | 228 suspected_flake_build_number = ndb.IntegerProperty() |
| 172 | 229 |
| 173 # The culprit CL associated with the try job results, if any. | 230 # The culprit CL associated with the try job results, if any. |
| 174 culprit = ndb.LocalStructuredProperty(FlakeCulprit) | 231 culprit = ndb.LocalStructuredProperty(FlakeCulprit) |
| 175 | 232 |
| 176 # The status of try jobs, if any. None if try jobs have not been triggered. | 233 # 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, | 234 # 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, | 235 # and COMPLETED when the last one finishes. If any try job ends in error, |
| 179 # status will be ERROR. | 236 # status will be ERROR. |
| 180 try_job_status = ndb.IntegerProperty(indexed=False) | 237 try_job_status = ndb.IntegerProperty(indexed=False) |
| 181 | 238 |
| 182 # The data points used to plot the flakiness graph build over build. | 239 # The data points used to plot the flakiness graph build over build. |
| 183 data_points = ndb.LocalStructuredProperty( | 240 data_points = ndb.LocalStructuredProperty( |
| 184 DataPoint, repeated=True, compressed=True) | 241 DataPoint, repeated=True, compressed=True) |
| 185 | 242 |
| 186 # Whether the analysis was triggered by a manual request through check flake, | 243 # Whether the analysis was triggered by a manual request through check flake, |
| 187 # Findit's automatic analysis upon detection, or Findit API. | 244 # Findit's automatic analysis upon detection, or Findit API. |
| 188 triggering_source = ndb.IntegerProperty(default=None, indexed=True) | 245 triggering_source = ndb.IntegerProperty(default=None, indexed=True) |
| 189 | 246 |
| 190 # Who triggered the analysis. Used for differentiating between manual and | 247 # Who triggered the analysis. Used for differentiating between manual and |
| 191 # automatic runs, and determining the most active users to gather feedback. | 248 # automatic runs, and determining the most active users to gather feedback. |
| 192 triggering_user_email = ndb.StringProperty(default=None, indexed=False) | 249 triggering_user_email = ndb.StringProperty(default=None, indexed=False) |
| 193 | 250 |
| 194 # Overall conclusion of analysis result for the flake. Found untriaged, Found | 251 # 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. | 252 # Correct, etc. used to filter what is displayed on the check flake dashboard. |
| 196 result_status = ndb.IntegerProperty(indexed=True) | 253 result_status = ndb.IntegerProperty(indexed=True) |
| OLD | NEW |