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

Side by Side Diff: appengine/findit/handlers/test/build_failure_test.py

Issue 2361583002: [Findit] UI change and triage change for cl level trige. (Closed)
Patch Set: rebase 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 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 os 5 import os
6 import re 6 import re
7 7
8 from google.appengine.ext import testbed 8 from google.appengine.ext import testbed
9 9
10 import webapp2 10 import webapp2
11 import webtest 11 import webtest
12 12
13 from handlers import build_failure 13 from handlers import build_failure
14 from handlers import handlers_util 14 from handlers import handlers_util
15 from handlers import result_status 15 from handlers import result_status
16 from model import analysis_approach_type
17 from model import analysis_status
18 from model import suspected_cl_status
16 from model.wf_analysis import WfAnalysis 19 from model.wf_analysis import WfAnalysis
20 from model.wf_suspected_cl import WfSuspectedCL
17 from model.wf_try_job import WfTryJob 21 from model.wf_try_job import WfTryJob
18 from model import analysis_status
19 from model.wf_analysis import WfAnalysis
20 from waterfall import buildbot 22 from waterfall import buildbot
21 from waterfall.test import wf_testcase 23 from waterfall.test import wf_testcase
22 24
23 # Root directory appengine/findit. 25 # Root directory appengine/findit.
24 ROOT_DIR = os.path.join(os.path.dirname(__file__), 26 ROOT_DIR = os.path.join(os.path.dirname(__file__),
25 os.path.pardir, os.path.pardir) 27 os.path.pardir, os.path.pardir)
26 28
27 SAMPLE_TRY_JOB_INFO = { 29 SAMPLE_TRY_JOB_INFO = {
28 'm/b/119': { 30 'm/b/119': {
29 'step1 on platform': { 31 'step1 on platform': {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 analysis.triage_history = [ 134 analysis.triage_history = [
133 { 135 {
134 'triage_timestamp': 1438380761, 136 'triage_timestamp': 1438380761,
135 'user_name': 'test', 137 'user_name': 'test',
136 'result_status': 'dummy status', 138 'result_status': 'dummy status',
137 'version': 'dummy version', 139 'version': 'dummy version',
138 } 140 }
139 ] 141 ]
140 self.assertIsNone(build_failure._GetTriageHistory(analysis)) 142 self.assertIsNone(build_failure._GetTriageHistory(analysis))
141 143
144 def testGetCLDict(self):
145 analysis = WfAnalysis.Create('m', 'b', 1)
146 analysis.suspected_cls = [
147 {
148 'repo_name': 'chromium',
149 'revision': 'rev2',
150 'url': 'url',
151 'commit_position': 123
152 }
153 ]
154 analysis.put()
155 cl_info = 'chromium/rev1'
156 self.assertIsNone(build_failure._GetCLDict(analysis, cl_info))
157
158 def testGetCLDictNone(self):
159 self.assertIsNone(build_failure._GetCLDict(None, None))
160
142 def testGetTriageHistoryWhenUserIsAdmin(self): 161 def testGetTriageHistoryWhenUserIsAdmin(self):
143 analysis = WfAnalysis.Create('m', 'b', 1) 162 analysis = WfAnalysis.Create('m', 'b', 1)
144 analysis.status = analysis_status.COMPLETED 163 analysis.status = analysis_status.COMPLETED
164 analysis.suspected_cls = [
165 {
166 'repo_name': 'chromium',
167 'revision': 'rev1',
168 'url': 'url',
169 'commit_position': 123
170 }
171 ]
145 analysis.triage_history = [ 172 analysis.triage_history = [
146 { 173 {
147 'triage_timestamp': 1438380761, 174 'triage_timestamp': 1438380761,
148 'user_name': 'test', 175 'user_name': 'test',
149 'result_status': 'dummy status', 176 'result_status': 'dummy status',
150 'version': 'dummy version', 177 'version': 'dummy version',
178 'triaged_cl': 'chromium/rev1'
151 } 179 }
152 ] 180 ]
153 self.mock_current_user(user_email='test@chromium.org', is_admin=True) 181 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
154 self.assertEqual(1, len(build_failure._GetTriageHistory(analysis))) 182 self.assertEqual(1, len(build_failure._GetTriageHistory(analysis)))
155 183
156 def testInvalidBuildUrl(self): 184 def testInvalidBuildUrl(self):
157 build_url = 'abc' 185 build_url = 'abc'
158 self.assertRaisesRegexp( 186 self.assertRaisesRegexp(
159 webtest.app.AppError, 187 webtest.app.AppError,
160 re.compile('.*501 Not Implemented.*Url "%s" ' 188 re.compile('.*501 Not Implemented.*Url "%s" '
161 'is not pointing to a build.*' % build_url, 189 'is not pointing to a build.*' % build_url,
162 re.MULTILINE | re.DOTALL), 190 re.MULTILINE | re.DOTALL),
163 self.test_app.get, '/build-failure', params={'url': build_url}) 191 self.test_app.get, '/build-failure', params={'url': build_url})
164 192
165 def testNonAdminCanViewAnalysisOfFailureOnUnsupportedMaster(self): 193 def testNonAdminCanViewAnalysisOfFailureOnUnsupportedMaster(self):
166 master_name = 'm2' 194 master_name = 'm2'
167 builder_name = 'b 1' 195 builder_name = 'b 1'
168 build_number = 123 196 build_number = 123
169 build_url = buildbot.CreateBuildUrl( 197 build_url = buildbot.CreateBuildUrl(
170 master_name, builder_name, build_number) 198 master_name, builder_name, build_number)
171 199
172 analysis = WfAnalysis.Create(master_name, builder_name, build_number) 200 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
173 analysis.status = analysis_status.COMPLETED 201 analysis.status = analysis_status.COMPLETED
202 analysis.suspected_cls = [
203 {
204 'repo_name': 'chromium',
205 'revision': 'r99_2',
206 'commit_position': None,
207 'url': None,
208 }
209 ]
174 analysis.put() 210 analysis.put()
175 211
176 response = self.test_app.get('/build-failure', 212 response = self.test_app.get('/build-failure',
177 params={'url': build_url}) 213 params={'url': build_url})
178 self.assertEquals(200, response.status_int) 214 self.assertEquals(200, response.status_int)
179 self.assertEqual(0, len(self.taskqueue_stub.get_filtered_tasks())) 215 self.assertEqual(0, len(self.taskqueue_stub.get_filtered_tasks()))
180 216
181 def testNonAdminCannotRequestAnalysisOfFailureOnUnsupportedMaster(self): 217 def testNonAdminCannotRequestAnalysisOfFailureOnUnsupportedMaster(self):
182 master_name = 'm2' 218 master_name = 'm2'
183 builder_name = 'b 1' 219 builder_name = 'b 1'
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 }, 766 },
731 { 767 {
732 'step_name': 'steps', 768 'step_name': 'steps',
733 }, 769 },
734 ] 770 ]
735 } 771 }
736 analysis.failure_result_map = { 772 analysis.failure_result_map = {
737 'compile': 'm/b/122', 773 'compile': 'm/b/122',
738 } 774 }
739 analysis.status = analysis_status.COMPLETED 775 analysis.status = analysis_status.COMPLETED
776 analysis.suspected_cls = [
777 {
778 'repo_name': 'chromium',
779 'revision': 'rev',
780 'commit_position': 122,
781 'url': None
782 }
783 ]
740 analysis.put() 784 analysis.put()
741 785
742 try_job = WfTryJob.Create('m', 'b', 122) 786 try_job = WfTryJob.Create('m', 'b', 122)
743 try_job.status = analysis_status.COMPLETED 787 try_job.status = analysis_status.COMPLETED
744 try_job.compile_results = [ 788 try_job.compile_results = [
745 { 789 {
746 'url': 'build/url', 790 'url': 'build/url',
747 'culprit': { 791 'culprit': {
748 'compile': { 792 'compile': {
749 'revision': 'rev', 793 'revision': 'rev',
750 } 794 }
751 } 795 }
752 } 796 }
753 ] 797 ]
754 try_job.put() 798 try_job.put()
755 799
800 suspected_cl = WfSuspectedCL.Create('chromium', 'rev', 122)
801 suspected_cl.builds = {
802 'm/b/123': {
803 'failure_type': 'compile',
804 'failures': None,
805 'status': suspected_cl_status.CORRECT,
806 'approach': analysis_approach_type.HEURISTIC,
807 'top_score': 5,
808 'Confidence': 97.9
809 }
810 }
811 suspected_cl.put()
812
756 expected_try_job_result = { 813 expected_try_job_result = {
757 'status': 'completed', 814 'status': 'completed',
758 'url': 'build/url', 815 'url': 'build/url',
759 'completed': True, 816 'completed': True,
760 'culprit': { 817 'culprit': {
761 'revision': 'rev', 818 'revision': 'rev',
762 }, 819 },
763 'failed': False, 820 'failed': False,
764 } 821 }
765 822
823 expected_suspected_cls = [
824 {
825 'repo_name': 'chromium',
826 'revision': 'rev',
827 'commit_position': 122,
828 'url': None,
829 'status': suspected_cl_status.CORRECT
830 }
831 ]
832
766 build_url = buildbot.CreateBuildUrl('m', 'b', 123) 833 build_url = buildbot.CreateBuildUrl('m', 'b', 123)
767 response = self.test_app.get('/build-failure', 834 response = self.test_app.get('/build-failure',
768 params={'url': build_url, 'format': 'json'}) 835 params={'url': build_url, 'format': 'json'})
769 836
770 self.assertEquals(200, response.status_int) 837 self.assertEquals(200, response.status_int)
771 self.assertEqual(expected_try_job_result, response.json_body['try_job']) 838 self.assertEqual(expected_try_job_result, response.json_body['try_job'])
839 self.assertEqual(
840 expected_suspected_cls, response.json_body['suspected_cls'])
841
842 def testGetAllSuspectedCLsAndCheckStatus(self):
843 master_name = 'm'
844 builder_name = 'b'
845 build_number = 123
846 analysis = WfAnalysis.Create(master_name, builder_name, build_number)
847 analysis.suspected_cls = [
848 {
849 'repo_name': 'chromium',
850 'revision': 'rev',
851 'commit_position': 122,
852 'url': None
853 }
854 ]
855 analysis.put()
856 suspected_cl = WfSuspectedCL.Create('chromium', 'rev', 122)
857 suspected_cl.builds = {
858 'm/b/122': {
859 'failure_type': 'compile',
860 'failures': None,
861 'status': suspected_cl_status.CORRECT,
862 'approach': analysis_approach_type.HEURISTIC,
863 'top_score': 5,
864 'Confidence': 97.9
865 }
866 }
867 suspected_cl.put()
868
869 expected_suspected_cls = [
870 {
871 'repo_name': 'chromium',
872 'revision': 'rev',
873 'commit_position': 122,
874 'url': None,
875 'status': None
876 }
877 ]
878
879 suspected_cls = build_failure._GetAllSuspectedCLsAndCheckStatus(
880 master_name, builder_name, build_number, analysis)
881 self.assertEqual(
882 expected_suspected_cls, suspected_cls)
883
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698