| 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 | |
| 6 | |
| 7 from google.appengine.ext import ndb | 5 from google.appengine.ext import ndb |
| 8 | 6 |
| 9 from common import appengine_util | 7 from common import appengine_util |
| 10 from common import constants | 8 from common import constants |
| 11 from model import analysis_status | 9 from model import analysis_status |
| 12 from model.flake.master_flake_analysis import MasterFlakeAnalysis | 10 from model.flake.master_flake_analysis import MasterFlakeAnalysis |
| 11 from waterfall import waterfall_config |
| 13 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline | 12 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline |
| 14 | 13 |
| 15 # TODO(lijeffrey): Move to config. | |
| 16 MAX_BUILD_NUMBERS_TO_LOOK_BACK = 1000 | |
| 17 | |
| 18 | 14 |
| 19 @ndb.transactional | 15 @ndb.transactional |
| 20 def NeedANewAnalysis( | 16 def NeedANewAnalysis( |
| 21 master_name, builder_name, build_number, step_name, test_name): | 17 master_name, builder_name, build_number, step_name, test_name): |
| 22 """Checks status of analysis for the test and decides if a new one is needed. | 18 """Checks status of analysis for the test and decides if a new one is needed. |
| 23 | 19 |
| 24 A MasterFlakeAnalysis entity for the given parameters will be created if none | 20 A MasterFlakeAnalysis entity for the given parameters will be created if none |
| 25 exists. When a new analysis is needed, this function will create and | 21 exists. When a new analysis is needed, this function will create and |
| 26 save a MasterFlakeAnalysis entity to the datastore. | 22 save a MasterFlakeAnalysis entity to the datastore. |
| 27 | 23 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 builder_name (str): The builder name of the failed test | 63 builder_name (str): The builder name of the failed test |
| 68 build_number (int): The build number of the failed test | 64 build_number (int): The build number of the failed test |
| 69 step_name (str): The name of the test suite | 65 step_name (str): The name of the test suite |
| 70 test_name (str): The single test we are checking | 66 test_name (str): The single test we are checking |
| 71 | 67 |
| 72 Returns: | 68 Returns: |
| 73 A MasterFlakeAnalysis instance. | 69 A MasterFlakeAnalysis instance. |
| 74 """ | 70 """ |
| 75 if NeedANewAnalysis( | 71 if NeedANewAnalysis( |
| 76 master_name, builder_name, build_number, step_name, test_name): | 72 master_name, builder_name, build_number, step_name, test_name): |
| 73 check_flake_settings = waterfall_config.GetCheckFlakeSettings() |
| 74 max_build_numbers_to_look_back = check_flake_settings.get( |
| 75 'max_build_numbers_to_look_back') |
| 77 flakiness_algorithm_results_dict = { | 76 flakiness_algorithm_results_dict = { |
| 78 'flakes_in_a_row': 0, | 77 'flakes_in_a_row': 0, |
| 79 'stable_in_a_row': 0, | 78 'stable_in_a_row': 0, |
| 80 'stabled_out': False, | 79 'stabled_out': False, |
| 81 'flaked_out': False, | 80 'flaked_out': False, |
| 82 'last_build_number': max( | 81 'last_build_number': max( |
| 83 0, build_number - MAX_BUILD_NUMBERS_TO_LOOK_BACK), | 82 0, build_number - max_build_numbers_to_look_back), |
| 84 'lower_boundary': None, | 83 'lower_boundary': None, |
| 85 'upper_boundary': None, | 84 'upper_boundary': None, |
| 86 'lower_boundary_result': None, | 85 'lower_boundary_result': None, |
| 87 'sequential_run_index': 0 | 86 'sequential_run_index': 0 |
| 88 } | 87 } |
| 89 pipeline_job = RecursiveFlakePipeline( | 88 pipeline_job = RecursiveFlakePipeline( |
| 90 master_name, builder_name, build_number, step_name, test_name, | 89 master_name, builder_name, build_number, step_name, test_name, |
| 91 master_build_number=build_number, | 90 master_build_number=build_number, |
| 92 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict) | 91 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict) |
| 93 pipeline_job.target = appengine_util.GetTargetNameForModule( | 92 pipeline_job.target = appengine_util.GetTargetNameForModule( |
| 94 constants.WATERFALL_BACKEND) | 93 constants.WATERFALL_BACKEND) |
| 95 pipeline_job.start(queue_name=queue_name) | 94 pipeline_job.start(queue_name=queue_name) |
| 96 return MasterFlakeAnalysis.Get( | 95 return MasterFlakeAnalysis.Get( |
| 97 master_name, builder_name, build_number, step_name, test_name) | 96 master_name, builder_name, build_number, step_name, test_name) |
| OLD | NEW |