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

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: Clean up and adding unit tests 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 'triage_history': None,
116 'show_debug_info': False
108 } 117 }
109 118
110 self.assertEquals(200, response.status_int) 119 self.assertEquals(200, response.status_int)
111 self.assertEqual(expected_check_flake_result, response.json_body) 120 self.assertEqual(expected_check_flake_result, response.json_body)
121
122 @mock.patch.object(users, 'is_current_user_admin', return_value=True)
123 def testGetTriageHistory(self, _):
124 master_name = 'm'
125 builder_name = 'b'
126 build_number = '123'
127 step_name = 's'
128 test_name = 't'
129 suspected_flake_build_number = '100'
130 triage_result = 2
131 user_name = 'test'
132
133 analysis = MasterFlakeAnalysis.Create(
134 master_name, builder_name, build_number, step_name, test_name)
135 analysis.status = analysis_status.COMPLETED
136 analysis.suspected_flake_build_number = 100
137 analysis.Save()
138 analysis.UpdateTriageResult(
139 triage_result, suspected_flake_build_number, 'test')
140
141 response = self.test_app.get('/waterfall/check-flake', params={
142 'master_name': master_name,
143 'builder_name': builder_name,
144 'build_number': build_number,
145 'step_name': step_name,
146 'test_name': test_name,
147 'format': 'json'})
148
149 # Because TriagedResult uses auto_now=True, a direct dict comparison will
150 # always fail. Instead only compare the relevant fields for trige_history.
151 triage_history = response.json_body.get('triage_history')
152 self.assertEqual(len(triage_history), 1)
153 self.assertEqual(triage_history[0].get('triage_result'), 'Correct')
154 self.assertEqual(triage_history[0].get('user_name'), user_name)
155 self.assertEqual(triage_history[0].get('suspect_info'),
156 suspected_flake_build_number)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698