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