| Index: appengine/findit/waterfall/flake/recursive_flake_pipeline.py
|
| diff --git a/appengine/findit/waterfall/flake/recursive_flake_pipeline.py b/appengine/findit/waterfall/flake/recursive_flake_pipeline.py
|
| index 4b1e0efa45d8f7963ca97d3ab60f5f20b76d4129..1619d647cf82c8a9e00bcbda23afa5b4fdd83d54 100644
|
| --- a/appengine/findit/waterfall/flake/recursive_flake_pipeline.py
|
| +++ b/appengine/findit/waterfall/flake/recursive_flake_pipeline.py
|
| @@ -5,6 +5,7 @@
|
| from common import appengine_util
|
| from common import constants
|
| from common.pipeline_wrapper import BasePipeline
|
| +from common import time_util
|
|
|
| from model import analysis_status
|
| from model.flake.flake_swarming_task import FlakeSwarmingTask
|
| @@ -15,6 +16,14 @@ from waterfall.process_flake_swarming_task_result_pipeline import (
|
| from waterfall.trigger_flake_swarming_task_pipeline import (
|
| TriggerFlakeSwarmingTaskPipeline)
|
|
|
| +def _UpdateAnalysisStatusUponCompletion(master_flake_analysis, status, error):
|
| + master_flake_analysis.completed_time = time_util.GetUTCNow()
|
| + master_flake_analysis.status = status
|
| +
|
| + if error:
|
| + master_flake_analysis.error = error
|
| +
|
| + master_flake_analysis.put()
|
|
|
| class RecursiveFlakePipeline(BasePipeline):
|
|
|
| @@ -38,11 +47,12 @@ class RecursiveFlakePipeline(BasePipeline):
|
| Returns:
|
| A dict of lists for reliable/flaky tests.
|
| """
|
| - master = MasterFlakeAnalysis.Get(master_name, builder_name,
|
| - master_build_number, step_name, test_name)
|
| - if master.status != analysis_status.RUNNING: # pragma: no branch
|
| - master.status = analysis_status.RUNNING
|
| - master.put()
|
| + master_flake_analysis = MasterFlakeAnalysis.Get(
|
| + master_name, builder_name, master_build_number, step_name, test_name)
|
| + if (master_flake_analysis.status !=
|
| + analysis_status.RUNNING): # pragma: no branch
|
| + master_flake_analysis.status = analysis_status.RUNNING
|
| + master_flake_analysis.put()
|
|
|
| # Call trigger pipeline (flake style).
|
| task_id = yield TriggerFlakeSwarmingTaskPipeline(
|
| @@ -57,12 +67,12 @@ class RecursiveFlakePipeline(BasePipeline):
|
| flakiness_algorithm_results_dict)
|
|
|
|
|
| -def get_next_run(master, flakiness_algorithm_results_dict):
|
| +def get_next_run(master_flake_analysis, flakiness_algorithm_results_dict):
|
| # A description of this algorithm can be found at:
|
| # https://docs.google.com/document/d/1wPYFZ5OT998Yn7O8wGDOhgfcQ98mknoX13AesJaS6ig/edit
|
| # Get the last result.
|
| - last_result = master.success_rates[-1]
|
| - cur_run = min(master.build_numbers)
|
| + last_result = master_flake_analysis.pass_rates[-1]
|
| + cur_run = min(master_flake_analysis.build_numbers)
|
| flake_settings = waterfall_config.GetCheckFlakeSettings()
|
| lower_flake_threshold = flake_settings.get('lower_flake_threshold')
|
| upper_flake_threshold = flake_settings.get('upper_flake_threshold')
|
| @@ -75,7 +85,7 @@ def get_next_run(master, flakiness_algorithm_results_dict):
|
| flakiness_algorithm_results_dict['flaked_out'] = True
|
| flakiness_algorithm_results_dict['lower_boundary_result'] = 'STABLE'
|
|
|
| - lower_boundary = master.build_numbers[
|
| + lower_boundary = master_flake_analysis.build_numbers[
|
| -flakiness_algorithm_results_dict['stable_in_a_row']]
|
|
|
| flakiness_algorithm_results_dict['lower_boundary'] = lower_boundary
|
| @@ -127,8 +137,9 @@ def get_next_run(master, flakiness_algorithm_results_dict):
|
| return cur_run - step_size
|
|
|
|
|
| -def sequential_next_run(master, flakiness_algorithm_results_dict):
|
| - last_result = master.success_rates[-1]
|
| +def sequential_next_run(
|
| + master_flake_analysis, flakiness_algorithm_results_dict):
|
| + last_result = master_flake_analysis.pass_rates[-1]
|
| last_result_status = 'FLAKE'
|
| flake_settings = waterfall_config.GetCheckFlakeSettings()
|
| lower_flake_threshold = flake_settings.get('lower_flake_threshold')
|
| @@ -140,10 +151,10 @@ def sequential_next_run(master, flakiness_algorithm_results_dict):
|
| if flakiness_algorithm_results_dict['sequential_run_index'] > 0:
|
| if (last_result_status !=
|
| flakiness_algorithm_results_dict['lower_boundary_result']):
|
| - master.suspected_flake_build_number = (
|
| + master_flake_analysis.suspected_flake_build_number = (
|
| flakiness_algorithm_results_dict['lower_boundary'] +
|
| flakiness_algorithm_results_dict['sequential_run_index'])
|
| - master.put()
|
| + master_flake_analysis.put()
|
| return 0
|
| flakiness_algorithm_results_dict['sequential_run_index'] += 1
|
| return (flakiness_algorithm_results_dict['lower_boundary'] +
|
| @@ -159,23 +170,31 @@ class NextBuildNumberPipeline(BasePipeline):
|
| queue_name, flakiness_algorithm_results_dict):
|
|
|
| # Get MasterFlakeAnalysis success list corresponding to parameters.
|
| - master = MasterFlakeAnalysis.Get(master_name, builder_name,
|
| - master_build_number, step_name, test_name)
|
| + master_flake_analysis = MasterFlakeAnalysis.Get(
|
| + master_name, builder_name, master_build_number, step_name, test_name)
|
| # Don't call another pipeline if we fail.
|
| flake_swarming_task = FlakeSwarmingTask.Get(
|
| master_name, builder_name, run_build_number, step_name, test_name)
|
|
|
| if flake_swarming_task.status == analysis_status.ERROR:
|
| - master.status = analysis_status.ERROR
|
| - master.put()
|
| + # TODO (lijeffrey): Implement more detailed error detection and reporting,
|
| + # such as timeouts, dead bots, etc.
|
| + error = {
|
| + 'error': 'An error occurred',
|
| + 'message': 'Unknown'
|
| + }
|
| + _UpdateAnalysisStatusUponCompletion(
|
| + master_flake_analysis, analysis_status.ERROR, error)
|
| return
|
|
|
| # Figure out what build_number we should call, if any
|
| if (flakiness_algorithm_results_dict['stabled_out'] and
|
| flakiness_algorithm_results_dict['flaked_out']):
|
| - next_run = sequential_next_run(master, flakiness_algorithm_results_dict)
|
| + next_run = sequential_next_run(
|
| + master_flake_analysis, flakiness_algorithm_results_dict)
|
| else:
|
| - next_run = get_next_run(master, flakiness_algorithm_results_dict)
|
| + next_run = get_next_run(
|
| + master_flake_analysis, flakiness_algorithm_results_dict)
|
|
|
| if next_run < flakiness_algorithm_results_dict['last_build_number']:
|
| next_run = 0
|
| @@ -192,5 +211,5 @@ class NextBuildNumberPipeline(BasePipeline):
|
| constants.WATERFALL_BACKEND)
|
| pipeline_job.start(queue_name=queue_name)
|
| else:
|
| - master.status = analysis_status.COMPLETED
|
| - master.put()
|
| + _UpdateAnalysisStatusUponCompletion(
|
| + master_flake_analysis, analysis_status.COMPLETED, None)
|
|
|