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

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: 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
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 = {
268 'culprit': { 270 'rev2': compile_suspected_cl
269 'compile': compile_suspected_cl
270 }
271 } 271 }
272 272
273 self.assertEqual( 273 self.assertEqual(
274 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 274 identify_try_job_culprit_pipeline._GetSuspectedCLs(
275 analysis, try_job_suspected_cls),
275 [heuristic_suspected_cl, compile_suspected_cl]) 276 [heuristic_suspected_cl, compile_suspected_cl])
276 277
277 def testGetSuspectedCLsForTestTryJobAndHeuristicResultsSame(self): 278 def testGetSuspectedCLsForTestTryJobAndHeuristicResultsSame(self):
278 suspected_cl = { 279 suspected_cl = {
279 'revision': 'rev1', 280 'revision': 'rev1',
280 'commit_position': '1', 281 'commit_position': 1,
281 'url': 'url_1', 282 'url': 'url_1',
282 'repo_name': 'chromium' 283 'repo_name': 'chromium'
283 } 284 }
284 285
285 analysis = WfAnalysis.Create('m', 'b', 1) 286 analysis = WfAnalysis.Create('m', 'b', 1)
286 analysis.suspected_cls = [suspected_cl] 287 analysis.suspected_cls = [suspected_cl]
287 analysis.put() 288 analysis.put()
288 289
289 result = { 290 try_job_suspected_cls = {
290 'culprit': { 291 'rev1': suspected_cl
291 'compile': suspected_cl
292 }
293 } 292 }
294 293
295 self.assertEqual( 294 updated_cls = identify_try_job_culprit_pipeline._GetSuspectedCLs(
296 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 295 analysis, try_job_suspected_cls)
297 [suspected_cl]) 296 print updated_cls
chanli 2016/09/12 20:56:15 Removed
297 self.assertEqual(updated_cls, [suspected_cl])
298 298
299 def testGetSuspectedCLsForTestTryJob(self): 299 def testGetSuspectedCLsForTestTryJob(self):
300 suspected_cl1 = { 300 suspected_cl1 = {
301 'revision': 'rev1', 301 'revision': 'rev1',
302 'commit_position': '1', 302 'commit_position': 1,
303 'url': 'url_1', 303 'url': 'url_1',
304 'repo_name': 'chromium' 304 'repo_name': 'chromium'
305 } 305 }
306 suspected_cl2 = { 306 suspected_cl2 = {
307 'revision': 'rev2', 307 'revision': 'rev2',
308 'commit_position': '2', 308 'commit_position': 2,
309 'url': 'url_2', 309 'url': 'url_2',
310 'repo_name': 'chromium' 310 'repo_name': 'chromium'
311 } 311 }
312 suspected_cl3 = { 312 suspected_cl3 = {
313 'revision': 'rev3', 313 'revision': 'rev3',
314 'commit_position': '3', 314 'commit_position': 3,
315 'url': 'url_3', 315 'url': 'url_3',
316 'repo_name': 'chromium' 316 'repo_name': 'chromium'
317 } 317 }
318 318
319 analysis = WfAnalysis.Create('m', 'b', 1) 319 analysis = WfAnalysis.Create('m', 'b', 1)
320 analysis.suspected_cls = [] 320 analysis.suspected_cls = [suspected_cl3]
321 analysis.put() 321 analysis.put()
322 322
323 result = { 323 try_job_suspected_cls = {
324 'culprit': { 324 'rev1': suspected_cl1,
325 'a_test': { 325 'rev2': suspected_cl2
326 'tests': {
327 'a_test1': suspected_cl1,
328 'a_test2': suspected_cl1
329 }
330 },
331 'b_test': {
332 'tests': {
333 'b_test1': suspected_cl2
334 }
335 },
336 'c_test': {
337 'revision': 'rev3',
338 'commit_position': '3',
339 'url': 'url_3',
340 'repo_name': 'chromium',
341 'tests': {}
342 }
343 }
344 } 326 }
345 327
328 result = identify_try_job_culprit_pipeline._GetSuspectedCLs(
329 analysis, try_job_suspected_cls)
346 self.assertEqual( 330 self.assertEqual(
347 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 331 result, [suspected_cl3, suspected_cl1, suspected_cl2])
348 [suspected_cl3, suspected_cl2, suspected_cl1])
349 332
350 def testGetSuspectedCLsForTestTryJobWithHeuristicResult(self): 333 def testGetSuspectedCLsForTestTryJobWithHeuristicResult(self):
351 suspected_cl = { 334 suspected_cl = {
352 'revision': 'rev1', 335 'revision': 'rev1',
353 'commit_position': '1', 336 'commit_position': 1,
354 'url': 'url_1', 337 'url': 'url_1',
355 'repo_name': 'chromium' 338 'repo_name': 'chromium'
356 } 339 }
357 340
358 analysis = WfAnalysis.Create('m', 'b', 1) 341 analysis = WfAnalysis.Create('m', 'b', 1)
359 analysis.suspected_cls = [suspected_cl] 342 analysis.suspected_cls = [suspected_cl]
360 analysis.put() 343 analysis.put()
361 344
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( 345 self.assertEqual(
374 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, result), 346 identify_try_job_culprit_pipeline._GetSuspectedCLs(analysis, {}),
375 [suspected_cl]) 347 [suspected_cl])
376 348
377 def testIdentifyCulpritForCompileTryJobNoCulprit(self): 349 def testIdentifyCulpritForCompileTryJobNoCulprit(self):
378 master_name = 'm' 350 master_name = 'm'
379 builder_name = 'b' 351 builder_name = 'b'
380 build_number = 1 352 build_number = 1
381 try_job_id = '1' 353 try_job_id = '1'
382 354
383 try_job = WfTryJob.Create(master_name, builder_name, build_number) 355 try_job = WfTryJob.Create(master_name, builder_name, build_number)
384 try_job.put() 356 try_job.put()
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 analysis.put() 407 analysis.put()
436 408
437 pipeline = IdentifyTryJobCulpritPipeline() 409 pipeline = IdentifyTryJobCulpritPipeline()
438 culprit = pipeline.run( 410 culprit = pipeline.run(
439 master_name, builder_name, build_number, ['rev1'], 411 master_name, builder_name, build_number, ['rev1'],
440 failure_type.COMPILE, '1', compile_result) 412 failure_type.COMPILE, '1', compile_result)
441 413
442 expected_culprit = 'rev2' 414 expected_culprit = 'rev2'
443 expected_suspected_cl = { 415 expected_suspected_cl = {
444 'revision': 'rev2', 416 'revision': 'rev2',
445 'commit_position': '2', 417 'commit_position': 2,
446 'url': 'url_2', 418 'url': 'url_2',
447 'repo_name': 'chromium' 419 'repo_name': 'chromium'
448 } 420 }
449 expected_compile_result = { 421 expected_compile_result = {
450 'report': { 422 'report': {
451 'result': { 423 'result': {
452 'rev1': 'passed', 424 'rev1': 'passed',
453 'rev2': 'failed' 425 'rev2': 'failed'
454 } 426 }
455 }, 427 },
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 self.assertIsNone(analysis.suspected_cls) 508 self.assertIsNone(analysis.suspected_cls)
537 509
538 def testIdentifyCulpritForTestTryJobNoTryJobResultWithHeuristicResult(self): 510 def testIdentifyCulpritForTestTryJobNoTryJobResultWithHeuristicResult(self):
539 master_name = 'm' 511 master_name = 'm'
540 builder_name = 'b' 512 builder_name = 'b'
541 build_number = 1 513 build_number = 1
542 try_job_id = '1' 514 try_job_id = '1'
543 515
544 suspected_cl = { 516 suspected_cl = {
545 'revision': 'rev1', 517 'revision': 'rev1',
546 'commit_position': '1', 518 'commit_position': 1,
547 'url': 'url_1', 519 'url': 'url_1',
548 'repo_name': 'chromium' 520 'repo_name': 'chromium'
549 } 521 }
550 522
551 WfTryJobData.Create(try_job_id).put() 523 WfTryJobData.Create(try_job_id).put()
552 try_job = WfTryJob.Create(master_name, builder_name, build_number) 524 try_job = WfTryJob.Create(master_name, builder_name, build_number)
553 try_job.status = analysis_status.RUNNING 525 try_job.status = analysis_status.RUNNING
554 try_job.put() 526 try_job.put()
555 527
556 # Heuristic analysis already provided some results. 528 # Heuristic analysis already provided some results.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 'rev1': { 659 'rev1': {
688 'a_test': { 660 'a_test': {
689 'status': 'failed', 661 'status': 'failed',
690 'valid': True, 662 'valid': True,
691 'failures': ['a_test1'] 663 'failures': ['a_test1']
692 }, 664 },
693 'b_test': { 665 'b_test': {
694 'status': 'failed', 666 'status': 'failed',
695 'valid': True, 667 'valid': True,
696 'failures': ['b_test1'] 668 'failures': ['b_test1']
697 },
698 'c_test': {
699 'status': 'passed',
700 'valid': True
701 } 669 }
702 }, 670 },
703 'rev2': { 671 'rev2': {
704 'a_test': { 672 'a_test': {
705 'status': 'failed', 673 'status': 'failed',
706 'valid': True, 674 'valid': True,
707 'failures': ['a_test1', 'a_test2'] 675 'failures': ['a_test1', 'a_test2']
708 }, 676 },
709 'b_test': { 677 'b_test': {
710 'status': 'passed', 678 'status': 'passed',
711 'valid': True 679 'valid': True
712 },
713 'c_test': {
714 'status': 'failed',
715 'valid': True,
716 'failures': []
717 } 680 }
718 } 681 }
719 } 682 }
720 }, 683 },
721 'url': 'url', 684 'url': 'url',
722 'try_job_id': try_job_id 685 'try_job_id': try_job_id
723 } 686 }
724 687
725 WfTryJobData.Create(try_job_id).put() 688 WfTryJobData.Create(try_job_id).put()
726 try_job = WfTryJob.Create(master_name, builder_name, build_number) 689 try_job = WfTryJob.Create(master_name, builder_name, build_number)
727 try_job.status = analysis_status.RUNNING 690 try_job.status = analysis_status.RUNNING
728 try_job.test_results = [test_result] 691 try_job.test_results = [test_result]
729 try_job.put() 692 try_job.put()
730 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 693 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
731 analysis.put() 694 analysis.put()
732 695
733 pipeline = IdentifyTryJobCulpritPipeline() 696 pipeline = IdentifyTryJobCulpritPipeline()
734 culprit = pipeline.run( 697 culprit = pipeline.run(
735 master_name, builder_name, build_number, ['rev1', 'rev2'], 698 master_name, builder_name, build_number, ['rev1', 'rev2'],
736 failure_type.TEST, '1', test_result) 699 failure_type.TEST, '1', test_result)
737 700
738 a_test1_suspected_cl = { 701 a_test1_suspected_cl = {
739 'revision': 'rev1', 702 'revision': 'rev1',
740 'commit_position': '1', 703 'commit_position': 1,
741 'url': 'url_1', 704 'url': 'url_1',
742 'repo_name': 'chromium' 705 'repo_name': 'chromium'
743 } 706 }
744 a_test2_suspected_cl = { 707 a_test2_suspected_cl = {
745 'revision': 'rev2', 708 'revision': 'rev2',
746 'commit_position': '2', 709 'commit_position': 2,
747 'url': 'url_2', 710 'url': 'url_2',
748 'repo_name': 'chromium' 711 'repo_name': 'chromium'
749 } 712 }
750 713
751 b_test1_suspected_cl = a_test1_suspected_cl 714 b_test1_suspected_cl = a_test1_suspected_cl
752 715
753 expected_test_result = { 716 expected_test_result = {
754 'report': { 717 'report': {
755 'result': { 718 'result': {
756 'rev1': { 719 'rev1': {
757 'a_test': { 720 'a_test': {
758 'status': 'failed', 721 'status': 'failed',
759 'valid': True, 722 'valid': True,
760 'failures': ['a_test1'] 723 'failures': ['a_test1']
761 }, 724 },
762 'b_test': { 725 'b_test': {
763 'status': 'failed', 726 'status': 'failed',
764 'valid': True, 727 'valid': True,
765 'failures': ['b_test1'] 728 'failures': ['b_test1']
766 },
767 'c_test': {
768 'status': 'passed',
769 'valid': True
770 } 729 }
771 }, 730 },
772 'rev2': { 731 'rev2': {
773 'a_test': { 732 'a_test': {
774 'status': 'failed', 733 'status': 'failed',
775 'valid': True, 734 'valid': True,
776 'failures': ['a_test1', 'a_test2'] 735 'failures': ['a_test1', 'a_test2']
777 }, 736 },
778 'b_test': { 737 'b_test': {
779 'status': 'passed', 738 'status': 'passed',
780 'valid': True 739 'valid': True
781 },
782 'c_test': {
783 'status': 'failed',
784 'valid': True,
785 'failures': []
786 } 740 }
787 } 741 }
788 } 742 }
789 }, 743 },
790 'url': 'url', 744 'url': 'url',
791 'try_job_id': try_job_id, 745 'try_job_id': try_job_id,
792 'culprit': { 746 'culprit': {
793 'a_test': { 747 'a_test': {
794 'tests': { 748 'tests': {
795 'a_test1': a_test1_suspected_cl, 749 'a_test1': a_test1_suspected_cl,
796 'a_test2': a_test2_suspected_cl 750 'a_test2': a_test2_suspected_cl
797 } 751 }
798 }, 752 },
799 'b_test': { 753 'b_test': {
800 'tests': { 754 'tests': {
801 'b_test1': b_test1_suspected_cl 755 'b_test1': b_test1_suspected_cl
802 } 756 }
803 },
804 'c_test': {
805 'revision': 'rev2',
806 'commit_position': '2',
807 'url': 'url_2',
808 'repo_name': 'chromium',
809 'tests': {}
810 } 757 }
811 } 758 }
812 } 759 }
813 760
814 self.assertEqual(expected_test_result['culprit'], culprit) 761 self.assertEqual(expected_test_result['culprit'], culprit)
815 762
816 try_job = WfTryJob.Get(master_name, builder_name, build_number) 763 try_job = WfTryJob.Get(master_name, builder_name, build_number)
817 self.assertEqual(expected_test_result, try_job.test_results[-1]) 764 self.assertEqual(expected_test_result, try_job.test_results[-1])
818 self.assertEqual(analysis_status.COMPLETED, try_job.status) 765 self.assertEqual(analysis_status.COMPLETED, try_job.status)
819 766
820 try_job_data = WfTryJobData.Get(try_job_id) 767 try_job_data = WfTryJobData.Get(try_job_id)
821 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 768 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
822 expected_culprit_data = { 769 expected_culprit_data = {
823 'a_test': { 770 'a_test': {
824 'a_test1': 'rev1', 771 'a_test1': 'rev1',
825 'a_test2': 'rev2', 772 'a_test2': 'rev2',
826 }, 773 },
827 'b_test': { 774 'b_test': {
828 'b_test1': 'rev1', 775 'b_test1': 'rev1',
829 },
830 'c_test': 'rev2'
831 } 776 }
777 }
832 self.assertEqual(expected_culprit_data, try_job_data.culprits) 778 self.assertEqual(expected_culprit_data, try_job_data.culprits)
833 self.assertEqual(analysis.result_status, 779 self.assertEqual(analysis.result_status,
834 result_status.FOUND_UNTRIAGED) 780 result_status.FOUND_UNTRIAGED)
781 print analysis.suspected_cls
782 print [a_test1_suspected_cl, a_test2_suspected_cl]
chanli 2016/09/12 20:56:16 Removed
835 self.assertEqual(analysis.suspected_cls, 783 self.assertEqual(analysis.suspected_cls,
836 [a_test2_suspected_cl, a_test1_suspected_cl]) 784 [a_test1_suspected_cl, a_test2_suspected_cl])
837 785
838 def testAnalysisIsUpdatedOnlyIfStatusOrSuspectedCLsChanged(self): 786 def testAnalysisIsUpdatedOnlyIfStatusOrSuspectedCLsChanged(self):
839 master_name = 'm' 787 master_name = 'm'
840 builder_name = 'b' 788 builder_name = 'b'
841 build_number = 1 789 build_number = 1
842 try_job_id = '1' 790 try_job_id = '1'
791 repo_name = 'chromium'
792 revision = 'rev1'
793 commit_position = 1
843 794
844 suspected_cl = { 795 heuristic_suspected_cl = {
845 'revision': 'rev1', 796 'revision': revision,
846 'commit_position': '1', 797 'commit_position': commit_position,
847 'url': 'url_1', 798 'url': 'url_1',
848 'repo_name': 'chromium' 799 'repo_name': repo_name
849 } 800 }
850 801
851 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 802 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
852 analysis.suspected_cls = [suspected_cl] 803 analysis.suspected_cls = [heuristic_suspected_cl]
853 analysis.result_status = result_status.FOUND_UNTRIAGED 804 analysis.result_status = result_status.FOUND_UNTRIAGED
854 analysis.put() 805 analysis.put()
855 version = analysis.version 806 version = analysis.version
807
808 build_key = '%s/%s/%d' % (master_name, builder_name, build_number)
809 suspected_cl = WfSuspectedCL.Create(repo_name, revision, commit_position)
810 suspected_cl.approach = analysis_approach_type.HEURISTIC
811 suspected_cl.builds = {
812 build_key: {
813 'approach': analysis_approach_type.HEURISTIC,
814 'failure_type':failure_type.COMPILE,
815 'failures': {'compile':[]},
816 'status': None,
817 'top_score': 4
818 }
819 }
820 suspected_cl.put()
821
856 compile_result = { 822 compile_result = {
857 'report': { 823 'report': {
858 'result': { 824 'result': {
859 'rev1': 'failed', 825 revision: 'failed',
860 }, 826 },
861 }, 827 },
862 } 828 }
863 829
864 try_job_data = WfTryJobData.Create(try_job_id) 830 try_job_data = WfTryJobData.Create(try_job_id)
865 try_job_data.put() 831 try_job_data.put()
866 832
867 try_job = WfTryJob.Create(master_name, builder_name, build_number) 833 try_job = WfTryJob.Create(master_name, builder_name, build_number)
868 try_job.status = analysis_status.RUNNING 834 try_job.status = analysis_status.RUNNING
869 try_job.compile_results = [{ 835 try_job.compile_results = [{
870 'report': { 836 'report': {
871 'result': { 837 'result': {
872 'rev1': 'failed', 838 revision: 'failed',
873 }, 839 },
874 }, 840 },
875 'try_job_id': try_job_id, 841 'try_job_id': try_job_id,
876 }] 842 }]
877 843
878 try_job.put() 844 try_job.put()
879 845
880 pipeline = IdentifyTryJobCulpritPipeline() 846 pipeline = IdentifyTryJobCulpritPipeline()
881 pipeline.run(master_name, builder_name, build_number, ['rev1'], 847 pipeline.run(master_name, builder_name, build_number, [revision],
882 failure_type.COMPILE, '1', compile_result) 848 failure_type.COMPILE, '1', compile_result)
883 849
884 self.assertEqual(analysis.result_status, 850 self.assertEqual(analysis.result_status,
885 result_status.FOUND_UNTRIAGED) 851 result_status.FOUND_UNTRIAGED)
886 self.assertEqual(analysis.suspected_cls, [suspected_cl]) 852 self.assertEqual(analysis.suspected_cls, [heuristic_suspected_cl])
887 self.assertEqual(version, analysis.version) # No update to analysis. 853 self.assertEqual(version, analysis.version) # No update to analysis.
888 854
855
chanli 2016/09/12 20:56:15 Removed one line.
856 expected_builds = {
857 build_key: {
858 'approach': analysis_approach_type.BOTH,
859 'failure_type':failure_type.COMPILE,
860 'failures': {'compile':[]},
861 'status': None,
862 'top_score': 4
863 }
864 }
865 suspected_cl = WfSuspectedCL.Get(repo_name, revision)
866 self.assertEqual(analysis_approach_type.BOTH, suspected_cl.approach)
867 self.assertEqual(expected_builds, suspected_cl.builds)
868
889 def testFindCulpritForEachTestFailureRevisionNotRun(self): 869 def testFindCulpritForEachTestFailureRevisionNotRun(self):
890 blame_list = ['rev1'] 870 blame_list = ['rev1']
891 result = { 871 result = {
892 'report': { 872 'report': {
893 'result': { 873 'result': {
894 'rev2': 'passed' 874 'rev2': 'passed'
895 } 875 }
896 } 876 }
897 } 877 }
898 878
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 918
939 try_job = WfTryJob.Create(master_name, builder_name, build_number).put() 919 try_job = WfTryJob.Create(master_name, builder_name, build_number).put()
940 pipeline = IdentifyTryJobCulpritPipeline() 920 pipeline = IdentifyTryJobCulpritPipeline()
941 culprit = pipeline.run(master_name, builder_name, build_number, ['rev1'], 921 culprit = pipeline.run(master_name, builder_name, build_number, ['rev1'],
942 failure_type.TEST, None, None) 922 failure_type.TEST, None, None)
943 self.assertIsNone(culprit) 923 self.assertIsNone(culprit)
944 924
945 try_job = WfTryJob.Get(master_name, builder_name, build_number) 925 try_job = WfTryJob.Get(master_name, builder_name, build_number)
946 self.assertEqual(try_job.test_results, []) 926 self.assertEqual(try_job.test_results, [])
947 self.assertEqual(try_job.status, analysis_status.COMPLETED) 927 self.assertEqual(try_job.status, analysis_status.COMPLETED)
948 928
chanli 2016/09/12 20:56:16 Removed one line
949 929
950 def testNotifyCulprits(self): 930 def testNotifyCulprits(self):
951 instances = [] 931 instances = []
952 class Mocked_SendNotificationForCulpritPipeline(object): 932 class Mocked_SendNotificationForCulpritPipeline(object):
953 def __init__(self, *args): 933 def __init__(self, *args):
954 self.args = args 934 self.args = args
955 self.started = False 935 self.started = False
956 instances.append(self) 936 instances.append(self)
957 937
958 def start(self): 938 def start(self):
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 self.started = True 1042 self.started = True
1063 1043
1064 self.mock( 1044 self.mock(
1065 identify_try_job_culprit_pipeline, 'SendNotificationForCulpritPipeline', 1045 identify_try_job_culprit_pipeline, 'SendNotificationForCulpritPipeline',
1066 Mocked_SendNotificationForCulpritPipeline) 1046 Mocked_SendNotificationForCulpritPipeline)
1067 1047
1068 identify_try_job_culprit_pipeline._NotifyCulprits( 1048 identify_try_job_culprit_pipeline._NotifyCulprits(
1069 master_name, builder_name, build_number, None, 1049 master_name, builder_name, build_number, None,
1070 heuristic_cls, compile_suspected_cl) 1050 heuristic_cls, compile_suspected_cl)
1071 self.assertEqual(1, len(instances)) 1051 self.assertEqual(1, len(instances))
1072 self.assertTrue(instances[0].started) 1052 self.assertTrue(instances[0].started)
1053
1054 def testGetTestFailureCausedByCLResultNone(self):
1055 self.assertIsNone(
1056 identify_try_job_culprit_pipeline._GetTestFailureCausedByCL(None))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698