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

Unified Diff: appengine/findit/handlers/test/build_failure_test.py

Issue 2398903002: [Findit] Display confidence score on result page. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/handlers/test/build_failure_test.py
diff --git a/appengine/findit/handlers/test/build_failure_test.py b/appengine/findit/handlers/test/build_failure_test.py
index f1d9fc812aaada2a98db7951e3b4a9b29295ddfc..9085b6e361bf8487b0fd88cdc4b87a7b9823c496 100644
--- a/appengine/findit/handlers/test/build_failure_test.py
+++ b/appengine/findit/handlers/test/build_failure_test.py
@@ -10,6 +10,7 @@ from google.appengine.ext import testbed
import webapp2
import webtest
+from common.waterfall import failure_type
from handlers import build_failure
from handlers import handlers_util
from handlers import result_status
@@ -17,6 +18,7 @@ from model import analysis_approach_type
from model import analysis_status
from model import suspected_cl_status
from model.base_build_model import BaseBuildModel
+from model.cl_confidence import CLConfidence
from model.wf_analysis import WfAnalysis
from model.wf_suspected_cl import WfSuspectedCL
from model.wf_try_job import WfTryJob
@@ -109,6 +111,20 @@ SAMPLE_TRY_JOB_INFO = {
}
}
+SAMPLE_HEURISTIC = {
+ '5': {
+ 'confidence': 0.9478
+ }
+}
+
+SAMPLE_TRY_JOB = {
+ 'confidence': 0.85
+}
+
+SAMPLE_HEURISTIC_TRY_JOB = {
+ 'confidence': 0.9778
+}
+
class BuildFailureTest(wf_testcase.WaterfallTestCase):
app_module = webapp2.WSGIApplication([
@@ -130,6 +146,19 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
return SAMPLE_TRY_JOB_INFO.get(build_key, None)
self.mock(handlers_util, 'GetAllTryJobResults', MockedGetAllTryJobResults)
+ self.cl_confidences = CLConfidence()
+ self.cl_confidences.compile_heuristic = SAMPLE_HEURISTIC
+ self.cl_confidences.test_heuristic = SAMPLE_HEURISTIC
+ self.cl_confidences.compile_try_job = SAMPLE_TRY_JOB
+ self.cl_confidences.test_try_job = SAMPLE_TRY_JOB
+ self.cl_confidences.compile_heuristic_try_job = SAMPLE_HEURISTIC_TRY_JOB
+ self.cl_confidences.test_heuristic_try_job = SAMPLE_HEURISTIC_TRY_JOB
+ self.cl_confidences.put()
+ def MockGetMostRecentConfidence():
+ return self.cl_confidences
+ self.mock(
+ build_failure, '_GetMostRecentConfidence', MockGetMostRecentConfidence)
+
def testGetTriageHistoryWhenUserIsNotAdmin(self):
analysis = WfAnalysis.Create('m', 'b', 1)
analysis.status = analysis_status.COMPLETED
@@ -802,12 +831,12 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
suspected_cl = WfSuspectedCL.Create('chromium', 'rev', 122)
suspected_cl.builds = {
'm/b/123': {
- 'failure_type': 'compile',
+ 'failure_type': failure_type.COMPILE,
'failures': None,
'status': suspected_cl_status.CORRECT,
- 'approach': analysis_approach_type.HEURISTIC,
- 'top_score': 5,
- 'Confidence': 97.9
+ 'approaches': [analysis_approach_type.HEURISTIC,
+ analysis_approach_type.TRY_JOB],
+ 'top_score': 5
}
}
suspected_cl.put()
@@ -828,7 +857,9 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
'revision': 'rev',
'commit_position': 122,
'url': None,
- 'status': suspected_cl_status.CORRECT
+ 'status': suspected_cl_status.CORRECT,
+ 'confidence': build_failure._PercentFormat(
+ self.cl_confidences.compile_heuristic_try_job['confidence'])
}
]
@@ -858,12 +889,11 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
suspected_cl = WfSuspectedCL.Create('chromium', 'rev', 122)
suspected_cl.builds = {
'm/b/122': {
- 'failure_type': 'compile',
+ 'failure_type': failure_type.COMPILE,
'failures': None,
'status': suspected_cl_status.CORRECT,
- 'approach': analysis_approach_type.HEURISTIC,
- 'top_score': 5,
- 'Confidence': 97.9
+ 'approaches': [analysis_approach_type.TRY_JOB],
+ 'top_score': 5
}
}
suspected_cl.put()
@@ -874,7 +904,8 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
'revision': 'rev',
'commit_position': 122,
'url': None,
- 'status': None
+ 'status': None,
+ 'confidence': None
}
]
@@ -883,3 +914,95 @@ class BuildFailureTest(wf_testcase.WaterfallTestCase):
self.assertEqual(
expected_suspected_cls, suspected_cls)
+ def testGetConfidenceTestHeuristic(self):
+ build = {
+ 'failure_type': failure_type.TEST,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [analysis_approach_type.HEURISTIC],
+ 'top_score': 5
+ }
+
+ self.assertEqual(
+ build_failure._PercentFormat(
+ self.cl_confidences.test_heuristic['5']['confidence']),
+ build_failure._GetConfidence(
+ self.cl_confidences, build))
+
+ def testGetConfidenceCompileHeuristic(self):
+ build = {
+ 'failure_type': failure_type.COMPILE,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [analysis_approach_type.HEURISTIC],
+ 'top_score': 5
+ }
+
+ self.assertEqual(
+ build_failure._PercentFormat(
+ self.cl_confidences.compile_heuristic['5']['confidence']),
+ build_failure._GetConfidence(
+ self.cl_confidences, build))
+
+ def testGetConfidenceTestTryJob(self):
+ build = {
+ 'failure_type': failure_type.TEST,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [analysis_approach_type.TRY_JOB],
+ 'top_score': 5
+ }
+
+ self.assertEqual(
+ build_failure._PercentFormat(
+ self.cl_confidences.test_try_job['confidence']),
+ build_failure._GetConfidence(
+ self.cl_confidences, build))
+
+ def testGetConfidenceCompileTryJob(self):
+ build = {
+ 'failure_type': failure_type.COMPILE,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [analysis_approach_type.TRY_JOB],
+ 'top_score': 5
+ }
+
+ self.assertEqual(
+ build_failure._PercentFormat(
+ self.cl_confidences.test_try_job['confidence']),
+ build_failure._GetConfidence(
+ self.cl_confidences, build))
+
+ def testGetConfidenceTestHeuristicTryJob(self):
+ build = {
+ 'failure_type': failure_type.TEST,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [analysis_approach_type.HEURISTIC,
+ analysis_approach_type.TRY_JOB],
+ 'top_score': 5
+ }
+
+ self.assertEqual(
+ build_failure._PercentFormat(
+ self.cl_confidences.test_heuristic_try_job['confidence']),
+ build_failure._GetConfidence(
+ self.cl_confidences, build))
+
+ def testGetConfidenceNone(self):
+ self.assertIsNone(build_failure._GetConfidence(None, None))
+
+ def testGetConfidenceUnexpected(self):
+ build = {
+ 'failure_type': failure_type.COMPILE,
+ 'failures': None,
+ 'status': suspected_cl_status.CORRECT,
+ 'approaches': [],
+ 'top_score': 5
+ }
+
+ self.assertIsNone(build_failure._GetConfidence(self.cl_confidences, build))
+
+ def testPercentFormatNone(self):
+ self.assertIsNone(build_failure._PercentFormat(None))

Powered by Google App Engine
This is Rietveld 408576698