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 datetime import datetime | 5 from datetime import datetime |
|
chanli
2016/08/11 23:59:39
datetime should be in a separate group
caiw
2016/08/13 00:09:15
Done.
| |
| 6 | |
| 7 from common import appengine_util | 6 from common import appengine_util |
| 8 from common import constants | 7 from common import constants |
| 9 from common.pipeline_wrapper import BasePipeline | 8 from common.pipeline_wrapper import BasePipeline |
| 10 | 9 |
| 11 from model import analysis_status | 10 from model import analysis_status |
| 12 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 12 from model.flake.flake_swarming_task import FlakeSwarmingTask | |
| 13 from waterfall.trigger_flake_swarming_task_pipeline import ( | 13 from waterfall.trigger_flake_swarming_task_pipeline import ( |
| 14 TriggerFlakeSwarmingTaskPipeline) | 14 TriggerFlakeSwarmingTaskPipeline) |
| 15 from waterfall.process_flake_swarming_task_result_pipeline import ( | 15 from waterfall.process_flake_swarming_task_result_pipeline import ( |
| 16 ProcessFlakeSwarmingTaskResultPipeline) | 16 ProcessFlakeSwarmingTaskResultPipeline) |
| 17 | 17 |
| 18 | 18 |
| 19 class RecursiveFlakePipeline(BasePipeline): | 19 class RecursiveFlakePipeline(BasePipeline): |
| 20 | 20 |
| 21 # Arguments number differs from overridden method - pylint: disable=W0221 | 21 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 22 def run(self, master_name, builder_name, run_build_number, step_name, | 22 def run(self, master_name, builder_name, run_build_number, step_name, |
| 23 test_name, master_build_number, queue_name=constants.DEFAULT_QUEUE): | 23 test_name, master_build_number, algo_dict, |
| 24 queue_name=constants.DEFAULT_QUEUE): | |
|
chanli
2016/08/11 23:59:39
Could you add a docstring to explain the args? For
caiw
2016/08/13 00:09:15
Done.
| |
| 24 # Call trigger pipeline (flake style). | 25 # Call trigger pipeline (flake style). |
| 25 task_id = yield TriggerFlakeSwarmingTaskPipeline(master_name, builder_name, | 26 task_id = yield TriggerFlakeSwarmingTaskPipeline( |
| 26 run_build_number, step_name, [test_name]) | 27 master_name, builder_name, run_build_number, step_name, [test_name]) |
| 27 # Pass the trigger pipeline into a process pipeline. | 28 # Pass the trigger pipeline into a process pipeline. |
| 28 test_result_future = yield ProcessFlakeSwarmingTaskResultPipeline( | 29 test_result_future = yield ProcessFlakeSwarmingTaskResultPipeline( |
| 29 master_name, builder_name, run_build_number, | 30 master_name, builder_name, run_build_number, |
| 30 step_name, task_id, master_build_number, test_name) | 31 step_name, task_id, master_build_number, test_name) |
| 31 yield NextBuildNumberPipeline( | 32 yield NextBuildNumberPipeline( |
| 32 master_name, builder_name, master_build_number, | 33 master_name, builder_name, master_build_number, run_build_number, |
| 33 step_name, test_name, test_result_future, queue_name) | 34 step_name, test_name, test_result_future, queue_name, algo_dict) |
| 35 | |
| 34 | 36 |
| 35 class NextBuildNumberPipeline(BasePipeline): | 37 class NextBuildNumberPipeline(BasePipeline): |
| 38 | |
| 36 # Arguments number differs from overridden method - pylint: disable=W0221 | 39 # Arguments number differs from overridden method - pylint: disable=W0221 |
| 37 # Unused argument - pylint: disable=W0613 | 40 # Unused argument - pylint: disable=W0613 |
| 38 def run(self, master_name, builder_name, master_build_number, step_name, | 41 def run(self, master_name, builder_name, master_build_number, |
| 39 test_name, test_result_future, queue_name): | 42 run_build_number, step_name, test_name, test_result_future, |
| 43 queue_name, algo_dict): | |
| 44 | |
| 40 # Get MasterFlakeAnalysis success list corresponding to parameters. | 45 # Get MasterFlakeAnalysis success list corresponding to parameters. |
| 41 master = MasterFlakeAnalysis.Get(master_name, builder_name, | 46 master = MasterFlakeAnalysis.Get(master_name, builder_name, |
| 42 master_build_number, step_name, test_name) | 47 master_build_number, step_name, test_name) |
| 48 | |
| 49 # Don't call another pipeline if we fail. | |
| 50 flake_swarming_task = FlakeSwarmingTask.Get( | |
| 51 master_name, builder_name, run_build_number, step_name, test_name) | |
| 52 if flake_swarming_task.status == analysis_status.ERROR: | |
| 53 return | |
| 54 | |
| 43 # Figure out what build_number we should call, if any | 55 # Figure out what build_number we should call, if any |
| 44 # This is a placeholder for testing: | 56 # This is a placeholder for testing: |
| 45 next_run = False | 57 |
| 46 if len(master.build_numbers) < 10: | 58 # Get the last result. |
| 47 # TODO(caiw): Develop algorithm to optimize this. | 59 last_result = master.success_rates[-1] |
| 48 next_run = min(master.build_numbers) - 10 | 60 if last_result < .02 or last_result > .98: |
|
lijeffrey
2016/08/11 22:22:25
move all these values to constants at the top of t
caiw
2016/08/13 00:09:15
Done.
| |
| 61 algo_dict['stable_in_a_row'] += 1 | |
| 62 if algo_dict['stable_in_a_row'] > 4: | |
| 63 algo_dict['stabled_out'] = True | |
| 64 algo_dict['flakes_in_a_row'] = 0 | |
| 65 step_size = algo_dict['stable_in_a_row'] + 1 | |
| 66 else: | |
| 67 algo_dict['flakes_in_a_row'] += 1 | |
| 68 if algo_dict['flakes_in_a_row'] > 4: | |
| 69 algo_dict['flaked_out'] = True | |
| 70 algo_dict['stable_in_a_row'] = 0 | |
| 71 step_size = algo_dict['flakes_in_a_row'] + 1 | |
| 72 next_run = min(master.build_numbers) - step_size | |
| 73 | |
| 74 if (next_run < algo_dict['last_build_number'] or | |
| 75 (algo_dict['stabled_out'] and algo_dict['flaked_out'])): | |
| 76 next_run = False | |
|
chanli
2016/08/11 23:59:39
Maybe set next_run to 0 or -1 instead of False?
caiw
2016/08/13 00:09:15
Done.
| |
| 77 | |
| 49 if next_run: | 78 if next_run: |
| 79 new_algo_dict = { | |
|
lijeffrey
2016/08/11 22:22:25
it looks like this is a direct copy. You can do ne
caiw
2016/08/13 00:09:15
Done.
| |
| 80 'flakes_in_a_row': algo_dict['flakes_in_a_row'], | |
| 81 'stable_in_a_row': algo_dict['stable_in_a_row'], | |
| 82 'stabled_out': algo_dict['stabled_out'], | |
| 83 'flaked_out': algo_dict['flaked_out'], | |
| 84 'last_build_number': algo_dict['last_build_number'] | |
| 85 } | |
| 50 pipeline_job = RecursiveFlakePipeline( | 86 pipeline_job = RecursiveFlakePipeline( |
| 51 master_name, builder_name, next_run, step_name, test_name, | 87 master_name, builder_name, next_run, step_name, test_name, |
| 52 master_build_number) | 88 master_build_number, algo_dict=new_algo_dict) |
| 53 #pylint: disable=W0201 | 89 # pylint: disable=W0201 |
| 54 pipeline_job.target = appengine_util.GetTargetNameForModule( | 90 pipeline_job.target = appengine_util.GetTargetNameForModule( |
| 55 constants.WATERFALL_BACKEND) | 91 constants.WATERFALL_BACKEND) |
| 56 pipeline_job.start(queue_name=queue_name) | 92 pipeline_job.start(queue_name=queue_name) |
| OLD | NEW |