| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 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 import mock | 5 import mock |
| 6 | 6 |
| 7 from common.waterfall import failure_type | 7 from common.waterfall import failure_type |
| 8 from model.wf_try_job import WfTryJob | 8 from model.wf_try_job import WfTryJob |
| 9 from waterfall import start_try_job_on_demand_pipeline | 9 from waterfall import start_try_job_on_demand_pipeline |
| 10 from waterfall.start_try_job_on_demand_pipeline import ( | 10 from waterfall.start_try_job_on_demand_pipeline import ( |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 start_try_job_on_demand_pipeline._GetSuspectsFromHeuristicResult( | 83 start_try_job_on_demand_pipeline._GetSuspectsFromHeuristicResult( |
| 84 heuristic_result)) | 84 heuristic_result)) |
| 85 | 85 |
| 86 def testNotScheduleTryJobIfBuildNotCompleted(self): | 86 def testNotScheduleTryJobIfBuildNotCompleted(self): |
| 87 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() | 87 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() |
| 88 result = pipeline.run( | 88 result = pipeline.run( |
| 89 'm', 'b', 1, {}, {}, {}, False, False) | 89 'm', 'b', 1, {}, {}, {}, False, False) |
| 90 self.assertEqual(list(result), []) | 90 self.assertEqual(list(result), []) |
| 91 | 91 |
| 92 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') | 92 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') |
| 93 def testNotScheduleTryJobIfDontNeedTryJob(self, mock_other): | 93 def testNotScheduleTryJobIfDontNeedTryJob(self, mock_module): |
| 94 mock_other.NeedANewTryJob.return_value = False | 94 mock_module.NeedANewTryJob.return_value = False |
| 95 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() | 95 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() |
| 96 result = pipeline.run( | 96 result = pipeline.run( |
| 97 'm', 'b', 1, {}, {}, {}, True, False) | 97 'm', 'b', 1, {}, {}, {}, True, False) |
| 98 self.assertEqual(list(result), []) | 98 self.assertEqual(list(result), []) |
| 99 | 99 |
| 100 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') | 100 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') |
| 101 def testNotScheduleTryJobIfUnsupportedFailureType(self, mock_other): | 101 def testNotScheduleTryJobIfUnsupportedFailureType(self, mock_module): |
| 102 mock_other.NeedANewTryJob.return_value = True | 102 mock_module.NeedANewTryJob.return_value = True |
| 103 try_job_type = failure_type.UNKNOWN | 103 try_job_type = failure_type.UNKNOWN |
| 104 failure_info = { | 104 failure_info = { |
| 105 'failure_type': try_job_type, | 105 'failure_type': try_job_type, |
| 106 'builds': { | 106 'builds': { |
| 107 '0': { | 107 '0': { |
| 108 'blame_list': ['r0', 'r1'], | 108 'blame_list': ['r0', 'r1'], |
| 109 'chromium_revision': 'r1' | 109 'chromium_revision': 'r1' |
| 110 }, | 110 }, |
| 111 '1': { | 111 '1': { |
| 112 'blame_list': ['r2'], | 112 'blame_list': ['r2'], |
| 113 'chromium_revision': 'r2' | 113 'chromium_revision': 'r2' |
| 114 } | 114 } |
| 115 }, | 115 }, |
| 116 'failed_steps': { | 116 'failed_steps': { |
| 117 'a': { | 117 'a': { |
| 118 'first_failure': 1, | 118 'first_failure': 1, |
| 119 'last_pass': 0 | 119 'last_pass': 0 |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() | 123 pipeline = start_try_job_on_demand_pipeline.StartTryJobOnDemandPipeline() |
| 124 result = pipeline.run( | 124 result = pipeline.run( |
| 125 'm', 'b', 1, failure_info, {}, {}, True, False) | 125 'm', 'b', 1, failure_info, {}, {}, True, False) |
| 126 self.assertEqual(list(result), []) | 126 self.assertEqual(list(result), []) |
| 127 | 127 |
| 128 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') | 128 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') |
| 129 def testCompileTryJob(self, mock_other): | 129 def testCompileTryJob(self, mock_module): |
| 130 | 130 |
| 131 master_name = 'm' | 131 master_name = 'm' |
| 132 builder_name = 'b' | 132 builder_name = 'b' |
| 133 build_number = 1 | 133 build_number = 1 |
| 134 try_job_type = failure_type.COMPILE | 134 try_job_type = failure_type.COMPILE |
| 135 failure_info = { | 135 failure_info = { |
| 136 'failure_type': try_job_type, | 136 'failure_type': try_job_type, |
| 137 'builds': { | 137 'builds': { |
| 138 '0': { | 138 '0': { |
| 139 'blame_list': ['r0', 'r1'], | 139 'blame_list': ['r0', 'r1'], |
| 140 'chromium_revision': 'r1' | 140 'chromium_revision': 'r1' |
| 141 }, | 141 }, |
| 142 '1': { | 142 '1': { |
| 143 'blame_list': ['r2'], | 143 'blame_list': ['r2'], |
| 144 'chromium_revision': 'r2' | 144 'chromium_revision': 'r2' |
| 145 } | 145 } |
| 146 }, | 146 }, |
| 147 'failed_steps': { | 147 'failed_steps': { |
| 148 'compile': { | 148 'compile': { |
| 149 'first_failure': 1, | 149 'first_failure': 1, |
| 150 'last_pass': 0 | 150 'last_pass': 0 |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 good_revision = 'r1' | 154 good_revision = 'r1' |
| 155 bad_revision = 'r2' | 155 bad_revision = 'r2' |
| 156 WfTryJob.Create('m', 'b', 1).put() | 156 WfTryJob.Create('m', 'b', 1).put() |
| 157 | 157 |
| 158 mock_other.NeedANewTryJob.return_value = True | 158 mock_module.NeedANewTryJob.return_value = True |
| 159 mock_other.GetFailedTargetsFromSignals.return_value = {} | 159 mock_module.GetFailedTargetsFromSignals.return_value = {} |
| 160 | 160 |
| 161 self.MockPipeline( | 161 self.MockPipeline( |
| 162 start_try_job_on_demand_pipeline.ScheduleCompileTryJobPipeline, | 162 start_try_job_on_demand_pipeline.ScheduleCompileTryJobPipeline, |
| 163 'try_job_id', | 163 'try_job_id', |
| 164 expected_args=[ | 164 expected_args=[ |
| 165 master_name, builder_name, build_number, good_revision, | 165 master_name, builder_name, build_number, good_revision, |
| 166 bad_revision, try_job_type, {}, []], | 166 bad_revision, try_job_type, {}, []], |
| 167 expected_kwargs={}) | 167 expected_kwargs={}) |
| 168 self.MockPipeline( | 168 self.MockPipeline( |
| 169 start_try_job_on_demand_pipeline.MonitorTryJobPipeline, | 169 start_try_job_on_demand_pipeline.MonitorTryJobPipeline, |
| 170 'try_job_result', | 170 'try_job_result', |
| 171 expected_args=[ | 171 expected_args=[ |
| 172 master_name, builder_name, build_number, try_job_type, 'try_job_id' | 172 master_name, builder_name, build_number, try_job_type, 'try_job_id' |
| 173 ], | 173 ], |
| 174 expected_kwargs={}) | 174 expected_kwargs={}) |
| 175 self.MockPipeline( | 175 self.MockPipeline( |
| 176 start_try_job_on_demand_pipeline.IdentifyTryJobCulpritPipeline, | 176 start_try_job_on_demand_pipeline.IdentifyTryJobCulpritPipeline, |
| 177 'final_result', | 177 'final_result', |
| 178 expected_args=[ | 178 expected_args=[ |
| 179 master_name, builder_name, build_number, ['r2'], try_job_type, | 179 master_name, builder_name, build_number, ['r2'], try_job_type, |
| 180 'try_job_id', 'try_job_result'], | 180 'try_job_id', 'try_job_result'], |
| 181 expected_kwargs={}) | 181 expected_kwargs={}) |
| 182 | 182 |
| 183 pipeline = StartTryJobOnDemandPipeline() | 183 pipeline = StartTryJobOnDemandPipeline() |
| 184 result = pipeline.run( | 184 result = pipeline.run( |
| 185 'm', 'b', 1, failure_info, {}, {}, True, False) | 185 'm', 'b', 1, failure_info, {}, {}, True, False) |
| 186 self.assertNotEqual(list(result), []) | 186 self.assertNotEqual(list(result), []) |
| 187 | 187 |
| 188 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') | 188 @mock.patch.object(start_try_job_on_demand_pipeline, 'try_job_util') |
| 189 def testTestTryJob(self, mock_other): | 189 def testTestTryJob(self, mock_module): |
| 190 | 190 |
| 191 master_name = 'm' | 191 master_name = 'm' |
| 192 builder_name = 'b' | 192 builder_name = 'b' |
| 193 build_number = 1 | 193 build_number = 1 |
| 194 try_job_type = failure_type.TEST | 194 try_job_type = failure_type.TEST |
| 195 failure_info = { | 195 failure_info = { |
| 196 'failure_type': try_job_type, | 196 'failure_type': try_job_type, |
| 197 'builds': { | 197 'builds': { |
| 198 '0': { | 198 '0': { |
| 199 'blame_list': ['r0', 'r1'], | 199 'blame_list': ['r0', 'r1'], |
| (...skipping 24 matching lines...) Expand all Loading... |
| 224 'b_test1': { | 224 'b_test1': { |
| 225 'first_failure': 0 | 225 'first_failure': 0 |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 } | 230 } |
| 231 good_revision = 'r1' | 231 good_revision = 'r1' |
| 232 bad_revision = 'r2' | 232 bad_revision = 'r2' |
| 233 | 233 |
| 234 mock_other.NeedANewTryJob.return_value = True | 234 mock_module.NeedANewTryJob.return_value = True |
| 235 mock_other.GetFailedTargetsFromSignals.return_value = {} | 235 mock_module.GetFailedTargetsFromSignals.return_value = {} |
| 236 | 236 |
| 237 self.MockPipeline( | 237 self.MockPipeline( |
| 238 start_try_job_on_demand_pipeline.ScheduleTestTryJobPipeline, | 238 start_try_job_on_demand_pipeline.ScheduleTestTryJobPipeline, |
| 239 'try_job_id', | 239 'try_job_id', |
| 240 expected_args=[ | 240 expected_args=[ |
| 241 master_name, builder_name, build_number, good_revision, | 241 master_name, builder_name, build_number, good_revision, |
| 242 bad_revision, try_job_type, 'targeted_tests', []], | 242 bad_revision, try_job_type, 'targeted_tests', []], |
| 243 expected_kwargs={}) | 243 expected_kwargs={}) |
| 244 self.MockPipeline( | 244 self.MockPipeline( |
| 245 start_try_job_on_demand_pipeline.MonitorTryJobPipeline, | 245 start_try_job_on_demand_pipeline.MonitorTryJobPipeline, |
| 246 'try_job_result', | 246 'try_job_result', |
| 247 expected_args=[ | 247 expected_args=[ |
| 248 master_name, builder_name, build_number, try_job_type, 'try_job_id' | 248 master_name, builder_name, build_number, try_job_type, 'try_job_id' |
| 249 ], | 249 ], |
| 250 expected_kwargs={}) | 250 expected_kwargs={}) |
| 251 self.MockPipeline( | 251 self.MockPipeline( |
| 252 start_try_job_on_demand_pipeline.IdentifyTryJobCulpritPipeline, | 252 start_try_job_on_demand_pipeline.IdentifyTryJobCulpritPipeline, |
| 253 'final_result', | 253 'final_result', |
| 254 expected_args=[ | 254 expected_args=[ |
| 255 master_name, builder_name, build_number, ['r2'], try_job_type, | 255 master_name, builder_name, build_number, ['r2'], try_job_type, |
| 256 'try_job_id', 'try_job_result'], | 256 'try_job_id', 'try_job_result'], |
| 257 expected_kwargs={}) | 257 expected_kwargs={}) |
| 258 | 258 |
| 259 pipeline = StartTryJobOnDemandPipeline() | 259 pipeline = StartTryJobOnDemandPipeline() |
| 260 result = pipeline.run( | 260 result = pipeline.run( |
| 261 'm', 'b', 1, failure_info, {}, {}, True, False) | 261 'm', 'b', 1, failure_info, {}, {}, True, False) |
| 262 WfTryJob.Create('m', 'b', 1).put() | 262 WfTryJob.Create('m', 'b', 1).put() |
| 263 self.assertNotEqual(list(result), []) | 263 self.assertNotEqual(list(result), []) |
| OLD | NEW |