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

Side by Side Diff: appengine/findit/handlers/flake/check_flake.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 from google.appengine.api import users 5 import time
6 from datetime import datetime
6 7
7 from common import auth_util 8 from common import auth_util
8 from common import constants 9 from common import constants
9 from common import time_util 10 from common import time_util
10 from common.base_handler import BaseHandler 11 from common.base_handler import BaseHandler
11 from common.base_handler import Permission 12 from common.base_handler import Permission
12 from model import analysis_status 13 from model import analysis_status
14 from model import triage_status
15 from model.base_triaged_model import TriagedModel
13 from waterfall.flake import initialize_flake_pipeline 16 from waterfall.flake import initialize_flake_pipeline
14 17
15 18
19 def _GetSuspectedFlakeAnalysisAndTriageResult(analysis):
20 if analysis.suspected_flake_build_number is not None:
21 return {
22 'build_number': analysis.suspected_flake_build_number,
23 'triage_result': (
24 analysis.triage_history[-1].triage_result if analysis.triage_history
25 else triage_status.UNTRIAGED)
26 }
27
28 return {}
29
30
16 class CheckFlake(BaseHandler): 31 class CheckFlake(BaseHandler):
17 PERMISSION_LEVEL = Permission.ANYONE 32 PERMISSION_LEVEL = Permission.ANYONE
18 33
19 def HandleGet(self): 34 def HandleGet(self):
20 master_name = self.request.get('master_name').strip() 35 master_name = self.request.get('master_name').strip()
21 builder_name = self.request.get('builder_name').strip() 36 builder_name = self.request.get('builder_name').strip()
22 build_number = int(self.request.get('build_number', '0').strip()) 37 build_number = int(self.request.get('build_number', '0').strip())
23 step_name = self.request.get('step_name').strip() 38 step_name = self.request.get('step_name').strip()
24 test_name = self.request.get('test_name').strip() 39 test_name = self.request.get('test_name').strip()
25 40
(...skipping 16 matching lines...) Expand all
42 'template': 'error.html', 57 'template': 'error.html',
43 'data': { 58 'data': {
44 'error_message': 59 'error_message':
45 ('You could schedule an analysis for flaky test only after ' 60 ('You could schedule an analysis for flaky test only after '
46 'you login with google.com account.'), 61 'you login with google.com account.'),
47 'login_url': self.GetLoginUrl(), 62 'login_url': self.GetLoginUrl(),
48 }, 63 },
49 'return_code': 401, 64 'return_code': 401,
50 } 65 }
51 66
67 suspected_flake = _GetSuspectedFlakeAnalysisAndTriageResult(analysis)
68
52 data = { 69 data = {
53 'pass_rates': [], 70 'pass_rates': [],
54 'analysis_status': analysis.status_description, 71 'analysis_status': analysis.status_description,
55 'suspected_flake_build_number': (
56 analysis.suspected_flake_build_number),
57 'master_name': master_name, 72 'master_name': master_name,
58 'builder_name': builder_name, 73 'builder_name': builder_name,
59 'build_number': build_number, 74 'build_number': build_number,
60 'step_name': step_name, 75 'step_name': step_name,
61 'test_name': test_name, 76 'test_name': test_name,
77 'version_number': analysis.version_number,
78 'suspected_flake': suspected_flake,
79 'triage_history': TriagedModel.GetTriageHistory(analysis),
62 'request_time': time_util.FormatDatetime( 80 'request_time': time_util.FormatDatetime(
63 analysis.request_time), 81 analysis.request_time),
64 'task_number': len(analysis.data_points), 82 'task_number': len(analysis.data_points),
65 'error': analysis.error_message, 83 'error': analysis.error_message,
66 'iterations_to_rerun': analysis.iterations_to_rerun, 84 'iterations_to_rerun': analysis.iterations_to_rerun,
85 'show_debug_info': self._ShowDebugInfo()
67 } 86 }
68 87
69 data['pending_time'] = time_util.FormatDuration( 88 data['pending_time'] = time_util.FormatDuration(
70 analysis.request_time, 89 analysis.request_time,
71 analysis.start_time or time_util.GetUTCNow()) 90 analysis.start_time or time_util.GetUTCNow())
72 if analysis.status != analysis_status.PENDING: 91 if analysis.status != analysis_status.PENDING:
73 data['duration'] = time_util.FormatDuration( 92 data['duration'] = time_util.FormatDuration(
74 analysis.start_time, 93 analysis.start_time,
75 analysis.end_time or time_util.GetUTCNow()) 94 analysis.end_time or time_util.GetUTCNow())
76 95
77 coordinates = [] 96 coordinates = []
78 for data_point in analysis.data_points: 97 for data_point in analysis.data_points:
79 coordinates.append([data_point.build_number, data_point.pass_rate]) 98 coordinates.append([data_point.build_number, data_point.pass_rate])
80 99
81 # Order by build number from earliest to latest. 100 # Order by build number from earliest to latest.
82 coordinates.sort(key=lambda x: x[0]) 101 coordinates.sort(key=lambda x: x[0])
83 102
84 data['pass_rates'] = coordinates 103 data['pass_rates'] = coordinates
85 return { 104 return {
86 'template': 'flake/result.html', 105 'template': 'flake/result.html',
87 'data': data 106 'data': data
88 } 107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698