Chromium Code Reviews| 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 | |
| 6 | |
| 7 from common import auth_util | 5 from common import auth_util |
| 8 from common import constants | 6 from common import constants |
| 9 from common import time_util | 7 from common import time_util |
| 10 from common.base_handler import BaseHandler | 8 from common.base_handler import BaseHandler |
| 11 from common.base_handler import Permission | 9 from common.base_handler import Permission |
| 12 from model import analysis_status | 10 from model import analysis_status |
| 13 from waterfall.flake import initialize_flake_pipeline | 11 from waterfall.flake import initialize_flake_pipeline |
| 12 from waterfall.flake import triggering_sources | |
| 14 | 13 |
| 15 | 14 |
| 16 class CheckFlake(BaseHandler): | 15 class CheckFlake(BaseHandler): |
| 17 PERMISSION_LEVEL = Permission.ANYONE | 16 PERMISSION_LEVEL = Permission.ANYONE |
| 18 | 17 |
| 19 def HandleGet(self): | 18 def HandleGet(self): |
| 20 master_name = self.request.get('master_name').strip() | 19 master_name = self.request.get('master_name').strip() |
| 21 builder_name = self.request.get('builder_name').strip() | 20 builder_name = self.request.get('builder_name').strip() |
| 22 build_number = int(self.request.get('build_number', '0').strip()) | 21 build_number = int(self.request.get('build_number', '0').strip()) |
| 23 step_name = self.request.get('step_name').strip() | 22 step_name = self.request.get('step_name').strip() |
| 24 test_name = self.request.get('test_name').strip() | 23 test_name = self.request.get('test_name').strip() |
| 25 | 24 |
| 26 if not (master_name and builder_name and build_number and | 25 if not (master_name and builder_name and build_number and |
| 27 step_name and test_name): # pragma: no cover. | 26 step_name and test_name): # pragma: no cover. |
| 28 return self.CreateError( | 27 return self.CreateError( |
| 29 'Invalid value of master/builder/build_number/step/test', 400) | 28 'Invalid value of master/builder/build_number/step/test', 400) |
| 30 | 29 |
| 31 force = (auth_util.IsCurrentUserAdmin() and | 30 force = (auth_util.IsCurrentUserAdmin() and |
| 32 self.request.get('force') == '1') | 31 self.request.get('force') == '1') |
| 33 allow_new_analysis = self.IsCorpUserOrAdmin() | 32 allow_new_analysis = self.IsCorpUserOrAdmin() |
| 34 | 33 |
| 34 # TODO(lijeffrey): Use flake_analysis_service.ScheduleAnalysisForFlake. | |
| 35 user_email = auth_util.GetUserEmail() | |
| 35 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( | 36 analysis = initialize_flake_pipeline.ScheduleAnalysisIfNeeded( |
| 36 master_name, builder_name, build_number, step_name, test_name, | 37 master_name, builder_name, build_number, step_name, test_name, |
| 37 allow_new_analysis, force=force, manually_triggered=True, | 38 allow_new_analysis, force=force, user_email=user_email, |
| 39 triggering_source=triggering_sources.FINDIT, | |
|
stgao
2016/10/13 06:14:38
Should we do FINDIT_UI?
lijeffrey
2016/10/14 23:45:21
Done.
| |
| 38 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) | 40 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) |
| 39 | 41 |
| 40 if not analysis: # pragma: no cover. | 42 if not analysis: # pragma: no cover. |
| 41 return { | 43 return { |
| 42 'template': 'error.html', | 44 'template': 'error.html', |
| 43 'data': { | 45 'data': { |
| 44 'error_message': | 46 'error_message': |
| 45 ('You could schedule an analysis for flaky test only after ' | 47 ('You could schedule an analysis for flaky test only after ' |
| 46 'you login with google.com account.'), | 48 'you login with google.com account.'), |
| 47 'login_url': self.GetLoginUrl(), | 49 'login_url': self.GetLoginUrl(), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 coordinates.append([data_point.build_number, data_point.pass_rate]) | 81 coordinates.append([data_point.build_number, data_point.pass_rate]) |
| 80 | 82 |
| 81 # Order by build number from earliest to latest. | 83 # Order by build number from earliest to latest. |
| 82 coordinates.sort(key=lambda x: x[0]) | 84 coordinates.sort(key=lambda x: x[0]) |
| 83 | 85 |
| 84 data['pass_rates'] = coordinates | 86 data['pass_rates'] = coordinates |
| 85 return { | 87 return { |
| 86 'template': 'flake/result.html', | 88 'template': 'flake/result.html', |
| 87 'data': data | 89 'data': data |
| 88 } | 90 } |
| OLD | NEW |