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