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

Side by Side Diff: appengine/findit/waterfall/test/identify_culprit_pipeline_test.py

Issue 2302223002: [Findit] Change the criteria of sending notification to code review. (Closed)
Patch Set: 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.pipeline_wrapper import pipeline_handlers 7 from common.pipeline_wrapper import pipeline_handlers
8 from model import analysis_status 8 from model import analysis_status
9 from model import result_status 9 from model import result_status
10 from model.wf_analysis import WfAnalysis 10 from model.wf_analysis import WfAnalysis
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 expected_suspected_cls = [] 232 expected_suspected_cls = []
233 233
234 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 234 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
235 self.assertTrue(analysis.build_completed) 235 self.assertTrue(analysis.build_completed)
236 self.assertIsNotNone(analysis) 236 self.assertIsNotNone(analysis)
237 self.assertEqual(dummy_result, analysis.result) 237 self.assertEqual(dummy_result, analysis.result)
238 self.assertEqual(analysis_status.COMPLETED, analysis.status) 238 self.assertEqual(analysis_status.COMPLETED, analysis.status)
239 self.assertIsNone(analysis.result_status) 239 self.assertIsNone(analysis.result_status)
240 self.assertEqual(expected_suspected_cls, analysis.suspected_cls) 240 self.assertEqual(expected_suspected_cls, analysis.suspected_cls)
241
242 def testGetSuspectedCLFoundByHeuristicForCompile(self):
243 master_name = 'm'
244 builder_name = 'b'
245 build_number = 9
246 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
247 analysis.result = {
248 'failures': [
249 {
250 'step_name': 'other_step',
251 'suspected_cls': [
252 {
253 'repo_name': 'chromium',
254 'revision': 'rev1'
255 }
256 ]
257 },
258 {
259 'step_name': 'compile',
260 'suspected_cls': [
261 {
262 'repo_name': 'chromium',
263 'revision': 'rev1'
264 }
265 ]
266 }
267 ]
268 }
269 analysis.put()
270
271 cl = (identify_culprit_pipeline. \
272 _GetSuspectedCLFoundByHeuristicForCompile(analysis))
273
274 expected_cl = {
275 'repo_name': 'chromium',
276 'revision': 'rev1'
277 }
278
279 self.assertEqual(cl, expected_cl)
280
281
282 def testGetSuspectedCLFoundByHeuristicForCompileReturnNoneIfNoAnalysis(self):
283 self.assertIsNone(identify_culprit_pipeline. \
284 _GetSuspectedCLFoundByHeuristicForCompile(None))
285
286
287 def testGetSuspectedCLFoundByHeuristicForCompileReturnNone(self):
288 master_name = 'm'
289 builder_name = 'b'
290 build_number = 9
291 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
292 analysis.result = {
293 'failures': [
294 {
295 'step_name': 'other_step',
296 'suspected_cls': [
297 {
298 'repo_name': 'chromium',
299 'revision': 'rev1'
300 }
301 ]
302 }
303 ]
304 }
305 analysis.put()
306
307 self.assertIsNone(identify_culprit_pipeline. \
308 _GetSuspectedCLFoundByHeuristicForCompile(analysis))
309
310
311
312 def testNotifyCulpritsIfHeuristicFoundCulpritForCompile(self):
313 master_name = 'm'
314 builder_name = 'b'
315 build_number = 9
316 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
317 analysis.result = {
318 'failures': [
319 {
320 'step_name': 'compile',
321 'suspected_cls': [
322 {
323 'repo_name': 'chromium',
324 'revision': 'rev1'
325 }
326 ]
327 }
328 ]
329 }
330 analysis.put()
331
332 instances = []
333 class Mocked_SendNotificationForCulpritPipeline(object):
334 def __init__(self, *args):
335 self.args = args
336 self.started = False
337 instances.append(self)
338
339 def start(self):
340 self.started = True
341
342 self.mock(
343 identify_culprit_pipeline, 'SendNotificationForCulpritPipeline',
344 Mocked_SendNotificationForCulpritPipeline)
345
346
347 identify_culprit_pipeline._NotifyCompileCulprits(
348 master_name, builder_name, build_number, analysis)
349 self.assertEqual(1, len(instances))
350 self.assertTrue(instances[0].started)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698