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

Side by Side Diff: appengine/findit/handlers/config.py

Issue 2272953002: [Findit] Moving check flake parameters to config (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Updating swarming settings config example Created 4 years, 3 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
« no previous file with comments | « no previous file | appengine/findit/handlers/test/config_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Handles requests to the findit config page.""" 5 """Handles requests to the findit config page."""
6 6
7 import json 7 import json
8 8
9 from common.base_handler import BaseHandler 9 from common.base_handler import BaseHandler
10 from common.base_handler import Permission 10 from common.base_handler import Permission
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 def _ValidateSwarmingSettings(settings): 158 def _ValidateSwarmingSettings(settings):
159 return (isinstance(settings, dict) and 159 return (isinstance(settings, dict) and
160 isinstance(settings.get('server_host'), basestring) and 160 isinstance(settings.get('server_host'), basestring) and
161 isinstance(settings.get('default_request_priority'), int) and 161 isinstance(settings.get('default_request_priority'), int) and
162 isinstance(settings.get('request_expiration_hours'), int) and 162 isinstance(settings.get('request_expiration_hours'), int) and
163 isinstance(settings.get('server_query_interval_seconds'), int) and 163 isinstance(settings.get('server_query_interval_seconds'), int) and
164 isinstance(settings.get('task_timeout_hours'), int) and 164 isinstance(settings.get('task_timeout_hours'), int) and
165 isinstance(settings.get('isolated_server'), basestring) and 165 isinstance(settings.get('isolated_server'), basestring) and
166 isinstance(settings.get('isolated_storage_url'), basestring) and 166 isinstance(settings.get('isolated_storage_url'), basestring) and
167 isinstance(settings.get('iterations_to_rerun'), int)) 167 isinstance(settings.get('iterations_to_rerun'), int) and
168 isinstance(
169 settings.get('get_swarming_task_id_timeout_seconds'), int) and
170 isinstance(settings.get('get_swarming_task_id_wait_seconds'), int))
168 171
169 172
170 def _ValidateDownloadBuildDataSettings(settings): 173 def _ValidateDownloadBuildDataSettings(settings):
171 return (isinstance(settings, dict) and 174 return (isinstance(settings, dict) and
172 isinstance(settings.get('download_interval_seconds'), int) and 175 isinstance(settings.get('download_interval_seconds'), int) and
173 isinstance(settings.get( 176 isinstance(settings.get(
174 'memcache_master_download_expiration_seconds'), int) and 177 'memcache_master_download_expiration_seconds'), int) and
175 isinstance(settings.get('use_chrome_build_extract'), bool)) 178 isinstance(settings.get('use_chrome_build_extract'), bool))
176 179
177 180
178 def _ValidateActionSettings(settings): 181 def _ValidateActionSettings(settings):
179 return (isinstance(settings, dict) and 182 return (isinstance(settings, dict) and
180 isinstance(settings.get('cr_notification_build_threshold'), int) and 183 isinstance(settings.get('cr_notification_build_threshold'), int) and
181 isinstance( 184 isinstance(
182 settings.get('cr_notification_latency_limit_minutes'), int)) 185 settings.get('cr_notification_latency_limit_minutes'), int))
183 186
184 187
188 def _ValidateCheckFlakeSettings(settings):
189 return (isinstance(settings, dict) and
190 isinstance(settings.get('lower_flake_threshold'), float) and
191 isinstance(settings.get('upper_flake_threshold'), float) and
192 isinstance(settings.get('max_flake_in_a_row'), int) and
193 isinstance(settings.get('max_stable_in_a_row'), int) and
194 isinstance(settings.get('iterations_to_rerun'), int))
195
196
185 # Maps config properties to their validation functions. 197 # Maps config properties to their validation functions.
186 _CONFIG_VALIDATION_FUNCTIONS = { 198 _CONFIG_VALIDATION_FUNCTIONS = {
187 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping, 199 'steps_for_masters_rules': _ValidateMastersAndStepsRulesMapping,
188 'builders_to_trybots': _ValidateTrybotMapping, 200 'builders_to_trybots': _ValidateTrybotMapping,
189 'try_job_settings': _ValidateTryJobSettings, 201 'try_job_settings': _ValidateTryJobSettings,
190 'swarming_settings': _ValidateSwarmingSettings, 202 'swarming_settings': _ValidateSwarmingSettings,
191 'download_build_data_settings': _ValidateDownloadBuildDataSettings, 203 'download_build_data_settings': _ValidateDownloadBuildDataSettings,
192 'action_settings': _ValidateActionSettings, 204 'action_settings': _ValidateActionSettings,
205 'check_flake_settings': _ValidateCheckFlakeSettings,
193 } 206 }
194 207
195 208
196 def _ConfigurationDictIsValid(configuration_dict): 209 def _ConfigurationDictIsValid(configuration_dict):
197 """Checks that each configuration setting is properly formatted. 210 """Checks that each configuration setting is properly formatted.
198 211
199 Args: 212 Args:
200 configuration_dict: A dictionary expected to map configuration properties 213 configuration_dict: A dictionary expected to map configuration properties
201 by name to their intended settings. For example, 214 by name to their intended settings. For example,
202 215
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 259
247 latest_version = settings.GetLatestVersionNumber() 260 latest_version = settings.GetLatestVersionNumber()
248 261
249 data = { 262 data = {
250 'masters': waterfall_config.GetStepsForMastersRules(settings), 263 'masters': waterfall_config.GetStepsForMastersRules(settings),
251 'builders': settings.builders_to_trybots, 264 'builders': settings.builders_to_trybots,
252 'try_job_settings': settings.try_job_settings, 265 'try_job_settings': settings.try_job_settings,
253 'swarming_settings': settings.swarming_settings, 266 'swarming_settings': settings.swarming_settings,
254 'download_build_data_settings': settings.download_build_data_settings, 267 'download_build_data_settings': settings.download_build_data_settings,
255 'action_settings': settings.action_settings, 268 'action_settings': settings.action_settings,
269 'check_flake_settings': settings.check_flake_settings,
256 'version': settings.version, 270 'version': settings.version,
257 'latest_version': latest_version, 271 'latest_version': latest_version,
258 'updated_by': settings.updated_by, 272 'updated_by': settings.updated_by,
259 'updated_ts': _FormatTimestamp(settings.updated_ts) 273 'updated_ts': _FormatTimestamp(settings.updated_ts)
260 } 274 }
261 275
262 return {'template': 'config.html', 'data': data} 276 return {'template': 'config.html', 'data': data}
263 277
264 def HandlePost(self): 278 def HandlePost(self):
265 data = self.request.params.get('data') 279 data = self.request.params.get('data')
266 new_config_dict = json.loads(data) 280 new_config_dict = json.loads(data)
267 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover 281 if not _ConfigurationDictIsValid(new_config_dict): # pragma: no cover
268 return self.CreateError( 282 return self.CreateError(
269 'New configuration settings is not properly formatted.', 400) 283 'New configuration settings is not properly formatted.', 400)
270 284
271 wf_config.FinditConfig.Get().Update(users.get_current_user(), 285 wf_config.FinditConfig.Get().Update(users.get_current_user(),
272 users.IsCurrentUserAdmin(), 286 users.IsCurrentUserAdmin(),
273 **new_config_dict) 287 **new_config_dict)
274 288
275 return self.HandleGet() 289 return self.HandleGet()
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/handlers/test/config_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698