| 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 model import analysis_status | 5 from model import analysis_status |
| 6 from model.wf_try_job import WfTryJob | 6 from model.wf_try_job import WfTryJob |
| 7 from waterfall import try_job_util | 7 from waterfall import try_job_util |
| 8 from waterfall.test import wf_testcase | 8 from waterfall.test import wf_testcase |
| 9 from waterfall.try_job_type import TryJobType | 9 from waterfall.try_job_type import TryJobType |
| 10 | 10 |
| 11 | 11 |
| 12 class _MockRootPipeline(object): | 12 class _MockRootPipeline(object): |
| 13 STARTED = False | 13 STARTED = False |
| 14 | 14 |
| 15 def __init__(self, *_): | 15 def __init__(self, *_): |
| 16 pass | 16 pass |
| 17 | 17 |
| 18 def start(self, *_, **__): | 18 def start(self, *_, **__): |
| 19 _MockRootPipeline.STARTED = True | 19 _MockRootPipeline.STARTED = True |
| 20 | 20 |
| 21 @property | 21 @property |
| 22 def pipeline_status_path(self): | 22 def pipeline_status_path(self): |
| 23 return 'path' | 23 return 'path' |
| 24 | 24 |
| 25 | 25 |
| 26 class TryJobUtilTest(wf_testcase.WaterfallTestCase): | 26 class TryJobUtilTest(wf_testcase.WaterfallTestCase): |
| 27 | 27 |
| 28 def testNotNeedANewTryJobIfBuilderIsNotSupportedYet(self): | 28 def testNotNeedANewTryJobIfBuilderIsNotSupportedYet(self): |
| 29 master_name = 'master2' | 29 master_name = 'master3' |
| 30 builder_name = 'builder2' | 30 builder_name = 'builder3' |
| 31 build_number = 223 | 31 build_number = 223 |
| 32 failure_info = { | 32 failure_info = { |
| 33 'master_name': master_name, | 33 'master_name': master_name, |
| 34 'builder_name': builder_name, | 34 'builder_name': builder_name, |
| 35 'build_number': build_number, | 35 'build_number': build_number, |
| 36 'failed_steps': { | 36 'failed_steps': { |
| 37 'compile': { | 37 'compile': { |
| 38 'current_failure': 221, | 38 'current_failure': 221, |
| 39 'first_failure': 221, | 39 'first_failure': 221, |
| 40 'last_pass': 220 | 40 'last_pass': 220 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 64 try_job_util.swarming_tasks_to_try_job_pipeline, | 64 try_job_util.swarming_tasks_to_try_job_pipeline, |
| 65 'SwarmingTasksToTryJobPipeline', _MockRootPipeline) | 65 'SwarmingTasksToTryJobPipeline', _MockRootPipeline) |
| 66 _MockRootPipeline.STARTED = False | 66 _MockRootPipeline.STARTED = False |
| 67 | 67 |
| 68 failure_result_map = try_job_util.ScheduleTryJobIfNeeded( | 68 failure_result_map = try_job_util.ScheduleTryJobIfNeeded( |
| 69 failure_info, None, None) | 69 failure_info, None, None) |
| 70 | 70 |
| 71 self.assertFalse(_MockRootPipeline.STARTED) | 71 self.assertFalse(_MockRootPipeline.STARTED) |
| 72 self.assertEqual({}, failure_result_map) | 72 self.assertEqual({}, failure_result_map) |
| 73 | 73 |
| 74 def testBailOutForTestTryJob(self): |
| 75 master_name = 'master2' |
| 76 builder_name = 'builder2' |
| 77 build_number = 223 |
| 78 failure_info = { |
| 79 'master_name': master_name, |
| 80 'builder_name': builder_name, |
| 81 'build_number': build_number, |
| 82 'failed_steps': { |
| 83 'a_test': {} |
| 84 }, |
| 85 } |
| 86 |
| 87 failure_result_map = try_job_util.ScheduleTryJobIfNeeded( |
| 88 failure_info, None, None) |
| 89 |
| 90 self.assertEqual({}, failure_result_map) |
| 91 |
| 74 def testNotNeedANewTryJobIfNotFirstTimeFailure(self): | 92 def testNotNeedANewTryJobIfNotFirstTimeFailure(self): |
| 75 master_name = 'm' | 93 master_name = 'm' |
| 76 builder_name = 'b' | 94 builder_name = 'b' |
| 77 build_number = 223 | 95 build_number = 223 |
| 78 failure_info = { | 96 failure_info = { |
| 79 'master_name': master_name, | 97 'master_name': master_name, |
| 80 'builder_name': builder_name, | 98 'builder_name': builder_name, |
| 81 'build_number': build_number, | 99 'build_number': build_number, |
| 82 'failed_steps': { | 100 'failed_steps': { |
| 83 'compile': { | 101 'compile': { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 { | 421 { |
| 404 'step_name': 'steps' | 422 'step_name': 'steps' |
| 405 }, | 423 }, |
| 406 ] | 424 ] |
| 407 } | 425 } |
| 408 expected_suspected_revisions = ['r1', 'r2'] | 426 expected_suspected_revisions = ['r1', 'r2'] |
| 409 self.assertEqual( | 427 self.assertEqual( |
| 410 expected_suspected_revisions, | 428 expected_suspected_revisions, |
| 411 try_job_util._GetSuspectsForCompileFailureFromHeuristicResult( | 429 try_job_util._GetSuspectsForCompileFailureFromHeuristicResult( |
| 412 heuristic_result)) | 430 heuristic_result)) |
| OLD | NEW |