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

Side by Side Diff: appengine/findit/handlers/flake/test/check_flake_test.py

Issue 2416303002: [Findit] Adding support for triaging suspected builds from flake analysis (Closed)
Patch Set: Rebase 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 import mock
6 import re 7 import re
7 8
8 import webapp2 9 import webapp2
9 import webtest 10 import webtest
10 11
12 from google.appengine.api import users
13
11 from handlers.flake import check_flake 14 from handlers.flake import check_flake
12 from model.flake.master_flake_analysis import DataPoint 15 from model.flake.master_flake_analysis import DataPoint
13 from model.flake.master_flake_analysis import MasterFlakeAnalysis 16 from model.flake.master_flake_analysis import MasterFlakeAnalysis
14 from model import analysis_status 17 from model import analysis_status
15 from model.analysis_status import STATUS_TO_DESCRIPTION 18 from model.analysis_status import STATUS_TO_DESCRIPTION
16 from waterfall.test import wf_testcase 19 from waterfall.test import wf_testcase
17 20
18 21
19 class CheckFlakeTest(wf_testcase.WaterfallTestCase): 22 class CheckFlakeTest(wf_testcase.WaterfallTestCase):
20 app_module = webapp2.WSGIApplication([ 23 app_module = webapp2.WSGIApplication([
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 'builder_name': builder_name, 100 'builder_name': builder_name,
98 'build_number': int(build_number), 101 'build_number': int(build_number),
99 'step_name': step_name, 102 'step_name': step_name,
100 'test_name': test_name, 103 'test_name': test_name,
101 'request_time': '2016-10-01 12:10:00 UTC', 104 'request_time': '2016-10-01 12:10:00 UTC',
102 'task_number': 1, 105 'task_number': 1,
103 'error': None, 106 'error': None,
104 'iterations_to_rerun': 100, 107 'iterations_to_rerun': 100,
105 'pending_time': '00:00:05', 108 'pending_time': '00:00:05',
106 'duration': '00:59:55', 109 'duration': '00:59:55',
107 'suspected_flake_build_number': 100, 110 'suspected_flake': {
111 'build_number': 100,
112 'triage_result': 0
113 },
114 'version_number': 1,
115 'show_debug_info': False
108 } 116 }
109 117
110 self.assertEquals(200, response.status_int) 118 self.assertEquals(200, response.status_int)
111 self.assertEqual(expected_check_flake_result, response.json_body) 119 self.assertEqual(expected_check_flake_result, response.json_body)
120
121 @mock.patch.object(users, 'is_current_user_admin', return_value=True)
122 def testGetTriageHistory(self, _):
123 master_name = 'm'
124 builder_name = 'b'
125 build_number = '123'
126 step_name = 's'
127 test_name = 't'
128 suspected_flake_build_number = 123
129 triage_result = 2
130 user_name = 'test'
131
132 analysis = MasterFlakeAnalysis.Create(
133 master_name, builder_name, build_number, step_name, test_name)
134 analysis.status = analysis_status.COMPLETED
135 analysis.suspected_flake_build_number = 100
136 analysis.Save()
137 analysis.UpdateTriageResult(
138 triage_result, {'build_number': suspected_flake_build_number}, 'test')
139
140 response = self.test_app.get('/waterfall/check-flake', params={
141 'master_name': master_name,
142 'builder_name': builder_name,
143 'build_number': build_number,
144 'step_name': step_name,
145 'test_name': test_name,
146 'format': 'json'})
147
148 # Because TriagedResult uses auto_now=True, a direct dict comparison will
149 # always fail. Instead only compare the relevant fields for trige_history.
150 triage_history = response.json_body.get('triage_history')
151 self.assertEqual(len(triage_history), 1)
152 self.assertEqual(triage_history[0].get('triage_result'), 'Correct')
153 self.assertEqual(triage_history[0].get('user_name'), user_name)
154 self.assertEqual(
155 triage_history[0].get('suspect_info', {}).get('build_number'),
156 suspected_flake_build_number)
OLDNEW
« no previous file with comments | « appengine/findit/handlers/flake/check_flake.py ('k') | appengine/findit/handlers/flake/triage_flake_analysis.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698