Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: appengine/findit/waterfall/flake/recursive_flake_pipeline.py

Issue 2243673002: [Findit] Added algorithm to analysis (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 import copy
5 from datetime import datetime 6 from datetime import datetime
6 7
7 from common import appengine_util 8 from common import appengine_util
8 from common import constants 9 from common import constants
9 from common.pipeline_wrapper import BasePipeline 10 from common.pipeline_wrapper import BasePipeline
10 11
11 from model import analysis_status 12 from model import analysis_status
12 from model.flake.master_flake_analysis import MasterFlakeAnalysis 13 from model.flake.master_flake_analysis import MasterFlakeAnalysis
14 from model.flake.flake_swarming_task import FlakeSwarmingTask
13 from waterfall.trigger_flake_swarming_task_pipeline import ( 15 from waterfall.trigger_flake_swarming_task_pipeline import (
14 TriggerFlakeSwarmingTaskPipeline) 16 TriggerFlakeSwarmingTaskPipeline)
15 from waterfall.process_flake_swarming_task_result_pipeline import ( 17 from waterfall.process_flake_swarming_task_result_pipeline import (
16 ProcessFlakeSwarmingTaskResultPipeline) 18 ProcessFlakeSwarmingTaskResultPipeline)
17 19
20 # TODO(lijeffrey): Move to config.
21 LOWER_FLAKE_THRESHOLD = .02
22 UPPER_FLAKE_THRESHOLD = .98
23 MAX_FLAKE_IN_A_ROW = 4
24 MAX_STABLE_IN_A_ROW = 4
25
18 26
19 class RecursiveFlakePipeline(BasePipeline): 27 class RecursiveFlakePipeline(BasePipeline):
20 28
21 # Arguments number differs from overridden method - pylint: disable=W0221 29 # Arguments number differs from overridden method - pylint: disable=W0221
22 def run(self, master_name, builder_name, run_build_number, step_name, 30 def run(self, master_name, builder_name, run_build_number, step_name,
23 test_name, master_build_number, queue_name=constants.DEFAULT_QUEUE): 31 test_name, master_build_number, algo_dict,
32 queue_name=constants.DEFAULT_QUEUE):
33 """
34 Args:
35 master_name (str): The master name.
36 builder_name (str): The builder name.
37 run_build_number (int): The build number of the current swarming rerun.
38 step_name (str): The step name.
39 test_name (str): The test name.
40 master_build_number (int): The build number of the Master_Flake_analysis.
41 algo_dict (dict): A dictionary used by NextBuildNumberPipeline
42 queue_name (str): Which queue to run on.
43 Returns:
44 A dict of lists for reliable/flaky tests.
45 """
46
24 # Call trigger pipeline (flake style). 47 # Call trigger pipeline (flake style).
25 task_id = yield TriggerFlakeSwarmingTaskPipeline(master_name, builder_name, 48 task_id = yield TriggerFlakeSwarmingTaskPipeline(
26 run_build_number, step_name, [test_name]) 49 master_name, builder_name, run_build_number, step_name, [test_name])
27 # Pass the trigger pipeline into a process pipeline. 50 # Pass the trigger pipeline into a process pipeline.
28 test_result_future = yield ProcessFlakeSwarmingTaskResultPipeline( 51 test_result_future = yield ProcessFlakeSwarmingTaskResultPipeline(
29 master_name, builder_name, run_build_number, 52 master_name, builder_name, run_build_number,
30 step_name, task_id, master_build_number, test_name) 53 step_name, task_id, master_build_number, test_name)
31 yield NextBuildNumberPipeline( 54 yield NextBuildNumberPipeline(
32 master_name, builder_name, master_build_number, 55 master_name, builder_name, master_build_number, run_build_number,
33 step_name, test_name, test_result_future, queue_name) 56 step_name, test_name, test_result_future, queue_name, algo_dict)
57
34 58
35 class NextBuildNumberPipeline(BasePipeline): 59 class NextBuildNumberPipeline(BasePipeline):
60
36 # Arguments number differs from overridden method - pylint: disable=W0221 61 # Arguments number differs from overridden method - pylint: disable=W0221
37 # Unused argument - pylint: disable=W0613 62 # Unused argument - pylint: disable=W0613
38 def run(self, master_name, builder_name, master_build_number, step_name, 63 def run(self, master_name, builder_name, master_build_number,
39 test_name, test_result_future, queue_name): 64 run_build_number, step_name, test_name, test_result_future,
65 queue_name, algo_dict):
66
40 # Get MasterFlakeAnalysis success list corresponding to parameters. 67 # Get MasterFlakeAnalysis success list corresponding to parameters.
41 master = MasterFlakeAnalysis.Get(master_name, builder_name, 68 master = MasterFlakeAnalysis.Get(master_name, builder_name,
42 master_build_number, step_name, test_name) 69 master_build_number, step_name, test_name)
70
71 # Don't call another pipeline if we fail.
72 flake_swarming_task = FlakeSwarmingTask.Get(
lijeffrey 2016/08/15 04:14:07 nit: it looks like this can be moved to before get
caiw 2016/08/17 08:36:18 Done.
73 master_name, builder_name, run_build_number, step_name, test_name)
74 if flake_swarming_task.status == analysis_status.ERROR:
75 return
76
43 # Figure out what build_number we should call, if any 77 # Figure out what build_number we should call, if any
44 # This is a placeholder for testing: 78 # This is a placeholder for testing:
45 next_run = False 79
46 if len(master.build_numbers) < 10: 80 # Get the last result.
47 # TODO(caiw): Develop algorithm to optimize this. 81 last_result = master.success_rates[-1]
lijeffrey 2016/08/15 04:14:08 I would move this stuff into a new function that r
caiw 2016/08/17 08:36:18 Done.
48 next_run = min(master.build_numbers) - 10 82 if (last_result < LOWER_FLAKE_THRESHOLD or
83 last_result > UPPER_FLAKE_THRESHOLD):
84 algo_dict['stable_in_a_row'] += 1
lijeffrey 2016/08/15 04:14:07 just an idea but it looks like algo_dict can be im
caiw 2016/08/17 08:36:18 Acknowledged.
85 if algo_dict['stable_in_a_row'] > MAX_STABLE_IN_A_ROW:
86 algo_dict['stabled_out'] = True
87 algo_dict['flakes_in_a_row'] = 0
88 step_size = algo_dict['stable_in_a_row'] + 1
89 else:
90 algo_dict['flakes_in_a_row'] += 1
91 if algo_dict['flakes_in_a_row'] > MAX_FLAKE_IN_A_ROW:
92 algo_dict['flaked_out'] = True
93 algo_dict['stable_in_a_row'] = 0
94 step_size = algo_dict['flakes_in_a_row'] + 1
95 next_run = min(master.build_numbers) - step_size
chanli 2016/08/15 23:01:05 Just a thought: Say after 10 flakes in a row, we s
caiw 2016/08/17 08:36:18 Yes Shuotao and I talked about this today. I will
96
97 if (next_run < algo_dict['last_build_number'] or
98 (algo_dict['stabled_out'] and algo_dict['flaked_out'])):
99 next_run = 0
100
49 if next_run: 101 if next_run:
102 new_algo_dict = copy.deepcopy(algo_dict)
50 pipeline_job = RecursiveFlakePipeline( 103 pipeline_job = RecursiveFlakePipeline(
51 master_name, builder_name, next_run, step_name, test_name, 104 master_name, builder_name, next_run, step_name, test_name,
52 master_build_number) 105 master_build_number, algo_dict=new_algo_dict)
53 #pylint: disable=W0201 106 # pylint: disable=W0201
54 pipeline_job.target = appengine_util.GetTargetNameForModule( 107 pipeline_job.target = appengine_util.GetTargetNameForModule(
55 constants.WATERFALL_BACKEND) 108 constants.WATERFALL_BACKEND)
56 pipeline_job.start(queue_name=queue_name) 109 pipeline_job.start(queue_name=queue_name)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698