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

Side by Side Diff: appengine/findit/handlers/flake/check_flake.py

Issue 2195473002: [Findit] Dashboards and graph for regression range (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: addressed comments Created 4 years, 4 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.
chanli 2016/08/01 20:42:03 Did you overwrite this file by tests by mistake?
caiw 2016/08/02 00:20:37 yes...sorry about that.
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 from google.appengine.api import users 5 import webapp2
6 6
7 from common import constants 7 from handlers.flake import check_flake
8 from common.base_handler import BaseHandler 8
9 from common.base_handler import Permission 9 from waterfall.test import wf_testcase
10 from waterfall.flake.initialize_flake_pipeline import ScheduleAnalysisIfNeeded 10 from model.flake.master_flake_analysis import MasterFlakeAnalysis
11 from model import analysis_status
11 12
12 13
13 class CheckFlake(BaseHandler): 14 class CheckFlakeTest(wf_testcase.WaterfallTestCase):
14 PERMISSION_LEVEL = Permission.CORP_USER 15 app_module = webapp2.WSGIApplication([
16 ('/waterfall/check-flake', check_flake.CheckFlake),
17 ], debug=True)
15 18
16 def HandleGet(self): 19 def _CreateAndSaveMasterFlakeAnalysis(
17 # Get input parameters. 20 self, master_name, builder_name, build_number,
18 # pylint: disable=W0612 21 step_name, test_name, status):
19 master_name = self.request.get('master_name').strip() 22 analysis = MasterFlakeAnalysis.Create(
20 builder_name = self.request.get('builder_name').strip() 23 master_name, builder_name, build_number, step_name, test_name)
21 build_number = int(self.request.get('build_number').strip()) 24 analysis.status = status
22 step_name = self.request.get('test_target_name').strip() 25 analysis.put()
23 test_name = self.request.get('test_name').strip() 26 return analysis
24 force = (users.is_current_user_admin() and
25 self.request.get('force') == '1')
26 27
27 ScheduleAnalysisIfNeeded(master_name, builder_name, build_number, step_name, 28 def setUp(self):
28 test_name, force=force, 29 super(CheckFlakeTest, self).setUp()
29 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) 30
30 return { 31 def testBasicFlowNoData(self):
31 'template': 'flake/result.html' 32 master_name = 'm'
32 } 33 builder_name = 'b'
34 build_number = '123'
35 step_name = 's'
36 test_name = 't'
37
38 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
39
40 response = self.test_app.get('/waterfall/check-flake', params={
41 'master_name': master_name,
42 'builder_name': builder_name,
43 'build_number': build_number,
44 'step_name': step_name,
45 'test_name': test_name})
46
47 self.assertEquals(200, response.status_int)
48
49 def testBasicFlowWithData(self):
50 master_name = 'm'
51 builder_name = 'b'
52 build_number = '123'
53 step_name = 's'
54 test_name = 't'
55
56 status = analysis_status.PENDING
57
58 master_flake_analysis = self._CreateAndSaveMasterFlakeAnalysis(
59 master_name, builder_name, build_number, step_name,
60 test_name, status)
61 master_flake_analysis.build_numbers.append(123)
62 master_flake_analysis.success_rates.append(.9)
63 master_flake_analysis.put()
64
65 self.mock_current_user(user_email='test@chromium.org', is_admin=True)
66
67 response = self.test_app.get('/waterfall/check-flake', params={
68 'master_name': master_name,
69 'builder_name': builder_name,
70 'build_number': build_number,
71 'step_name': step_name,
72 'test_name': test_name})
73
74 self.assertEquals(200, response.status_int)
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/handlers/flake/flake_dashboard.py » ('j') | appengine/findit/handlers/flake/flake_dashboard.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698