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. | |
| 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. | |
| 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. | |
| 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 ID of the try job that generated this data point, if any. | |
| 50 try_job_id = ndb.StringProperty(indexed=False) | |
| 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): | |
| 56 """Gets the commit position of a revision within blame_list. | |
| 57 | |
| 58 It should be noted that commit position isn't guaranteed to be reliable | |
| 59 (monotonically increasing by increments of 1) 100% of the time. Should | |
|
stgao
2017/01/12 08:04:16
Per my meeting with Robbie, commit position is rel
lijeffrey
2017/01/12 09:52:52
Done.
| |
| 60 this be the case, commit position should not be used. | |
| 61 | |
| 62 Args: | |
| 63 revision (str): The revision to search for. | |
| 64 | |
| 65 Returns: | |
| 66 commit_position (int): The calculated commit position of revision. | |
| 67 """ | |
| 68 assert revision in self.blame_list | |
| 69 | |
| 70 for i in range(0, len(self.blame_list)): # pragma: no branch | |
| 71 if revision == self.blame_list[i]: | |
| 72 return self.commit_position - i | |
| 73 | |
| 74 def GetRevisionAtCommitPosition(self, commit_position): | |
| 75 """Gets the corresponding revision to commit_position. | |
| 76 | |
| 77 Args: | |
| 78 commit_position (int): The commit position for which to find the | |
| 79 corresponding revision within self.blame_list. | |
| 80 | |
| 81 Returns: | |
| 82 revision (str): The git revision corresponding to commit_position. | |
| 83 """ | |
| 84 assert (commit_position > self.commit_position - len(self.blame_list) and | |
| 85 commit_position <= self.commit_position) | |
| 86 return self.blame_list[self.commit_position - commit_position] | |
| 87 | |
| 29 | 88 |
| 30 class MasterFlakeAnalysis( | 89 class MasterFlakeAnalysis( |
| 31 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel): | 90 BaseAnalysis, BaseBuildModel, VersionedModel, TriagedModel): |
| 32 """Represents an analysis of a flaky test on a Waterfall test cycle.""" | 91 """Represents an analysis of a flaky test on a Waterfall test cycle.""" |
| 33 | 92 |
| 34 @ndb.ComputedProperty | 93 @ndb.ComputedProperty |
| 35 def step_name(self): | 94 def step_name(self): |
| 36 return self.key.pairs()[0][1].split('/')[3] | 95 return self.key.pairs()[0][1].split('/')[3] |
| 37 | 96 |
| 38 @ndb.ComputedProperty | 97 @ndb.ComputedProperty |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 # Findit's automatic analysis upon detection, or Findit API. | 246 # Findit's automatic analysis upon detection, or Findit API. |
| 188 triggering_source = ndb.IntegerProperty(default=None, indexed=True) | 247 triggering_source = ndb.IntegerProperty(default=None, indexed=True) |
| 189 | 248 |
| 190 # Who triggered the analysis. Used for differentiating between manual and | 249 # Who triggered the analysis. Used for differentiating between manual and |
| 191 # automatic runs, and determining the most active users to gather feedback. | 250 # automatic runs, and determining the most active users to gather feedback. |
| 192 triggering_user_email = ndb.StringProperty(default=None, indexed=False) | 251 triggering_user_email = ndb.StringProperty(default=None, indexed=False) |
| 193 | 252 |
| 194 # Overall conclusion of analysis result for the flake. Found untriaged, Found | 253 # 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. | 254 # Correct, etc. used to filter what is displayed on the check flake dashboard. |
| 196 result_status = ndb.IntegerProperty(indexed=True) | 255 result_status = ndb.IntegerProperty(indexed=True) |
| OLD | NEW |