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

Side by Side Diff: appengine/findit/model/flake/base_analysis.py

Issue 2124973003: These are the database objects used while finding the regression range. 1/3 (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
chanli 2016/07/07 23:38:28 2014 -> 2016
caiw 2016/07/14 00:59:40 Done.
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 common import constants 7 from common import constants
8 from common.waterfall import failure_type 8 from common.waterfall import failure_type
9 from model.base_build_model import BaseBuildModel 9 from model.base_build_model import BaseBuildModel
10 from model import analysis_status 10 from model import analysis_status
11 from model import result_status 11 from model import result_status
12 12
13 13
14 class WfAnalysis(BaseBuildModel): 14 class BaseAnalysis(BaseBuildModel):
15 """Represents an analysis of a build of a builder in a Chromium waterfall. 15 """Represents an analysis of a build of a builder in a Chromium waterfall.
16
17 'Wf' is short for waterfall.
18 """ 16 """
19 @staticmethod
20 def _CreateKey(master_name, builder_name, build_number): # pragma: no cover
21 return ndb.Key('WfAnalysis',
22 BaseBuildModel.CreateBuildId(
23 master_name, builder_name, build_number))
24
25 @staticmethod
26 def Create(master_name, builder_name, build_number): # pragma: no cover
27 return WfAnalysis(
28 key=WfAnalysis._CreateKey(master_name, builder_name, build_number))
29
30 @staticmethod
31 def Get(master_name, builder_name, build_number): # pragma: no cover
32 return WfAnalysis._CreateKey(master_name, builder_name, build_number).get()
33 17
34 @property 18 @property
35 def completed(self): 19 def completed(self):
36 return self.status in ( 20 return self.status in (
37 analysis_status.COMPLETED, analysis_status.ERROR) 21 analysis_status.COMPLETED, analysis_status.ERROR)
38 22
39 @property 23 @property
40 def duration(self): 24 def duration(self):
41 if not self.completed or not self.end_time or not self.start_time: 25 if not self.completed or not self.end_time or not self.start_time:
42 return None 26 return None
43 27
44 return int((self.end_time - self.start_time).total_seconds()) 28 return int((self.end_time - self.start_time).total_seconds())
45 29
46 @property 30 @property
47 def failed(self): 31 def failed(self):
48 return self.status == analysis_status.ERROR 32 return self.status == analysis_status.ERROR
49 33
50 @property 34 @property
51 def status_description(self): 35 def status_description(self):
52 return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown') 36 return analysis_status.STATUS_TO_DESCRIPTION.get(self.status, 'Unknown')
53 37
54 @property 38 @property
55 def result_status_description(self): 39 def result_status_description(self):
56 return result_status.RESULT_STATUS_TO_DESCRIPTION.get( 40 return result_status.RESULT_STATUS_TO_DESCRIPTION.get(
57 self.result_status, '') 41 self.result_status, '')
58 42
59 @property 43 @property
60 def correct(self): 44 def correct(self):
stgao 2016/07/08 22:51:27 This seems not belonging to this base class.
caiw 2016/07/14 00:59:40 Done.
61 """Returns whether the analysis result is correct or not. 45 """Returns whether the analysis result is correct or not.
62 46
63 Returns: 47 Returns:
64 True: correct 48 True: correct
65 False: incorrect 49 False: incorrect
66 None: don't know yet. 50 None: don't know yet.
67 """ 51 """
68 if not self.completed or self.failed: 52 if not self.completed or self.failed:
69 return None 53 return None
70 54
(...skipping 13 matching lines...) Expand all
84 68
85 def Reset(self): # pragma: no cover 69 def Reset(self): # pragma: no cover
86 """Resets to the state as if no analysis is run.""" 70 """Resets to the state as if no analysis is run."""
87 self.pipeline_status_path = None 71 self.pipeline_status_path = None
88 self.status = analysis_status.PENDING 72 self.status = analysis_status.PENDING
89 self.request_time = None 73 self.request_time = None
90 self.start_time = None 74 self.start_time = None
91 self.end_time = None 75 self.end_time = None
92 76
93 @property 77 @property
94 def failure_type(self): 78 def failure_type(self):
stgao 2016/07/08 22:51:27 This seems not fit here.
caiw 2016/07/14 00:59:39 Done.
95 if self.build_failure_type is not None: 79 if self.build_failure_type is not None:
96 return self.build_failure_type 80 return self.build_failure_type
97 81
98 # Legacy data don't have property ``build_failure_type``. 82 # Legacy data don't have property ``build_failure_type``.
99 if not self.result: 83 if not self.result:
100 return failure_type.UNKNOWN 84 return failure_type.UNKNOWN
101 85
102 step_failures = self.result.get('failures', []) 86 step_failures = self.result.get('failures', [])
103 if not step_failures: 87 if not step_failures:
104 return failure_type.UNKNOWN 88 return failure_type.UNKNOWN
105 89
106 for step_result in step_failures: 90 for step_result in step_failures:
107 if step_result['step_name'] == constants.COMPILE_STEP_NAME: 91 if step_result['step_name'] == constants.COMPILE_STEP_NAME:
108 return failure_type.COMPILE 92 return failure_type.COMPILE
109 93
110 # Although the failed steps could be infra setup steps like "bot_update", 94 # Although the failed steps could be infra setup steps like "bot_update",
111 # for legacy data we just assume all of them are tests if not compile. 95 # for legacy data we just assume all of them are tests if not compile.
112 return failure_type.TEST 96 return failure_type.TEST
113 97
114 @property 98 @property
115 def failure_type_str(self): 99 def failure_type_str(self):
stgao 2016/07/08 22:51:27 Same here.
caiw 2016/07/14 00:59:39 Done.
116 return failure_type.GetDescriptionForFailureType(self.failure_type) 100 return failure_type.GetDescriptionForFailureType(self.failure_type)
117 101
118 # When the build cycle started.
119 build_start_time = ndb.DateTimeProperty(indexed=True)
120 # Whether the build cycle has completed.
121 build_completed = ndb.BooleanProperty(indexed=False)
122 # Whether it is a compile failure, test failure, infra failure or others.
123 # Refer to common/waterfall/failure_type.py for all the failure types.
124 build_failure_type = ndb.IntegerProperty(indexed=False)
125
126 # The url path to the pipeline status page. 102 # The url path to the pipeline status page.
127 pipeline_status_path = ndb.StringProperty(indexed=False) 103 pipeline_status_path = ndb.StringProperty(indexed=False)
104
128 # The status of the analysis. 105 # The status of the analysis.
129 status = ndb.IntegerProperty( 106 status = ndb.IntegerProperty(
130 default=analysis_status.PENDING, indexed=False) 107 default=analysis_status.PENDING, indexed=False)
131 # When the analysis was requested. 108 # When the analysis was requested.
132 request_time = ndb.DateTimeProperty(indexed=False) 109 request_time = ndb.DateTimeProperty(indexed=False)
133 # When the analysis actually started. 110 # When the analysis actually started.
134 start_time = ndb.DateTimeProperty(indexed=False) 111 start_time = ndb.DateTimeProperty(indexed=False)
135 # When the analysis actually ended. 112 # When the analysis actually ended.
136 end_time = ndb.DateTimeProperty(indexed=False) 113 end_time = ndb.DateTimeProperty(indexed=False)
137 # When the analysis was updated. 114 # When the analysis was updated.
138 updated_time = ndb.DateTimeProperty(indexed=False, auto_now=True) 115 updated_time = ndb.DateTimeProperty(indexed=False, auto_now=True)
139 # Record which version of analysis. 116 # Record which version of analysis.
140 version = ndb.StringProperty(indexed=False) 117 version = ndb.StringProperty(indexed=False)
141
142 # Analysis result for the build failure.
143 not_passed_steps = ndb.StringProperty(indexed=False, repeated=True)
144 result = ndb.JsonProperty(indexed=False, compressed=True)
145 # Suspected CLs we found.
146 suspected_cls = ndb.JsonProperty(indexed=False, compressed=True)
147 # Record the id of try job results of each failure.
148 failure_result_map = ndb.JsonProperty(indexed=False, compressed=True)
149
150 # The actual culprit CLs that are responsible for the failures.
151 culprit_cls = ndb.JsonProperty(indexed=False, compressed=True)
152 # Conclusion of analysis result for the build failure: 'Found' or 'Not Found'.
153 result_status = ndb.IntegerProperty(indexed=True)
154 # Record the history of triage.
155 triage_history = ndb.JsonProperty(indexed=False, compressed=True)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698