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

Side by Side Diff: appengine/findit/waterfall/test/suspected_cl_util_test.py

Issue 2230103002: [Findit] Pipeline change to save suspected cls to data store. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@0808-resubmit-suspected_cl_model
Patch Set: Modified pipelines after design change. Created 4 years, 3 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
(Empty)
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
3 # found in the LICENSE file.
4
5 from common.waterfall import failure_type
6 from model import analysis_approach_type
7 from model import suspected_cl_status
8 from model.wf_suspected_cl import WfSuspectedCL
9 from waterfall import suspected_cl_util
10 from waterfall.test import wf_testcase
11
12
13 class SuspectedCLUtilTest(wf_testcase.WaterfallTestCase):
14
15 def testCreateWfSuspectedCL(self):
16 approach = analysis_approach_type.HEURISTIC
17 master_name = 'm'
18 builder_name = 'b'
19 build_number = 123
20 compile_failure_type = failure_type.COMPILE
21 repo_name = 'chromium'
22 revision = 'r1'
23 commit_position = 1
24 failures = {'compile': []}
25 top_score = 5
26
27 self.assertIsNone(WfSuspectedCL.Get(repo_name, revision))
28
29 suspected_cl_util.UpdateSuspectedCL(
30 repo_name, revision, commit_position, approach, master_name,
31 builder_name, build_number, compile_failure_type, failures, top_score)
32
33 expected_builds = {
34 '%s/%s/%d' % (master_name, builder_name, build_number ):{
35 'approach': approach,
36 'failure_type': compile_failure_type,
37 'failures': failures,
38 'status': None,
39 'top_score': top_score
40 }
41 }
42
43 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
44
45 self.assertIsNotNone(suspected_cl)
46 self.assertEqual(analysis_approach_type.HEURISTIC, suspected_cl.approach)
47 self.assertEqual(compile_failure_type, suspected_cl.failure_type)
48 self.assertEqual(expected_builds, suspected_cl.builds)
49
50 def testUpdateWfSuspectedCLAddAnotherApproach(self):
51 approach = analysis_approach_type.TRY_JOB
52 master_name = 'm'
53 builder_name = 'b'
54 build_number = 122
55 test_failure_type = failure_type.TEST
56 repo_name = 'chromium'
57 revision = 'r2'
58 commit_position = 2
59 failures = {'step_1': ['test1', 'test2']}
60 top_score = None
61
62 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
63 suspected_cl.approach = analysis_approach_type.HEURISTIC
64 suspected_cl.builds = {
65 '%s/%s/%d' % (master_name, builder_name, build_number ): {
66 'approach': analysis_approach_type.HEURISTIC,
67 'failure_type': test_failure_type,
68 'failures': failures,
69 'status': None,
70 'top_score': 4
71 }
72 }
73 suspected_cl.failure_type = test_failure_type
74 suspected_cl.put()
75
76 suspected_cl_util.UpdateSuspectedCL(
77 repo_name, revision, commit_position, approach, master_name,
78 builder_name, build_number, test_failure_type, failures, top_score)
79
80 expected_builds = {
81 '%s/%s/%d' % (master_name, builder_name, build_number ): {
82 'approach': analysis_approach_type.BOTH,
83 'failure_type': test_failure_type,
84 'failures': failures,
85 'status': None,
86 'top_score': 4
87 }
88 }
89
90 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
91
92 self.assertIsNotNone(suspected_cl)
93 self.assertEqual(analysis_approach_type.BOTH, suspected_cl.approach)
94 self.assertEqual(test_failure_type, suspected_cl.failure_type)
95 self.assertEqual(expected_builds, suspected_cl.builds)
96
97 def testUpdateWfSuspectedCLAddAnotherHeuristic(self):
98 approach = analysis_approach_type.HEURISTIC
99 master_name = 'm'
100 builder_name = 'b'
101 build_number = 122
102 test_failure_type = failure_type.TEST
103 repo_name = 'chromium'
104 revision = 'r2'
105 commit_position = 2
106 failures = {'step_1': ['test1', 'test2']}
107 top_score = 4
108
109 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
110 suspected_cl.approach = analysis_approach_type.HEURISTIC
111 suspected_cl.builds = {
112 '%s/%s/%d' % (master_name, builder_name, build_number-1): {
113 'approach': analysis_approach_type.HEURISTIC,
114 'failure_type': test_failure_type,
115 'failures': {'step': ['test']},
116 'status': suspected_cl_status.CORRECT,
117 'top_score': 4
118 },
119 '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
120 'approach': analysis_approach_type.HEURISTIC,
121 'failure_type': test_failure_type,
122 'failures': failures,
123 'status': suspected_cl_status.CORRECT,
124 'top_score': 4
125 }
126 }
127 suspected_cl.failure_type = test_failure_type
128 suspected_cl.put()
129
130 suspected_cl_util.UpdateSuspectedCL(
131 repo_name, revision, commit_position, approach, master_name,
132 builder_name, build_number, test_failure_type, failures, top_score)
133
134 expected_builds = {
135 '%s/%s/%d' % (master_name, builder_name, build_number-1): {
136 'approach': analysis_approach_type.HEURISTIC,
137 'failure_type': test_failure_type,
138 'failures': {'step': ['test']},
139 'status': suspected_cl_status.CORRECT,
140 'top_score': 4
141 },
142 '%s/%s/%d' % (master_name, builder_name, build_number - 2): {
143 'approach': analysis_approach_type.HEURISTIC,
144 'failure_type': test_failure_type,
145 'failures': failures,
146 'status': suspected_cl_status.CORRECT,
147 'top_score': 4
148 },
149 '%s/%s/%d' % (master_name, builder_name, build_number ): {
150 'approach': analysis_approach_type.HEURISTIC,
151 'failure_type': test_failure_type,
152 'failures': failures,
153 'status': suspected_cl_status.CORRECT,
154 'top_score': 4
155 }
156 }
157
158 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
159
160 self.assertIsNotNone(suspected_cl)
161 self.assertEqual(analysis_approach_type.HEURISTIC, suspected_cl.approach)
162 self.assertEqual(test_failure_type, suspected_cl.failure_type)
163 self.assertEqual(expected_builds, suspected_cl.builds)
164 #
165 #
166 # def testUpdateWfSuspectedCLUpdateStatusBasedOnSameFailure(self):
167 # approach = analysis_approach_type.HEURISTIC
168 # master_name = 'm'
169 # builder_name = 'b'
170 # build_number = 122
171 # test_failure_type = failure_type.TEST
172 # repo_name = 'chromium'
173 # revision = 'r2'
174 # commit_position = 2
175 # failures = {'step_1': ['test1', 'test2']}
176 # top_score = 4
177 #
178 # suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
179 # suspected_cl.approach = analysis_approach_type.HEURISTIC
180 # suspected_cl.builds = {
181 # '%s/%s/%d' % (master_name, builder_name, build_number - 1): {
182 # 'approach': analysis_approach_type.HEURISTIC,
183 # 'failure_type': test_failure_type,
184 # 'failures': failures,
185 # 'status': None,
186 # 'top_score': 4
187 # }
188 # }
189 # suspected_cl.failure_type = test_failure_type
190 # suspected_cl.put()
191 #
192 # suspected_cl_util.UpdateSuspectedCL(
193 # repo_name, revision, commit_position, approach, master_name,
194 # builder_name, build_number, test_failure_type, failures, top_score)
195 #
196 # expected_builds = {
197 # '%s/%s/%d' % (master_name, builder_name, build_number - 1): {
198 # 'approach': analysis_approach_type.HEURISTIC,
199 # 'failure_type': test_failure_type,
200 # 'failures': failures,
201 # 'status': None,
202 # 'top_score': 4
203 # },
204 # '%s/%s/%d' % (master_name, builder_name, build_number): {
205 # 'approach': analysis_approach_type.HEURISTIC,
206 # 'failure_type': test_failure_type,
207 # 'failures': failures,
208 # 'status': None,
209 # 'top_score': 4
210 # }
211 # }
212 #
213 # suspected_cl = WfSuspectedCL.Get(repo_name, revision)
214 #
215 # self.assertIsNotNone(suspected_cl)
216 # self.assertEqual(analysis_approach_type.HEURISTIC, suspected_cl.approach)
217 # self.assertEqual(test_failure_type, suspected_cl.failure_type)
218 # self.assertEqual(expected_builds, suspected_cl.builds)
chanli 2016/09/12 20:56:16 This part has been removed.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698