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

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

Issue 2425853005: [Findit] Modify Findit API to return more information to Sheriff-O-Matic. (Closed)
Patch Set: rebase Created 4 years, 1 month 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
« no previous file with comments | « appengine/findit/waterfall/suspected_cl_util.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 datetime 5 import datetime
6 6
7 from common import time_util
8 from common.waterfall import failure_type 7 from common.waterfall import failure_type
9 from model import analysis_approach_type 8 from model import analysis_approach_type
10 from model import suspected_cl_status 9 from model import suspected_cl_status
10 from model.suspected_cl_confidence import ConfidenceInformation
11 from model.suspected_cl_confidence import SuspectedCLConfidence
11 from model.wf_suspected_cl import WfSuspectedCL 12 from model.wf_suspected_cl import WfSuspectedCL
12 from waterfall import build_util 13 from waterfall import build_util
13 from waterfall import suspected_cl_util 14 from waterfall import suspected_cl_util
14 from waterfall.test import wf_testcase 15 from waterfall.test import wf_testcase
15 16
16 17
18 SAMPLE_HEURISTIC_1 = ConfidenceInformation(
19 correct=100, total=100, confidence=1.0, score=5)
20
21 SAMPLE_HEURISTIC_2 = ConfidenceInformation(
22 correct=90, total=100, confidence=0.9, score=4)
23
24 SAMPLE_TRY_JOB = ConfidenceInformation(
25 correct=99, total=100, confidence=0.99, score=None)
26
27 SAMPLE_HEURISTIC_TRY_JOB = ConfidenceInformation(
28 correct=98, total=100, confidence=0.98, score=None)
29
30
17 class SuspectedCLUtilTest(wf_testcase.WaterfallTestCase): 31 class SuspectedCLUtilTest(wf_testcase.WaterfallTestCase):
18 32
33 def setUp(self):
34 super(SuspectedCLUtilTest, self).setUp()
35
36 self.cl_confidences = SuspectedCLConfidence.Create()
37 self.cl_confidences.compile_heuristic = [
38 SAMPLE_HEURISTIC_1, SAMPLE_HEURISTIC_2]
39 self.cl_confidences.test_heuristic = [
40 SAMPLE_HEURISTIC_2, SAMPLE_HEURISTIC_1]
41 self.cl_confidences.compile_try_job = SAMPLE_TRY_JOB
42 self.cl_confidences.test_try_job = SAMPLE_TRY_JOB
43 self.cl_confidences.compile_heuristic_try_job = SAMPLE_HEURISTIC_TRY_JOB
44 self.cl_confidences.test_heuristic_try_job = SAMPLE_HEURISTIC_TRY_JOB
45 self.cl_confidences.Save()
46
19 def testCreateWfSuspectedCL(self): 47 def testCreateWfSuspectedCL(self):
20 approach = analysis_approach_type.HEURISTIC 48 approach = analysis_approach_type.HEURISTIC
21 master_name = 'm' 49 master_name = 'm'
22 builder_name = 'b' 50 builder_name = 'b'
23 build_number = 123 51 build_number = 123
24 compile_failure_type = failure_type.COMPILE 52 compile_failure_type = failure_type.COMPILE
25 repo_name = 'chromium' 53 repo_name = 'chromium'
26 revision = 'r1' 54 revision = 'r1'
27 commit_position = 1 55 commit_position = 1
28 failures = {'compile': []} 56 failures = {'compile': []}
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 261
234 self.assertIsNotNone(suspected_cl) 262 self.assertIsNotNone(suspected_cl)
235 self.assertEqual( 263 self.assertEqual(
236 [analysis_approach_type.HEURISTIC], suspected_cl.approaches) 264 [analysis_approach_type.HEURISTIC], suspected_cl.approaches)
237 self.assertEqual([test_failure_type], suspected_cl.failure_type) 265 self.assertEqual([test_failure_type], suspected_cl.failure_type)
238 self.assertEqual(expected_builds, suspected_cl.builds) 266 self.assertEqual(expected_builds, suspected_cl.builds)
239 267
240 def testGetCLInfo(self): 268 def testGetCLInfo(self):
241 self.assertEqual(['chromium', 'rev1'], 269 self.assertEqual(['chromium', 'rev1'],
242 suspected_cl_util.GetCLInfo('chromium/rev1')) 270 suspected_cl_util.GetCLInfo('chromium/rev1'))
271
272 def testGetConfidenceScoreTestHeuristic(self):
273 build = {
274 'failure_type': failure_type.TEST,
275 'failures': None,
276 'status': suspected_cl_status.CORRECT,
277 'approaches': [analysis_approach_type.HEURISTIC],
278 'top_score': 5
279 }
280
281 self.assertEqual(
282 suspected_cl_util._RoundConfidentToInteger(
283 self.cl_confidences.test_heuristic[1].confidence),
284 suspected_cl_util.GetSuspectedCLConfidenceScore(
285 self.cl_confidences, build))
286
287 def testGetConfidenceScoreCompileHeuristic(self):
288 build = {
289 'failure_type': failure_type.COMPILE,
290 'failures': None,
291 'status': suspected_cl_status.CORRECT,
292 'approaches': [analysis_approach_type.HEURISTIC],
293 'top_score': 4
294 }
295
296 self.assertEqual(
297 suspected_cl_util._RoundConfidentToInteger(
298 self.cl_confidences.compile_heuristic[1].confidence),
299 suspected_cl_util.GetSuspectedCLConfidenceScore(
300 self.cl_confidences, build))
301
302 def testGetConfidenceScoreTestTryJob(self):
303 build = {
304 'failure_type': failure_type.TEST,
305 'failures': None,
306 'status': suspected_cl_status.CORRECT,
307 'approaches': [analysis_approach_type.TRY_JOB],
308 'top_score': 5
309 }
310
311 self.assertEqual(
312 suspected_cl_util._RoundConfidentToInteger(
313 self.cl_confidences.test_try_job.confidence),
314 suspected_cl_util.GetSuspectedCLConfidenceScore(
315 self.cl_confidences, build))
316
317 def testGetConfidenceScoreCompileTryJob(self):
318 build = {
319 'failure_type': failure_type.COMPILE,
320 'failures': None,
321 'status': suspected_cl_status.CORRECT,
322 'approaches': [analysis_approach_type.TRY_JOB],
323 'top_score': 5
324 }
325
326 self.assertEqual(
327 suspected_cl_util._RoundConfidentToInteger(
328 self.cl_confidences.test_try_job.confidence),
329 suspected_cl_util.GetSuspectedCLConfidenceScore(
330 self.cl_confidences, build))
331
332 def testGetConfidenceScoreTestHeuristicTryJob(self):
333 build = {
334 'failure_type': failure_type.TEST,
335 'failures': None,
336 'status': suspected_cl_status.CORRECT,
337 'approaches': [analysis_approach_type.HEURISTIC,
338 analysis_approach_type.TRY_JOB],
339 'top_score': 5
340 }
341
342 self.assertEqual(
343 suspected_cl_util._RoundConfidentToInteger(
344 self.cl_confidences.test_heuristic_try_job.confidence),
345 suspected_cl_util.GetSuspectedCLConfidenceScore(
346 self.cl_confidences, build))
347
348 def testGetConfidenceScoreCompileHeuristicTryJob(self):
349 build = {
350 'failure_type': failure_type.COMPILE,
351 'failures': None,
352 'status': suspected_cl_status.CORRECT,
353 'approaches': [analysis_approach_type.HEURISTIC,
354 analysis_approach_type.TRY_JOB],
355 'top_score': 5
356 }
357
358 self.assertEqual(
359 suspected_cl_util._RoundConfidentToInteger(
360 self.cl_confidences.compile_heuristic_try_job.confidence),
361 suspected_cl_util.GetSuspectedCLConfidenceScore(
362 self.cl_confidences, build))
363
364 def testGetConfidenceScoreNone(self):
365 self.assertIsNone(
366 suspected_cl_util.GetSuspectedCLConfidenceScore(None, None))
367
368 def testGetConfidenceScoreUnexpected(self):
369 build = {
370 'failure_type': failure_type.COMPILE,
371 'failures': None,
372 'status': suspected_cl_status.CORRECT,
373 'approaches': [analysis_approach_type.HEURISTIC],
374 'top_score': 2
375 }
376
377 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore(
378 self.cl_confidences, build))
379
380 def testGetConfidenceScoreCompileNone(self):
381 build = {
382 'failure_type': failure_type.COMPILE,
383 'approaches': []
384 }
385 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore(
386 self.cl_confidences, build))
387
388 def testGetConfidenceScoreUnexpectedTest(self):
389 build = {
390 'failure_type': failure_type.TEST,
391 'failures': None,
392 'status': suspected_cl_status.CORRECT,
393 'approaches': [analysis_approach_type.HEURISTIC],
394 'top_score': 2
395 }
396
397 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore(
398 self.cl_confidences, build))
399
400 def testGetConfidenceScoreTestNone(self):
401 build = {
402 'failure_type': failure_type.TEST,
403 'approaches': []
404 }
405 self.assertIsNone(suspected_cl_util.GetSuspectedCLConfidenceScore(
406 self.cl_confidences, build))
OLDNEW
« no previous file with comments | « appengine/findit/waterfall/suspected_cl_util.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698