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

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