| OLD | NEW |
| 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 logging |
| 6 |
| 5 from google.appengine.api import users | 7 from google.appengine.api import users |
| 6 from google.appengine.ext import ndb | 8 from google.appengine.ext import ndb |
| 7 | 9 |
| 8 from common import auth_util | 10 from common import auth_util |
| 9 from common.base_handler import BaseHandler | 11 from common.base_handler import BaseHandler |
| 10 from common.base_handler import Permission | 12 from common.base_handler import Permission |
| 11 from lib import time_util | 13 from lib import time_util |
| 12 from model import analysis_status | 14 from model import analysis_status |
| 13 from model import triage_status | 15 from model import triage_status |
| 14 from model.flake.flake_analysis_request import FlakeAnalysisRequest | 16 from model.flake.flake_analysis_request import FlakeAnalysisRequest |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 user_email = auth_util.GetUserEmail() | 96 user_email = auth_util.GetUserEmail() |
| 95 is_admin = auth_util.IsCurrentUserAdmin() | 97 is_admin = auth_util.IsCurrentUserAdmin() |
| 96 | 98 |
| 97 request = FlakeAnalysisRequest.Create(test_name, False, bug_id) | 99 request = FlakeAnalysisRequest.Create(test_name, False, bug_id) |
| 98 request.AddBuildStep(master_name, builder_name, build_number, step_name, | 100 request.AddBuildStep(master_name, builder_name, build_number, step_name, |
| 99 time_util.GetUTCNow()) | 101 time_util.GetUTCNow()) |
| 100 scheduled = flake_analysis_service.ScheduleAnalysisForFlake( | 102 scheduled = flake_analysis_service.ScheduleAnalysisForFlake( |
| 101 request, user_email, is_admin, triggering_sources.FINDIT_UI) | 103 request, user_email, is_admin, triggering_sources.FINDIT_UI) |
| 102 | 104 |
| 103 analysis = MasterFlakeAnalysis.GetVersion( | 105 analysis = MasterFlakeAnalysis.GetVersion( |
| 104 master_name, builder_name, build_number, step_name, test_name) | 106 master_name, builder_name, build_number, step_name, test_name) |
| 105 | 107 |
| 106 if not analysis: | 108 if not analysis: |
| 107 if scheduled is None: | 109 if scheduled is None: |
| 108 # User does not have permission to trigger, nor was any previous | 110 # User does not have permission to trigger, nor was any previous |
| 109 # analysis triggered to view. | 111 # analysis triggered to view. |
| 110 return { | 112 return { |
| 111 'template': 'error.html', | 113 'template': 'error.html', |
| 112 'data': { | 114 'data': { |
| 113 'error_message': | 115 'error_message': |
| 114 ('You could schedule an analysis for flaky test only ' | 116 ('You could schedule an analysis for flaky test only ' |
| 115 'after you login with google.com account.'), | 117 'after you login with google.com account.'), |
| 116 'login_url': self.GetLoginUrl(), | 118 'login_url': self.GetLoginUrl(), |
| 117 }, | 119 }, |
| 118 'return_code': 401, | 120 'return_code': 401, |
| 119 } | 121 } |
| 120 | 122 |
| 121 # Check if a previous request has already covered this analysis so use | 123 # Check if a previous request has already covered this analysis so use |
| 122 # the results from that analysis. | 124 # the results from that analysis. |
| 123 request = FlakeAnalysisRequest.GetVersion(key=test_name) | 125 request = FlakeAnalysisRequest.GetVersion(key=test_name) |
| 124 | 126 |
| 125 if request and request.analyses: | 127 if not request: |
| 126 analysis = request.analyses[-1].get() | |
| 127 else: | |
| 128 return { | 128 return { |
| 129 'template': 'error.html', | 129 'template': 'error.html', |
| 130 'data': { | 130 'data': { |
| 131 'error_message': ( | 131 'error_message': ( |
| 132 'Flake analysis is not supported for this request. Either' | 132 'Flake analysis is not supported for this request. Either' |
| 133 ' the build step may not be supported or the test is not ' | 133 ' the build step may not be supported or the test is not ' |
| 134 'swarmed.'), | 134 'swarmed.'), |
| 135 }, | 135 }, |
| 136 'return_code': 400, | 136 'return_code': 400, |
| 137 } | 137 } |
| 138 | 138 |
| 139 analysis = request.FindMatchingAnalysisForConfiguration( |
| 140 master_name, builder_name) |
| 141 |
| 142 if not analysis: # pragma: no cover |
| 143 logging.error('Flake analysis was deleted unexpectedly!') |
| 144 return { |
| 145 'template': 'error.html', |
| 146 'data': { |
| 147 'error_message': 'Flake analysis was deleted unexpectedly!', |
| 148 }, |
| 149 'return_code': 400 |
| 150 } |
| 151 |
| 139 suspected_flake = _GetSuspectedFlakeAnalysisAndTriageResult(analysis) | 152 suspected_flake = _GetSuspectedFlakeAnalysisAndTriageResult(analysis) |
| 140 | 153 |
| 141 data = { | 154 data = { |
| 142 'master_name': analysis.master_name, | 155 'master_name': analysis.master_name, |
| 143 'builder_name': analysis.builder_name, | 156 'builder_name': analysis.builder_name, |
| 144 'build_number': analysis.build_number, | 157 'build_number': analysis.build_number, |
| 145 'step_name': analysis.step_name, | 158 'step_name': analysis.step_name, |
| 146 'test_name': analysis.test_name, | 159 'test_name': analysis.test_name, |
| 147 'pass_rates': [], | 160 'pass_rates': [], |
| 148 'analysis_status': analysis.status_description, | 161 'analysis_status': analysis.status_description, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 coordinates.append([data_point.build_number, data_point.pass_rate]) | 186 coordinates.append([data_point.build_number, data_point.pass_rate]) |
| 174 | 187 |
| 175 # Order by build number from earliest to latest. | 188 # Order by build number from earliest to latest. |
| 176 coordinates.sort(key=lambda x: x[0]) | 189 coordinates.sort(key=lambda x: x[0]) |
| 177 | 190 |
| 178 data['pass_rates'] = coordinates | 191 data['pass_rates'] = coordinates |
| 179 return { | 192 return { |
| 180 'template': 'flake/result.html', | 193 'template': 'flake/result.html', |
| 181 'data': data | 194 'data': data |
| 182 } | 195 } |
| OLD | NEW |