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

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

Issue 2345093002: [Findit] Extending versioned_model.py to support versioning multiple entities of the same class. (Closed)
Patch Set: Ignore this patch, uploaded unrelated change to wrong branch Created 4 years, 2 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 from google.appengine.ext import ndb 5 from google.appengine.ext import ndb
6 6
7 from common import appengine_util 7 from common import appengine_util
8 from common import constants 8 from common import constants
9 from common import time_util
9 from model import analysis_status 10 from model import analysis_status
10 from model.flake.master_flake_analysis import MasterFlakeAnalysis 11 from model.flake.master_flake_analysis import MasterFlakeAnalysis
11 from waterfall import waterfall_config 12 from waterfall import waterfall_config
12 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline 13 from waterfall.flake.recursive_flake_pipeline import RecursiveFlakePipeline
13 14
14 15
15 @ndb.transactional 16 @ndb.transactional
16 def NeedANewAnalysis( 17 def NeedANewAnalysis(
17 master_name, builder_name, build_number, step_name, test_name, 18 master_name, builder_name, build_number, step_name, test_name,
18 allow_new_analysis=False): 19 allow_new_analysis=False):
19 """Checks status of analysis for the test and decides if a new one is needed. 20 """Checks status of analysis for the test and decides if a new one is needed.
20 21
21 A MasterFlakeAnalysis entity for the given parameters will be created if none 22 A MasterFlakeAnalysis entity for the given parameters will be created if none
22 exists. When a new analysis is needed, this function will create and 23 exists. When a new analysis is needed, this function will create and
23 save a MasterFlakeAnalysis entity to the datastore. 24 save a MasterFlakeAnalysis entity to the datastore.
24 25
25 Returns: 26 Returns:
26 True if an analysis is needed, otherwise False. 27 True if an analysis is needed, otherwise False.
27 """ 28 """
28 master_flake_analysis = MasterFlakeAnalysis.Get( 29 master_flake_analysis = MasterFlakeAnalysis.Get(
29 master_name, builder_name, build_number, step_name, test_name) 30 master_name, builder_name, build_number, step_name, test_name)
30 31
31 if not master_flake_analysis: 32 if not master_flake_analysis:
32 if not allow_new_analysis: 33 if not allow_new_analysis:
33 return False 34 return False
34 master_flake_analysis = MasterFlakeAnalysis.Create( 35 master_flake_analysis = MasterFlakeAnalysis.Create(
35 master_name, builder_name, build_number, step_name, test_name) 36 master_name, builder_name, build_number, step_name, test_name)
37 master_flake_analysis.created_time = time_util.GetUTCNow()
36 master_flake_analysis.status = analysis_status.PENDING 38 master_flake_analysis.status = analysis_status.PENDING
37 master_flake_analysis.put() 39 master_flake_analysis.put()
38 return True 40 return True
39 elif (master_flake_analysis.status == analysis_status.COMPLETED or 41 elif (master_flake_analysis.status == analysis_status.COMPLETED or
40 master_flake_analysis.status == analysis_status.PENDING or 42 master_flake_analysis.status == analysis_status.PENDING or
41 master_flake_analysis.status == analysis_status.RUNNING): 43 master_flake_analysis.status == analysis_status.RUNNING):
42 return False 44 return False
43 else: 45 else:
44 # TODO(caiw): Reset method. 46 # TODO(caiw): Reset method.
45 MasterFlakeAnalysis.Get( 47 MasterFlakeAnalysis.Get(
(...skipping 25 matching lines...) Expand all
71 force (bool): Indicate whether to force a rerun of current analysis. 73 force (bool): Indicate whether to force a rerun of current analysis.
72 queue_name (str): The App Engine queue to run the analysis. 74 queue_name (str): The App Engine queue to run the analysis.
73 75
74 Returns: 76 Returns:
75 A MasterFlakeAnalysis instance. 77 A MasterFlakeAnalysis instance.
76 None if no analysis was scheduled and the user has no permission to. 78 None if no analysis was scheduled and the user has no permission to.
77 """ 79 """
78 if NeedANewAnalysis( 80 if NeedANewAnalysis(
79 master_name, builder_name, build_number, step_name, test_name, 81 master_name, builder_name, build_number, step_name, test_name,
80 allow_new_analysis): 82 allow_new_analysis):
83 master_flake_analysis = MasterFlakeAnalysis.Get(
84 master_name, builder_name, build_number, step_name, test_name)
81 check_flake_settings = waterfall_config.GetCheckFlakeSettings() 85 check_flake_settings = waterfall_config.GetCheckFlakeSettings()
86
87 # TODO(lijeffrey): Allow for reruns with custom parameters if the user is
88 # not satisfied with with the results generated by the default ones provided
89 # by waterfall_config and record the custom ones here.
90 master_flake_analysis.algorithm_parameters = check_flake_settings
91 master_flake_analysis.put()
92
82 max_build_numbers_to_look_back = check_flake_settings.get( 93 max_build_numbers_to_look_back = check_flake_settings.get(
83 'max_build_numbers_to_look_back') 94 'max_build_numbers_to_look_back')
84 flakiness_algorithm_results_dict = { 95 flakiness_algorithm_results_dict = {
85 'flakes_in_a_row': 0, 96 'flakes_in_a_row': 0,
86 'stable_in_a_row': 0, 97 'stable_in_a_row': 0,
87 'stabled_out': False, 98 'stabled_out': False,
88 'flaked_out': False, 99 'flaked_out': False,
89 'last_build_number': max( 100 'last_build_number': max(
90 0, build_number - max_build_numbers_to_look_back), 101 0, build_number - max_build_numbers_to_look_back),
91 'lower_boundary': None, 102 'lower_boundary': None,
92 'upper_boundary': None, 103 'upper_boundary': None,
93 'lower_boundary_result': None, 104 'lower_boundary_result': None,
94 'sequential_run_index': 0 105 'sequential_run_index': 0
95 } 106 }
107
96 pipeline_job = RecursiveFlakePipeline( 108 pipeline_job = RecursiveFlakePipeline(
97 master_name, builder_name, build_number, step_name, test_name, 109 master_name, builder_name, build_number, step_name, test_name,
98 master_build_number=build_number, 110 master_build_number=build_number,
99 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict) 111 flakiness_algorithm_results_dict=flakiness_algorithm_results_dict)
100 pipeline_job.target = appengine_util.GetTargetNameForModule( 112 pipeline_job.target = appengine_util.GetTargetNameForModule(
101 constants.WATERFALL_BACKEND) 113 constants.WATERFALL_BACKEND)
102 pipeline_job.start(queue_name=queue_name) 114 pipeline_job.start(queue_name=queue_name)
103 return MasterFlakeAnalysis.Get( 115 return MasterFlakeAnalysis.Get(
104 master_name, builder_name, build_number, step_name, test_name) 116 master_name, builder_name, build_number, step_name, test_name)
OLDNEW
« no previous file with comments | « appengine/findit/templates/flake/result.html ('k') | appengine/findit/waterfall/flake/recursive_flake_pipeline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698