Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 from datetime import datetime | |
| 6 import logging | |
| 7 | |
| 8 from google.appengine.ext import ndb | |
| 9 | |
| 10 from common import appengine_util | |
| 11 from common import constants | |
| 12 from model.flake.flake_swarming_task import FlakeSwarmingTask | |
| 13 from model.flake.master_flake_analysis import MasterFlakeAnalysis | |
| 14 from model.flake.flake_swarming_task import FlakeSwarmingTask | |
| 15 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline | |
| 16 from model import analysis_status | |
|
chanli
2016/07/08 16:58:54
Move ln 16 before ln 10
stgao
2016/07/09 00:04:33
imports of the same category are usually ordered a
caiw
2016/07/14 00:59:44
Done.
caiw
2016/07/14 00:59:44
Done.
| |
| 17 | |
| 18 | |
| 19 | |
|
chanli
2016/07/08 16:58:54
Only 2 empty lines are needed here.
caiw
2016/07/14 00:59:44
Done.
| |
| 20 @ndb.transactional | |
| 21 # Unused argument - pylint: disable=W0613 | |
| 22 def NeedANewAnalysis( | |
| 23 master_name, builder_name, step_name, build_number): | |
|
chanli
2016/07/08 16:58:53
builder_name is not used in function?
caiw
2016/07/14 00:59:43
Done.
| |
| 24 """Checks status of analysis for the test and decides if a new one is needed. | |
| 25 | |
| 26 A MasterFlakeAnalysis entity for the given build will be created if none | |
|
chanli
2016/07/08 16:58:54
I thought MasterFlakeAnalysis is by (master_name,
caiw
2016/07/14 00:59:44
Done.
| |
| 27 exists. When a new analysis is needed, this function will create and | |
| 28 save a MasterFlakeAnalysis entity to the datastore, or it will | |
| 29 reset the existing one but still keep the result of last analysis. | |
| 30 | |
| 31 Returns: | |
| 32 True if an analysis is needed, otherwise False. | |
| 33 """ | |
| 34 # Where should we put this logic? | |
| 35 # I think this flow has some redundancy with check_flake handler | |
|
stgao
2016/07/09 00:04:33
The logic to determine whether an analysis is need
caiw
2016/07/14 00:59:44
Done.
| |
| 36 | |
| 37 analysis = MasterFlakeAnalysis.Get(master_name, builder_name, step_name) | |
| 38 # If no analysis exists, create it and return True. | |
| 39 # For debugging purposes, we want to create a new one | |
| 40 # as long as it is not completed | |
|
chanli
2016/07/08 16:58:54
It is fine for now that you have this kind of comm
caiw
2016/07/14 00:59:43
Done.
| |
| 41 | |
| 42 if not analysis: | |
| 43 analysis = MasterFlakeAnalysis.Create( | |
| 44 master_name, builder_name, step_name) | |
| 45 analysis.status = analysis_status.PENDING | |
| 46 analysis.put() | |
| 47 return True | |
| 48 elif (analysis.status != analysis_status.COMPLETED): | |
|
chanli
2016/07/08 16:58:54
what if analysis.status == PENDING or RUNNING?
caiw
2016/07/14 00:59:43
Done.
| |
| 49 # If the analysis failed, destroy it and create a new one. | |
| 50 # if analysis.status == analysis_status.ERROR: | |
| 51 MasterFlakeAnalysis.Get(master_name, builder_name, step_name).key.delete() | |
|
chanli
2016/07/08 16:58:54
Alternative: write a Reset function instead.
caiw
2016/07/14 00:59:44
Done.
| |
| 52 analysis = MasterFlakeAnalysis.Create( | |
| 53 master_name, builder_name, step_name) | |
| 54 analysis.status = analysis_status.PENDING | |
| 55 analysis.put() | |
| 56 return True | |
| 57 | |
| 58 # If the analysis finished, return False. | |
| 59 if analysis.status == analysis_status.COMPLETED: | |
|
chanli
2016/07/08 16:58:54
This is actually else after elif above, right?
caiw
2016/07/14 00:59:44
Done.
| |
| 60 return False | |
| 61 | |
| 62 # Unused arguments - pylint: disable=W0612, W0613 | |
| 63 def ScheduleAnalysisIfNeeded(master_name, builder_name, step_name, build_number, | |
| 64 testcase, force=False, | |
| 65 queue_name=constants.DEFAULT_QUEUE): | |
| 66 """Schedules an analysis if needed and returns the MasterFlakeAnalysis. | |
| 67 | |
| 68 When the build failure was already analyzed and a new analysis is scheduled, | |
| 69 the returned WfAnalysis will still have the result of last completed analysis. | |
| 70 | |
| 71 Args: | |
| 72 master_name (str): The master name of the failed test | |
| 73 builder_name (str): The builder name of the failed test | |
| 74 build_number (int): The build number of the failed test | |
| 75 step_name (str): The name of the test suite | |
| 76 | |
| 77 Returns: | |
| 78 A MasterFlakeAnalysis instance. | |
| 79 """ | |
| 80 # Change force to true for testing? | |
| 81 if NeedANewAnalysis( | |
| 82 master_name, builder_name, step_name, build_number): | |
| 83 pipeline_job = RecursiveFlakePipeline( | |
| 84 master_name, builder_name, step_name, build_number, testcase) | |
| 85 pipeline_job.target = appengine_util.GetTargetNameForModule( | |
| 86 constants.WATERFALL_BACKEND) | |
| 87 pipeline_job.start(queue_name=queue_name) | |
| 88 return MasterFlakeAnalysis.Get( | |
| 89 master_name, builder_name, step_name) | |
| OLD | NEW |