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

Side by Side Diff: appengine/findit/waterfall/test/identify_try_job_culprit_pipeline_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: . Created 4 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 testing_utils import testing 5 from testing_utils import testing
6 6
7 from common.git_repository import GitRepository 7 from common.git_repository import GitRepository
8 from common.waterfall import failure_type 8 from common.waterfall import failure_type
9 from model import analysis_approach_type
9 from model import analysis_status 10 from model import analysis_status
10 from model import result_status 11 from model import result_status
11 from model.wf_analysis import WfAnalysis 12 from model.wf_analysis import WfAnalysis
13 from model.wf_suspected_cl import WfSuspectedCL
12 from model.wf_try_job import WfTryJob 14 from model.wf_try_job import WfTryJob
13 from model.wf_try_job_data import WfTryJobData 15 from model.wf_try_job_data import WfTryJobData
14 from waterfall import identify_try_job_culprit_pipeline 16 from waterfall import identify_try_job_culprit_pipeline
15 from waterfall.identify_try_job_culprit_pipeline import( 17 from waterfall.identify_try_job_culprit_pipeline import(
16 IdentifyTryJobCulpritPipeline) 18 IdentifyTryJobCulpritPipeline)
17 19
18 20
19 class IdentifyTryJobCulpritPipelineTest(testing.AppengineTestCase): 21 class IdentifyTryJobCulpritPipelineTest(testing.AppengineTestCase):
20 22
21 def _MockGetChangeLog(self, revision): 23 def _MockGetChangeLog(self, revision):
22 class MockedChangeLog(object): 24 class MockedChangeLog(object):
23 25
24 def __init__(self, commit_position, code_review_url): 26 def __init__(self, commit_position, code_review_url):
25 self.commit_position = commit_position 27 self.commit_position = commit_position
26 self.code_review_url = code_review_url 28 self.code_review_url = code_review_url
27 29
28 mock_change_logs = {} 30 mock_change_logs = {}
29 mock_change_logs['rev1'] = MockedChangeLog('1', 'url_1') 31 mock_change_logs['rev1'] = MockedChangeLog(1, 'url_1')
30 mock_change_logs['rev2'] = MockedChangeLog('2', 'url_2') 32 mock_change_logs['rev2'] = MockedChangeLog(2, 'url_2')
31 return mock_change_logs.get(revision) 33 return mock_change_logs.get(revision)
32 34
33 def setUp(self): 35 def setUp(self):
34 super(IdentifyTryJobCulpritPipelineTest, self).setUp() 36 super(IdentifyTryJobCulpritPipelineTest, self).setUp()
35 37
36 self.mock(GitRepository, 'GetChangeLog', self._MockGetChangeLog) 38 self.mock(GitRepository, 'GetChangeLog', self._MockGetChangeLog)
37 39
38 def testGetFailedRevisionFromResultsDict(self): 40 def testGetFailedRevisionFromResultsDict(self):
39 self.assertIsNone( 41 self.assertIsNone(
40 identify_try_job_culprit_pipeline._GetFailedRevisionFromResultsDict({})) 42 identify_try_job_culprit_pipeline._GetFailedRevisionFromResultsDict({}))
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 def testGetResultAnalysisStatusWithTryJobCulpritNotFoundUntriaged(self): 96 def testGetResultAnalysisStatusWithTryJobCulpritNotFoundUntriaged(self):
95 # Heuristic analysis provided no results, but the try job found a culprit. 97 # Heuristic analysis provided no results, but the try job found a culprit.
96 analysis = WfAnalysis.Create('m', 'b', 1) 98 analysis = WfAnalysis.Create('m', 'b', 1)
97 analysis.result_status = result_status.NOT_FOUND_UNTRIAGED 99 analysis.result_status = result_status.NOT_FOUND_UNTRIAGED
98 analysis.put() 100 analysis.put()
99 101
100 result = { 102 result = {
101 'culprit': { 103 'culprit': {
102 'compile': { 104 'compile': {
103 'revision': 'rev1', 105 'revision': 'rev1',
104 'commit_position': '1', 106 'commit_position': 1,
105 'url': 'url_1', 107 'url': 'url_1',
106 'repo_name': 'chromium' 108 'repo_name': 'chromium'
107 } 109 }
108 } 110 }
109 } 111 }
110 112
111 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 113 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
112 analysis, result) 114 analysis, result)
113 115
114 self.assertEqual(status, result_status.FOUND_UNTRIAGED) 116 self.assertEqual(status, result_status.FOUND_UNTRIAGED)
115 117
116 def testGetResultAnalysisStatusWithTryJobCulpritNotFoundCorrect(self): 118 def testGetResultAnalysisStatusWithTryJobCulpritNotFoundCorrect(self):
117 # Heuristic analysis found no results, which was correct. In this case, the 119 # Heuristic analysis found no results, which was correct. In this case, the
118 # try job result is actually a false positive. 120 # try job result is actually a false positive.
119 analysis = WfAnalysis.Create('m', 'b', 1) 121 analysis = WfAnalysis.Create('m', 'b', 1)
120 analysis.result_status = result_status.NOT_FOUND_CORRECT 122 analysis.result_status = result_status.NOT_FOUND_CORRECT
121 analysis.put() 123 analysis.put()
122 124
123 result = { 125 result = {
124 'culprit': { 126 'culprit': {
125 'compile': { 127 'compile': {
126 'revision': 'rev1', 128 'revision': 'rev1',
127 'commit_position': '1', 129 'commit_position': 1,
128 'url': 'url_1', 130 'url': 'url_1',
129 'repo_name': 'chromium' 131 'repo_name': 'chromium'
130 } 132 }
131 } 133 }
132 } 134 }
133 135
134 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 136 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
135 analysis, result) 137 analysis, result)
136 138
137 self.assertEqual(status, result_status.FOUND_UNTRIAGED) 139 self.assertEqual(status, result_status.FOUND_UNTRIAGED)
138 140
139 def testGetResultanalysisStatusWithTryJobCulpritNotFoundIncorrect(self): 141 def testGetResultanalysisStatusWithTryJobCulpritNotFoundIncorrect(self):
140 # Heuristic analysis found no results and was triaged to incorrect before a 142 # Heuristic analysis found no results and was triaged to incorrect before a
141 # try job result was found. In this case the try job result should override 143 # try job result was found. In this case the try job result should override
142 # the heuristic result. 144 # the heuristic result.
143 analysis = WfAnalysis.Create('m', 'b', 1) 145 analysis = WfAnalysis.Create('m', 'b', 1)
144 analysis.result_status = result_status.NOT_FOUND_INCORRECT 146 analysis.result_status = result_status.NOT_FOUND_INCORRECT
145 analysis.put() 147 analysis.put()
146 148
147 result = { 149 result = {
148 'culprit': { 150 'culprit': {
149 'compile': { 151 'compile': {
150 'revision': 'rev1', 152 'revision': 'rev1',
151 'commit_position': '1', 153 'commit_position': 1,
152 'url': 'url_1', 154 'url': 'url_1',
153 'repo_name': 'chromium' 155 'repo_name': 'chromium'
154 } 156 }
155 } 157 }
156 } 158 }
157 159
158 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 160 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
159 analysis, result) 161 analysis, result)
160 162
161 self.assertEqual(status, result_status.FOUND_UNTRIAGED) 163 self.assertEqual(status, result_status.FOUND_UNTRIAGED)
162 164
163 def testGetResultanalysisStatusWithTryJobCulpritNoHeuristicResult(self): 165 def testGetResultanalysisStatusWithTryJobCulpritNoHeuristicResult(self):
164 # In this case, the try job found a result before the heuristic result is 166 # In this case, the try job found a result before the heuristic result is
165 # available. This case should generally never happen, as heuristic analysis 167 # available. This case should generally never happen, as heuristic analysis
166 # is usually much faster than try jobs. 168 # is usually much faster than try jobs.
167 analysis = WfAnalysis.Create('m', 'b', 1) 169 analysis = WfAnalysis.Create('m', 'b', 1)
168 analysis.put() 170 analysis.put()
169 171
170 result = { 172 result = {
171 'culprit': { 173 'culprit': {
172 'compile': { 174 'compile': {
173 'revision': 'rev1', 175 'revision': 'rev1',
174 'commit_position': '1', 176 'commit_position': 1,
175 'url': 'url_1', 177 'url': 'url_1',
176 'repo_name': 'chromium' 178 'repo_name': 'chromium'
177 } 179 }
178 } 180 }
179 } 181 }
180 182
181 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 183 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
182 analysis, result) 184 analysis, result)
183 185
184 self.assertEqual(status, result_status.FOUND_UNTRIAGED) 186 self.assertEqual(status, result_status.FOUND_UNTRIAGED)
(...skipping 14 matching lines...) Expand all
199 # In this case, heuristic analysis found the correct culprit. The try job 201 # In this case, heuristic analysis found the correct culprit. The try job
200 # result should not overwrite it. 202 # result should not overwrite it.
201 analysis = WfAnalysis.Create('m', 'b', 1) 203 analysis = WfAnalysis.Create('m', 'b', 1)
202 analysis.result_status = result_status.FOUND_CORRECT 204 analysis.result_status = result_status.FOUND_CORRECT
203 analysis.put() 205 analysis.put()
204 206
205 result = { 207 result = {
206 'culprit': { 208 'culprit': {
207 'compile': { 209 'compile': {
208 'revision': 'rev1', 210 'revision': 'rev1',
209 'commit_position': '1', 211 'commit_position': 1,
210 'url': 'url_1', 212 'url': 'url_1',
211 'repo_name': 'chromium' 213 'repo_name': 'chromium'
212 } 214 }
213 } 215 }
214 } 216 }
215 217
216 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 218 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
217 analysis, result) 219 analysis, result)
218 self.assertEqual(status, result_status.FOUND_CORRECT) 220 self.assertEqual(status, result_status.FOUND_CORRECT)
219 221
(...skipping 21 matching lines...) Expand all
241 243
242 result = {} 244 result = {}
243 245
244 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus( 246 status = identify_try_job_culprit_pipeline._GetResultAnalysisStatus(
245 analysis, result) 247 analysis, result)
246 self.assertEqual(status, result_status.NOT_FOUND_INCORRECT) 248 self.assertEqual(status, result_status.NOT_FOUND_INCORRECT)
247 249
248 def testGetSuspectedCLsForCompileTryJob(self): 250 def testGetSuspectedCLsForCompileTryJob(self):
249 heuristic_suspected_cl = { 251 heuristic_suspected_cl = {
250 'revision': 'rev1', 252 'revision': 'rev1',
251 'commit_position': '1', 253 'commit_position': 1,
252 'url': 'url_1', 254 'url': 'url_1',
253 'repo_name': 'chromium' 255 'repo_name': 'chromium'
254 } 256 }
255 257
256 compile_suspected_cl = { 258 compile_suspected_cl = {
257 'revision': 'rev2', 259 'revision': 'rev2',
258 'commit_position': '2', 260 'commit_position': 2,
259 'url': 'url_2', 261 'url': 'url_2',
260 'repo_name': 'chromium' 262 'repo_name': 'chromium'
261 } 263 }
262 264
263 analysis = WfAnalysis.Create('m', 'b', 1) 265 analysis = WfAnalysis.Create('m', 'b', 1)
264 analysis.suspected_cls = [heuristic_suspected_cl] 266 analysis.suspected_cls = [heuristic_suspected_cl]
265 analysis.put() 267 analysis.put()
266 268
267 result = { 269 try_job_suspected_cls = [compile_suspected_cl]
268 'culprit': {
269 'compile': compile_suspected_cl
270 }
271 }
272 270
273 self.assertEqual( 271 self.assertEqual(
274 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 272 identify_try_job_culprit_pipeline._GetSuspectedCLs(
273 analysis, try_job_suspected_cls),
275 [heuristic_suspected_cl, compile_suspected_cl]) 274 [heuristic_suspected_cl, compile_suspected_cl])
276 275
277 def testGetSuspectedCLsForTestTryJobAndHeuristicResultsSame(self): 276 def testGetSuspectedCLsForTestTryJobAndHeuristicResultsSame(self):
278 suspected_cl = { 277 suspected_cl = {
279 'revision': 'rev1', 278 'revision': 'rev1',
280 'commit_position': '1', 279 'commit_position': 1,
281 'url': 'url_1', 280 'url': 'url_1',
282 'repo_name': 'chromium' 281 'repo_name': 'chromium'
283 } 282 }
284 283
285 analysis = WfAnalysis.Create('m', 'b', 1) 284 analysis = WfAnalysis.Create('m', 'b', 1)
286 analysis.suspected_cls = [suspected_cl] 285 analysis.suspected_cls = [suspected_cl]
287 analysis.put() 286 analysis.put()
288 287
289 result = { 288 try_job_suspected_cls = [suspected_cl]
290 'culprit': {
291 'compile': suspected_cl
292 }
293 }
294 289
295 self.assertEqual( 290 self.assertEqual(
296 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 291 identify_try_job_culprit_pipeline._GetSuspectedCLs(
297 [suspected_cl]) 292 analysis, try_job_suspected_cls), [suspected_cl])
298 293
299 def testGetSuspectedCLsForTestTryJob(self): 294 def testGetSuspectedCLsForTestTryJob(self):
300 suspected_cl1 = { 295 suspected_cl1 = {
301 'revision': 'rev1', 296 'revision': 'rev1',
302 'commit_position': '1', 297 'commit_position': 1,
303 'url': 'url_1', 298 'url': 'url_1',
304 'repo_name': 'chromium' 299 'repo_name': 'chromium'
305 } 300 }
306 suspected_cl2 = { 301 suspected_cl2 = {
307 'revision': 'rev2', 302 'revision': 'rev2',
308 'commit_position': '2', 303 'commit_position': 2,
309 'url': 'url_2', 304 'url': 'url_2',
310 'repo_name': 'chromium' 305 'repo_name': 'chromium'
311 } 306 }
312 suspected_cl3 = { 307 suspected_cl3 = {
313 'revision': 'rev3', 308 'revision': 'rev3',
314 'commit_position': '3', 309 'commit_position': 3,
315 'url': 'url_3', 310 'url': 'url_3',
316 'repo_name': 'chromium' 311 'repo_name': 'chromium'
317 } 312 }
318 313
319 analysis = WfAnalysis.Create('m', 'b', 1) 314 analysis = WfAnalysis.Create('m', 'b', 1)
320 analysis.suspected_cls = [] 315 analysis.suspected_cls = [suspected_cl3]
321 analysis.put() 316 analysis.put()
322 317
323 result = { 318 result = {
324 'culprit': { 319 'culprit': {
325 'a_test': { 320 'a_test': {
326 'tests': { 321 'tests': {
327 'a_test1': suspected_cl1, 322 'a_test1': suspected_cl1,
328 'a_test2': suspected_cl1 323 'a_test2': suspected_cl1
329 } 324 }
330 }, 325 },
331 'b_test': { 326 'b_test': {
332 'tests': { 327 'tests': {
333 'b_test1': suspected_cl2 328 'b_test1': suspected_cl2
334 } 329 }
335 }, 330 },
336 'c_test': { 331 'c_test': {
337 'revision': 'rev3', 332 'revision': 'rev3',
338 'commit_position': '3', 333 'commit_position': 3,
339 'url': 'url_3', 334 'url': 'url_3',
340 'repo_name': 'chromium', 335 'repo_name': 'chromium',
341 'tests': {} 336 'tests': {}
342 } 337 }
343 } 338 }
344 } 339 }
340 try_job_suspected_cls = [suspected_cl1, suspected_cl1, suspected_cl2]
345 341
342 result = identify_try_job_culprit_pipeline._GetSuspectedCLs(
343 analysis, try_job_suspected_cls)
346 self.assertEqual( 344 self.assertEqual(
347 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 345 result, [suspected_cl3, suspected_cl1, suspected_cl2])
348 [suspected_cl3, suspected_cl2, suspected_cl1])
349 346
350 def testGetSuspectedCLsForTestTryJobWithHeuristicResult(self): 347 def testGetSuspectedCLsForTestTryJobWithHeuristicResult(self):
351 suspected_cl = { 348 suspected_cl = {
352 'revision': 'rev1', 349 'revision': 'rev1',
353 'commit_position': '1', 350 'commit_position': 1,
354 'url': 'url_1', 351 'url': 'url_1',
355 'repo_name': 'chromium' 352 'repo_name': 'chromium'
356 } 353 }
357 354
358 analysis = WfAnalysis.Create('m', 'b', 1) 355 analysis = WfAnalysis.Create('m', 'b', 1)
359 analysis.suspected_cls = [suspected_cl] 356 analysis.suspected_cls = [suspected_cl]
360 analysis.put() 357 analysis.put()
361 358
362 result = {
363 'culprit': {
364 'a_test': {
365 'revision': 'rev1',
366 'commit_position': '1',
367 'url': 'url_1',
368 'repo_name': 'chromium',
369 'tests': {}
370 }
371 }
372 }
373 self.assertEqual( 359 self.assertEqual(
374 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 360 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, []),
375 [suspected_cl]) 361 [suspected_cl])
376 362
377 def testIdentifyCulpritForCompileTryJobNoCulprit(self): 363 def testIdentifyCulpritForCompileTryJobNoCulprit(self):
378 master_name = 'm' 364 master_name = 'm'
379 builder_name = 'b' 365 builder_name = 'b'
380 build_number = 1 366 build_number = 1
381 try_job_id = '1' 367 try_job_id = '1'
382 368
383 try_job = WfTryJob.Create(master_name, builder_name, build_number) 369 try_job = WfTryJob.Create(master_name, builder_name, build_number)
384 try_job.put() 370 try_job.put()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 analysis.put() 421 analysis.put()
436 422
437 pipeline = IdentifyTryJobCulpritPipeline() 423 pipeline = IdentifyTryJobCulpritPipeline()
438 culprit = pipeline.run( 424 culprit = pipeline.run(
439 master_name, builder_name, build_number, ['rev1'], 425 master_name, builder_name, build_number, ['rev1'],
440 failure_type.COMPILE, '1', compile_result) 426 failure_type.COMPILE, '1', compile_result)
441 427
442 expected_culprit = 'rev2' 428 expected_culprit = 'rev2'
443 expected_suspected_cl = { 429 expected_suspected_cl = {
444 'revision': 'rev2', 430 'revision': 'rev2',
445 'commit_position': '2', 431 'commit_position': 2,
446 'url': 'url_2', 432 'url': 'url_2',
447 'repo_name': 'chromium' 433 'repo_name': 'chromium'
448 } 434 }
449 expected_compile_result = { 435 expected_compile_result = {
450 'report': { 436 'report': {
451 'result': { 437 'result': {
452 'rev1': 'passed', 438 'rev1': 'passed',
453 'rev2': 'failed' 439 'rev2': 'failed'
454 } 440 }
455 }, 441 },
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 self.assertIsNone(analysis.suspected_cls) 522 self.assertIsNone(analysis.suspected_cls)
537 523
538 def testIdentifyCulpritForTestTryJobNoTryJobResultWithHeuristicResult(self): 524 def testIdentifyCulpritForTestTryJobNoTryJobResultWithHeuristicResult(self):
539 master_name = 'm' 525 master_name = 'm'
540 builder_name = 'b' 526 builder_name = 'b'
541 build_number = 1 527 build_number = 1
542 try_job_id = '1' 528 try_job_id = '1'
543 529
544 suspected_cl = { 530 suspected_cl = {
545 'revision': 'rev1', 531 'revision': 'rev1',
546 'commit_position': '1', 532 'commit_position': 1,
547 'url': 'url_1', 533 'url': 'url_1',
548 'repo_name': 'chromium' 534 'repo_name': 'chromium'
549 } 535 }
550 536
551 WfTryJobData.Create(try_job_id).put() 537 WfTryJobData.Create(try_job_id).put()
552 try_job = WfTryJob.Create(master_name, builder_name, build_number) 538 try_job = WfTryJob.Create(master_name, builder_name, build_number)
553 try_job.status = analysis_status.RUNNING 539 try_job.status = analysis_status.RUNNING
554 try_job.put() 540 try_job.put()
555 541
556 # Heuristic analysis already provided some results. 542 # Heuristic analysis already provided some results.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 'rev1': { 673 'rev1': {
688 'a_test': { 674 'a_test': {
689 'status': 'failed', 675 'status': 'failed',
690 'valid': True, 676 'valid': True,
691 'failures': ['a_test1'] 677 'failures': ['a_test1']
692 }, 678 },
693 'b_test': { 679 'b_test': {
694 'status': 'failed', 680 'status': 'failed',
695 'valid': True, 681 'valid': True,
696 'failures': ['b_test1'] 682 'failures': ['b_test1']
697 },
698 'c_test': {
699 'status': 'passed',
700 'valid': True
701 } 683 }
702 }, 684 },
703 'rev2': { 685 'rev2': {
704 'a_test': { 686 'a_test': {
705 'status': 'failed', 687 'status': 'failed',
706 'valid': True, 688 'valid': True,
707 'failures': ['a_test1', 'a_test2'] 689 'failures': ['a_test1', 'a_test2']
708 }, 690 },
709 'b_test': { 691 'b_test': {
710 'status': 'passed', 692 'status': 'passed',
711 'valid': True 693 'valid': True
712 },
713 'c_test': {
714 'status': 'failed',
715 'valid': True,
716 'failures': []
717 } 694 }
718 } 695 }
719 } 696 }
720 }, 697 },
721 'url': 'url', 698 'url': 'url',
722 'try_job_id': try_job_id 699 'try_job_id': try_job_id
723 } 700 }
724 701
725 WfTryJobData.Create(try_job_id).put() 702 WfTryJobData.Create(try_job_id).put()
726 try_job = WfTryJob.Create(master_name, builder_name, build_number) 703 try_job = WfTryJob.Create(master_name, builder_name, build_number)
727 try_job.status = analysis_status.RUNNING 704 try_job.status = analysis_status.RUNNING
728 try_job.test_results = [test_result] 705 try_job.test_results = [test_result]
729 try_job.put() 706 try_job.put()
730 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 707 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
731 analysis.put() 708 analysis.put()
732 709
733 pipeline = IdentifyTryJobCulpritPipeline() 710 pipeline = IdentifyTryJobCulpritPipeline()
734 culprit = pipeline.run( 711 culprit = pipeline.run(
735 master_name, builder_name, build_number, ['rev1', 'rev2'], 712 master_name, builder_name, build_number, ['rev1', 'rev2'],
736 failure_type.TEST, '1', test_result) 713 failure_type.TEST, '1', test_result)
737 714
738 a_test1_suspected_cl = { 715 a_test1_suspected_cl = {
739 'revision': 'rev1', 716 'revision': 'rev1',
740 'commit_position': '1', 717 'commit_position': 1,
741 'url': 'url_1', 718 'url': 'url_1',
742 'repo_name': 'chromium' 719 'repo_name': 'chromium'
743 } 720 }
744 a_test2_suspected_cl = { 721 a_test2_suspected_cl = {
745 'revision': 'rev2', 722 'revision': 'rev2',
746 'commit_position': '2', 723 'commit_position': 2,
747 'url': 'url_2', 724 'url': 'url_2',
748 'repo_name': 'chromium' 725 'repo_name': 'chromium'
749 } 726 }
750 727
751 b_test1_suspected_cl = a_test1_suspected_cl 728 b_test1_suspected_cl = a_test1_suspected_cl
752 729
753 expected_test_result = { 730 expected_test_result = {
754 'report': { 731 'report': {
755 'result': { 732 'result': {
756 'rev1': { 733 'rev1': {
757 'a_test': { 734 'a_test': {
758 'status': 'failed', 735 'status': 'failed',
759 'valid': True, 736 'valid': True,
760 'failures': ['a_test1'] 737 'failures': ['a_test1']
761 }, 738 },
762 'b_test': { 739 'b_test': {
763 'status': 'failed', 740 'status': 'failed',
764 'valid': True, 741 'valid': True,
765 'failures': ['b_test1'] 742 'failures': ['b_test1']
766 },
767 'c_test': {
768 'status': 'passed',
769 'valid': True
770 } 743 }
771 }, 744 },
772 'rev2': { 745 'rev2': {
773 'a_test': { 746 'a_test': {
774 'status': 'failed', 747 'status': 'failed',
775 'valid': True, 748 'valid': True,
776 'failures': ['a_test1', 'a_test2'] 749 'failures': ['a_test1', 'a_test2']
777 }, 750 },
778 'b_test': { 751 'b_test': {
779 'status': 'passed', 752 'status': 'passed',
780 'valid': True 753 'valid': True
781 },
782 'c_test': {
783 'status': 'failed',
784 'valid': True,
785 'failures': []
786 } 754 }
787 } 755 }
788 } 756 }
789 }, 757 },
790 'url': 'url', 758 'url': 'url',
791 'try_job_id': try_job_id, 759 'try_job_id': try_job_id,
792 'culprit': { 760 'culprit': {
793 'a_test': { 761 'a_test': {
794 'tests': { 762 'tests': {
795 'a_test1': a_test1_suspected_cl, 763 'a_test1': a_test1_suspected_cl,
796 'a_test2': a_test2_suspected_cl 764 'a_test2': a_test2_suspected_cl
797 } 765 }
798 }, 766 },
799 'b_test': { 767 'b_test': {
800 'tests': { 768 'tests': {
801 'b_test1': b_test1_suspected_cl 769 'b_test1': b_test1_suspected_cl
802 } 770 }
803 },
804 'c_test': {
805 'revision': 'rev2',
806 'commit_position': '2',
807 'url': 'url_2',
808 'repo_name': 'chromium',
809 'tests': {}
810 } 771 }
811 } 772 }
812 } 773 }
813 774
814 self.assertEqual(expected_test_result['culprit'], culprit) 775 self.assertEqual(expected_test_result['culprit'], culprit)
815 776
816 try_job = WfTryJob.Get(master_name, builder_name, build_number) 777 try_job = WfTryJob.Get(master_name, builder_name, build_number)
817 self.assertEqual(expected_test_result, try_job.test_results[-1]) 778 self.assertEqual(expected_test_result, try_job.test_results[-1])
818 self.assertEqual(analysis_status.COMPLETED, try_job.status) 779 self.assertEqual(analysis_status.COMPLETED, try_job.status)
819 780
820 try_job_data = WfTryJobData.Get(try_job_id) 781 try_job_data = WfTryJobData.Get(try_job_id)
821 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 782 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
822 expected_culprit_data = { 783 expected_culprit_data = {
823 'a_test': { 784 'a_test': {
824 'a_test1': 'rev1', 785 'a_test1': 'rev1',
825 'a_test2': 'rev2', 786 'a_test2': 'rev2',
826 }, 787 },
827 'b_test': { 788 'b_test': {
828 'b_test1': 'rev1', 789 'b_test1': 'rev1',
829 },
830 'c_test': 'rev2'
831 } 790 }
791 }
832 self.assertEqual(expected_culprit_data, try_job_data.culprits) 792 self.assertEqual(expected_culprit_data, try_job_data.culprits)
833 self.assertEqual(analysis.result_status, 793 self.assertEqual(analysis.result_status,
834 result_status.FOUND_UNTRIAGED) 794 result_status.FOUND_UNTRIAGED)
835 self.assertEqual(analysis.suspected_cls, 795 self.assertEqual(analysis.suspected_cls,
836 [a_test2_suspected_cl, a_test1_suspected_cl]) 796 [a_test1_suspected_cl, a_test2_suspected_cl])
837 797
838 def testAnalysisIsUpdatedOnlyIfStatusOrSuspectedCLsChanged(self): 798 def testAnalysisIsUpdatedOnlyIfStatusOrSuspectedCLsChanged(self):
839 master_name = 'm' 799 master_name = 'm'
840 builder_name = 'b' 800 builder_name = 'b'
841 build_number = 1 801 build_number = 1
842 try_job_id = '1' 802 try_job_id = '1'
803 repo_name = 'chromium'
804 revision = 'rev1'
805 commit_position = 1
843 806
844 suspected_cl = { 807 heuristic_suspected_cl = {
845 'revision': 'rev1', 808 'revision': revision,
846 'commit_position': '1', 809 'commit_position': commit_position,
847 'url': 'url_1', 810 'url': 'url_1',
848 'repo_name': 'chromium' 811 'repo_name': repo_name
849 } 812 }
850 813
851 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 814 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
852 analysis.suspected_cls = [suspected_cl] 815 analysis.suspected_cls = [heuristic_suspected_cl]
853 analysis.result_status = result_status.FOUND_UNTRIAGED 816 analysis.result_status = result_status.FOUND_UNTRIAGED
854 analysis.put() 817 analysis.put()
855 version = analysis.version 818 version = analysis.version
819
820 build_info = [master_name, builder_name, build_number]
821 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
822 suspected_cl.approach = analysis_approach_type.HEURISTIC
823 suspected_cl.builds = [build_info]
824 suspected_cl.put()
825
856 compile_result = { 826 compile_result = {
857 'report': { 827 'report': {
858 'result': { 828 'result': {
859 'rev1': 'failed', 829 revision: 'failed',
860 }, 830 },
861 }, 831 },
862 } 832 }
863 833
864 try_job_data = WfTryJobData.Create(try_job_id) 834 try_job_data = WfTryJobData.Create(try_job_id)
865 try_job_data.put() 835 try_job_data.put()
866 836
867 try_job = WfTryJob.Create(master_name, builder_name, build_number) 837 try_job = WfTryJob.Create(master_name, builder_name, build_number)
868 try_job.status = analysis_status.RUNNING 838 try_job.status = analysis_status.RUNNING
869 try_job.compile_results = [{ 839 try_job.compile_results = [{
870 'report': { 840 'report': {
871 'result': { 841 'result': {
872 'rev1': 'failed', 842 revision: 'failed',
873 }, 843 },
874 }, 844 },
875 'try_job_id': try_job_id, 845 'try_job_id': try_job_id,
876 }] 846 }]
877 847
878 try_job.put() 848 try_job.put()
879 849
880 pipeline = IdentifyTryJobCulpritPipeline() 850 pipeline = IdentifyTryJobCulpritPipeline()
881 pipeline.run(master_name, builder_name, build_number, ['rev1'], 851 pipeline.run(master_name, builder_name, build_number, [revision],
882 failure_type.COMPILE, '1', compile_result) 852 failure_type.COMPILE, '1', compile_result)
883 853
884 self.assertEqual(analysis.result_status, 854 self.assertEqual(analysis.result_status,
885 result_status.FOUND_UNTRIAGED) 855 result_status.FOUND_UNTRIAGED)
886 self.assertEqual(analysis.suspected_cls, [suspected_cl]) 856 self.assertEqual(analysis.suspected_cls, [heuristic_suspected_cl])
887 self.assertEqual(version, analysis.version) # No update to analysis. 857 self.assertEqual(version, analysis.version) # No update to analysis.
888 858
859 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
860 self.assertEqual(analysis_approach_type.BOTH, suspected_cl.approach)
861 self.assertEqual([build_info], suspected_cl.builds)
862
889 def testFindCulpritForEachTestFailureRevisionNotRun(self): 863 def testFindCulpritForEachTestFailureRevisionNotRun(self):
890 blame_list = ['rev1'] 864 blame_list = ['rev1']
891 result = { 865 result = {
892 'report': { 866 'report': {
893 'result': { 867 'result': {
894 'rev2': 'passed' 868 'rev2': 'passed'
895 } 869 }
896 } 870 }
897 } 871 }
898 872
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 culprits = { 923 culprits = {
950 'r1': { 924 'r1': {
951 'repo_name': 'chromium', 925 'repo_name': 'chromium',
952 'revision': 'r1', 926 'revision': 'r1',
953 } 927 }
954 } 928 }
955 929
956 identify_try_job_culprit_pipeline._NotifyCulprits('m', 'b', 1, culprits) 930 identify_try_job_culprit_pipeline._NotifyCulprits('m', 'b', 1, culprits)
957 self.assertEqual(1, len(instances)) 931 self.assertEqual(1, len(instances))
958 self.assertTrue(instances[0].started) 932 self.assertTrue(instances[0].started)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698