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

Unified Diff: appengine/findit/test/findit_api_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 side-by-side diff with in-line comments
Download patch
Index: appengine/findit/test/findit_api_test.py
diff --git a/appengine/findit/test/findit_api_test.py b/appengine/findit/test/findit_api_test.py
index b2e109362a1580b0e890ab02e4e0741dcd0adb8c..d10c224c1e567a6ba3d17f7e53958b6775684a1d 100644
--- a/appengine/findit/test/findit_api_test.py
+++ b/appengine/findit/test/findit_api_test.py
@@ -6,7 +6,6 @@ import json
import mock
import re
-import endpoints
from google.appengine.api import taskqueue
import webtest
@@ -15,10 +14,14 @@ from testing_utils import testing
from common.waterfall import failure_type
import findit_api
from findit_api import FindItApi
+from model import analysis_approach_type
+from model.base_build_model import BaseBuildModel
from model.wf_analysis import WfAnalysis
+from model.wf_suspected_cl import WfSuspectedCL
from model.wf_swarming_task import WfSwarmingTask
from model.wf_try_job import WfTryJob
from model import analysis_status
+from waterfall import suspected_cl_util
from waterfall import waterfall_config
@@ -219,9 +222,12 @@ class FinditApiTest(testing.EndpointsTestCase):
'repo_name': 'chromium',
'revision': 'git_hash',
'commit_position': 123,
+ 'analysis_approach': 'HEURISTIC'
}
],
'analysis_approach': 'HEURISTIC',
+ 'try_job_status': 'FINISHED',
+ 'is_flaky_test': False
},
]
@@ -338,14 +344,18 @@ class FinditApiTest(testing.EndpointsTestCase):
'repo_name': 'chromium',
'revision': 'git_hash1',
'commit_position': 234,
+ 'analysis_approach': 'HEURISTIC'
},
{
'repo_name': 'chromium',
'revision': 'git_hash2',
'commit_position': 288,
+ 'analysis_approach': 'HEURISTIC'
}
],
'analysis_approach': 'HEURISTIC',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
}
]
@@ -429,9 +439,12 @@ class FinditApiTest(testing.EndpointsTestCase):
'repo_name': 'chromium',
'revision': 'r3',
'commit_position': 3,
+ 'analysis_approach': 'TRY_JOB'
},
],
'analysis_approach': 'TRY_JOB',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
}
]
@@ -441,7 +454,159 @@ class FinditApiTest(testing.EndpointsTestCase):
self.assertEqual(200, response.status_int)
self.assertEqual(expected_results, response.json_body.get('results'))
- def testTestLevelResultIsReturned(self):
+ def testTryJobIsRunning(self):
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 5
+
+ master_url = 'https://build.chromium.org/p/%s' % master_name
+ builds = {
+ 'builds': [
+ {
+ 'master_url': master_url,
+ 'builder_name': builder_name,
+ 'build_number': build_number
+ }
+ ]
+ }
+
+ try_job = WfTryJob.Create(master_name, builder_name, 3)
+ try_job.status = analysis_status.RUNNING
+ try_job.put()
+
+ analysis = WfAnalysis.Create(master_name, builder_name, build_number)
+ analysis.status = analysis_status.COMPLETED
+ analysis.build_failure_type = failure_type.COMPILE
+ analysis.failure_result_map = {
+ 'compile': '/'.join([master_name, builder_name, '3']),
+ }
+ analysis.result = {
+ 'failures': [
+ {
+ 'step_name': 'compile',
+ 'first_failure': 3,
+ 'last_pass': 1,
+ 'suspected_cls': [
+ {
+ 'build_number': 3,
+ 'repo_name': 'chromium',
+ 'revision': 'git_hash2',
+ 'commit_position': 288,
+ 'score': 1,
+ 'hints': {
+ 'modify d/e/f.cc': 1,
+ }
+ }
+ ]
+ }
+ ]
+ }
+ analysis.put()
+
+ expected_results = [
+ {
+ 'master_url': master_url,
+ 'builder_name': builder_name,
+ 'build_number': build_number,
+ 'step_name': 'compile',
+ 'is_sub_test': False,
+ 'first_known_failed_build_number': 3,
+ 'suspected_cls': [
+ {
+ 'repo_name': 'chromium',
+ 'revision': 'git_hash2',
+ 'commit_position': 288,
+ 'analysis_approach': 'HEURISTIC'
+ },
+ ],
+ 'analysis_approach': 'HEURISTIC',
+ 'is_flaky_test': False,
+ 'try_job_status': 'RUNNING'
+ }
+ ]
+
+ self._MockMasterIsSupported(supported=True)
+
+ response = self.call_api('AnalyzeBuildFailures', body=builds)
+ self.assertEqual(200, response.status_int)
+ self.assertEqual(expected_results, response.json_body.get('results'))
+
+ def testTestIsFlaky(self):
+ master_name = 'm'
+ builder_name = 'b'
+ build_number = 5
+
+ master_url = 'https://build.chromium.org/p/%s' % master_name
+ builds = {
+ 'builds': [
+ {
+ 'master_url': master_url,
+ 'builder_name': builder_name,
+ 'build_number': build_number
+ }
+ ]
+ }
+
+ task = WfSwarmingTask.Create(master_name, builder_name, 3, 'b on platform')
+ task.tests_statuses = {
+ 'Unittest3.Subtest1': {
+ 'total_run': 4,
+ 'SUCCESS': 2,
+ 'FAILURE': 2
+ }
+ }
+ task.put()
+
+ analysis = WfAnalysis.Create(master_name, builder_name, build_number)
+ analysis.status = analysis_status.COMPLETED
+ analysis.failure_result_map = {
+ 'b on platform': {
+ 'Unittest3.Subtest1': '/'.join([master_name, builder_name, '3']),
+ },
+ }
+ analysis.result = {
+ 'failures': [
+ {
+ 'step_name': 'b on platform',
+ 'first_failure': 3,
+ 'last_pass': 2,
+ 'suspected_cls': [],
+ 'tests': [
+ {
+ 'test_name': 'Unittest3.Subtest1',
+ 'first_failure': 3,
+ 'last_pass': 2,
+ 'suspected_cls': []
+ }
+ ]
+ }
+ ]
+ }
+ analysis.put()
+
+ expected_results = [
+ {
+ 'master_url': master_url,
+ 'builder_name': builder_name,
+ 'build_number': build_number,
+ 'step_name': 'b on platform',
+ 'is_sub_test': True,
+ 'test_name': 'Unittest3.Subtest1',
+ 'first_known_failed_build_number': 3,
+ 'analysis_approach': 'HEURISTIC',
+ 'is_flaky_test': True,
+ 'try_job_status': 'FINISHED'
+ }
+ ]
+
+ self._MockMasterIsSupported(supported=True)
+
+ response = self.call_api('AnalyzeBuildFailures', body=builds)
+ self.assertEqual(200, response.status_int)
+ self.assertEqual(expected_results, response.json_body.get('results'))
+
+ @mock.patch.object(suspected_cl_util, 'GetSuspectedCLConfidenceScore')
+ def testTestLevelResultIsReturned(self, mock_fn):
master_name = 'm'
builder_name = 'b'
build_number = 5
@@ -593,6 +758,30 @@ class FinditApiTest(testing.EndpointsTestCase):
}
analysis.put()
+ suspected_cl_42 = WfSuspectedCL.Create('chromium', 'r4_2', 42)
+ suspected_cl_42.builds = {
+ BaseBuildModel.CreateBuildId(master_name, builder_name, 4): {
+ 'approaches': [analysis_approach_type.TRY_JOB]
+ }
+ }
+ suspected_cl_42.put()
+
+ suspected_cl_21 = WfSuspectedCL.Create('chromium', 'r2_1', None)
+ suspected_cl_21.builds = {
+ BaseBuildModel.CreateBuildId(master_name, builder_name, build_number): {
+ 'approaches': [analysis_approach_type.HEURISTIC],
+ 'top_score': 5
+ }
+ }
+ suspected_cl_21.put()
+
+ def confidence_side_effect(_, build_info):
+ if build_info.get('top_score'):
+ return 90
+ return 98
+
+ mock_fn.side_effect = confidence_side_effect
+
expected_results = [
{
'master_url': master_url,
@@ -606,9 +795,13 @@ class FinditApiTest(testing.EndpointsTestCase):
'repo_name': 'chromium',
'revision': 'r4_2',
'commit_position': 42,
+ 'confidence': 98,
+ 'analysis_approach': 'TRY_JOB'
}
],
'analysis_approach': 'TRY_JOB',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
},
{
'master_url': master_url,
@@ -622,9 +815,13 @@ class FinditApiTest(testing.EndpointsTestCase):
{
'repo_name': 'chromium',
'revision': 'r2_1',
+ 'confidence': 90,
+ 'analysis_approach': 'HEURISTIC'
}
],
'analysis_approach': 'HEURISTIC',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
},
{
'master_url': master_url,
@@ -638,9 +835,13 @@ class FinditApiTest(testing.EndpointsTestCase):
{
'repo_name': 'chromium',
'revision': 'r2_1',
+ 'confidence': 90,
+ 'analysis_approach': 'HEURISTIC'
}
],
'analysis_approach': 'HEURISTIC',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
},
{
'master_url': master_url,
@@ -655,9 +856,12 @@ class FinditApiTest(testing.EndpointsTestCase):
'repo_name': 'chromium',
'revision': 'r4_10',
'commit_position': 410,
+ 'analysis_approach': 'TRY_JOB'
}
],
'analysis_approach': 'TRY_JOB',
+ 'is_flaky_test': False,
+ 'try_job_status': 'FINISHED'
}
]

Powered by Google App Engine
This is Rietveld 408576698