| 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 from google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 6 | 6 |
| 7 from model.base_suspected_cl import BaseSuspectedCL |
| 7 | 8 |
| 8 class WfSuspectedCL(ndb.Model): | 9 |
| 10 class WfSuspectedCL(BaseSuspectedCL): |
| 9 """Represents suspected cl that causes failures on Chromium waterfall builds. | 11 """Represents suspected cl that causes failures on Chromium waterfall builds. |
| 10 | 12 |
| 11 'Wf' is short for waterfall. | 13 'Wf' is short for waterfall. |
| 12 """ | 14 """ |
| 13 | 15 |
| 14 # Repo or project name of the suspected CL, eg: chromium, etc. | 16 # The dict of builds in which the suspected CL caused some breakage. |
| 15 repo_name = ndb.StringProperty(indexed=True) | 17 # The dict will look like: |
| 16 | 18 # { |
| 17 # The Git hash revision of the suspected CL. | 19 # 'm1/b1/123': [ |
| 18 revision = ndb.StringProperty(indexed=False) | 20 # { |
| 19 | 21 # 'failure_type': 'compile', |
| 20 # The commit position of the suspected CL. | 22 # 'failures': None, |
| 21 # Might not be available for some repo. | 23 # 'status': CORRECT, |
| 22 commit_position = ndb.IntegerProperty(indexed=False) | 24 # 'approaches': [HEURISTIC, TRY_JOB], |
| 23 | 25 # 'top_score': 5, |
| 24 # The list of builds in which the suspected CL caused some breakage. | 26 # 'Confidence': 97.9 |
| 25 builds = ndb.JsonProperty(indexed=False) | 27 # } |
| 28 # ], |
| 29 # 'm2/b2/234': [ |
| 30 # { |
| 31 # 'failure_type': 'test', |
| 32 # 'failures': { |
| 33 # 's1': ['t1', 't2'] |
| 34 # }, |
| 35 # 'status': CORRECT, |
| 36 # 'approachES': [HEURISTIC, TRY_JOB], |
| 37 # 'top_score': None, |
| 38 # 'Confidence': 80.0 |
| 39 # }, |
| 40 # { |
| 41 # 'failure_type': 'test', |
| 42 # 'failures': { |
| 43 # 's1': ['t3'] |
| 44 # }, |
| 45 # 'status': INCORRECT, |
| 46 # 'approaches': [HEURISTIC], |
| 47 # 'top_score': 2, |
| 48 # 'Confidence': 50.5 |
| 49 # }, |
| 50 # { |
| 51 # 'failure_type': 'test', |
| 52 # 'failures': { |
| 53 # 's2': [] |
| 54 # }, |
| 55 # 'status': INCORRECT, |
| 56 # 'approaches': [HEURISTIC], |
| 57 # 'top_score': 1, |
| 58 # 'Confidence': 30.7 |
| 59 # } |
| 60 # ] |
| 61 # } |
| 62 builds = ndb.JsonProperty(indexed=False, compressed=True) |
| 26 | 63 |
| 27 # Is the suspected CL the culprit or not. | 64 # Is the suspected CL the culprit or not. |
| 28 is_culprit = ndb.BooleanProperty(indexed=True, default=None) | 65 # If not triaged, the status would be None. |
| 66 # Other possible status are: suspected_cl_status.CORRECT, |
| 67 # suspected_cl_status.INCORRECT, suspected_cl_status.PARTIALLY_CORRECT and |
| 68 # suspected_cl_status.PARTIALLY_TRIAGED. |
| 69 status = ndb.IntegerProperty(indexed=True, default=None) |
| 29 | 70 |
| 30 # From which approach do we get this suspected CL: HEURISTIC, TRY_JOB or BOTH. | 71 # From which approach do we get this suspected CL: |
| 31 approach = ndb.IntegerProperty(indexed=True) | 72 # analysis_approach_type.HEURISTIC, analysis_approach_type.TRY_JOB or both. |
| 73 approaches = ndb.IntegerProperty(indexed=True, repeated=True) |
| 32 | 74 |
| 33 # Failure type: failure_type.COMPILE or failure_type.TEST. | 75 # Failure type: failure_type.COMPILE, failure_type.TEST, |
| 34 failure_type = ndb.IntegerProperty(indexed=True) | 76 # and if a CL caused a compile failure and another test failure, |
| 35 | 77 # the failure_type would be both. |
| 36 @property | 78 failure_type = ndb.IntegerProperty(indexed=True, repeated=True) |
| 37 def project_name(self): | |
| 38 return self.repo_name | |
| 39 | |
| 40 @classmethod | |
| 41 def _CreateKey(cls, repo_name, revision): # pragma: no cover | |
| 42 return ndb.Key(cls.__name__, '%s/%s' % (repo_name, revision)) | |
| 43 | 79 |
| 44 @classmethod | 80 @classmethod |
| 45 def Create(cls, repo_name, revision, commit_position): # pragma: no cover | 81 def Create(cls, repo_name, revision, commit_position): # pragma: no cover |
| 46 instance = cls(key=cls._CreateKey(repo_name, revision)) | 82 instance = cls(key=cls._CreateKey(repo_name, revision)) |
| 47 instance.repo_name = repo_name | 83 instance.repo_name = repo_name |
| 48 instance.revision = revision | 84 instance.revision = revision |
| 49 instance.commit_position = commit_position | 85 instance.commit_position = commit_position |
| 50 instance.builds = [] | 86 instance.builds = {} |
| 51 return instance | 87 return instance |
| 52 | |
| 53 @classmethod | |
| 54 def Get(cls, repo_name, revision): # pragma: no cover | |
| 55 return cls._CreateKey(repo_name, revision).get() | |
| OLD | NEW |