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 constants | |
| 5 from common.base_handler import BaseHandler | 8 from common.base_handler import BaseHandler |
| 6 from common.base_handler import Permission | 9 from common.base_handler import Permission |
| 10 from model import analysis_status | |
| 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis | |
| 12 from waterfall.flake.initialize_flake_pipeline import ScheduleAnalysisIfNeeded | |
| 13 | |
| 7 | 14 |
| 8 | 15 |
| 9 class CheckFlake(BaseHandler): | 16 class CheckFlake(BaseHandler): |
| 10 PERMISSION_LEVEL = Permission.CORP_USER | 17 PERMISSION_LEVEL = Permission.CORP_USER |
| 11 | 18 |
| 12 def HandleGet(self): | 19 def HandleGet(self): |
| 13 | 20 |
| 14 # Get input parameters. | 21 # Get input parameters. |
| 15 # pylint: disable=W0612 | 22 # pylint: disable=W0612 |
| 16 master_name = self.request.get('master_name').strip() | 23 master_name = self.request.get('master_name').strip() |
| 17 builder_name = self.request.get('builder_name').strip() | 24 builder_name = self.request.get('builder_name').strip() |
| 18 build_number = int(self.request.get('build_number').strip()) | 25 build_number = int(self.request.get('build_number').strip()) |
| 19 test_target_name = self.request.get('test_target_name').strip() | 26 step_name = self.request.get('test_target_name').strip() |
| 20 testcase = self.request.get('testcase').strip() | 27 testcase = self.request.get('testcase').strip() |
| 21 | 28 |
| 22 # TODO(caiw): Get status of master_analysis from database. | 29 # Get status of master_analysis from database. |
| 30 analysis = MasterFlakeAnalysis.Get(master_name, builder_name, step_name) | |
|
stgao
2016/07/09 00:12:24
Should we use the one returned by ScheduleAnalysis
caiw
2016/07/14 00:59:34
Done.
| |
| 31 force = (users.is_current_user_admin() and | |
| 32 self.request.get('force') == '1') | |
| 33 # Disable for testing - pylint: disable=W0105 | |
| 34 """ | |
| 35 # If there is an existing one, react appropriately | |
| 36 if analysis: | |
| 37 if (analysis.status == analysis_status.COMPLETED or | |
| 38 analysis.status == analysis_status.RUNNING): | |
| 39 return { | |
| 40 'template': 'flake/finished_analysis.html', | |
| 41 'data': analysis.GenerateData(), | |
| 42 } | |
| 43 elif analysis.status == analysis_status.PENDING: | |
| 44 print "wtf\n\n" | |
| 45 return { | |
| 46 'template': 'flake/in_progress.html' | |
| 47 } | |
| 48 elif analysis.status == analysis_status.ERROR: | |
| 49 # If the current master_analysis has an error, | |
| 50 # delete it. | |
| 51 if force: | |
| 52 # Delete analysis (but not yet) | |
| 53 pass | |
| 54 else: | |
| 55 # Return error template | |
| 56 return { | |
| 57 'template': 'flake/error.html', | |
| 58 } | |
| 23 | 59 |
| 24 # TODO(caiw): If there is a completed master_analysis, return | 60 force = (users.is_current_user_admin() and |
| 25 # the template which displays it. | 61 self.request.get('force') == '1') |
| 26 | 62 """ |
| 27 # TODO(caiw): If the current master_analysis has an error, | 63 # Do we need a put() statement? |
| 28 # delete it. | 64 ScheduleAnalysisIfNeeded(master_name, builder_name, step_name, |
| 29 | 65 build_number, testcase, force=force, |
| 30 # TODO(caiw): If there is no master_analysis, create one. | 66 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) |
| 31 | 67 return { |
| 32 # TODO(caiw): Trigger pipeline. | 68 'template': 'flake/in_progress.html' |
| 33 | 69 } |
| 34 # TODO(caiw): Return the appropriate template based on the case. | |
| OLD | NEW |