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

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/bisector.py

Issue 1831843002: Revert of Add bisect config validation. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 9 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 | scripts/slave/recipe_modules/auto_bisect/config_validation.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 import json 5 import json
6 import re 6 import re
7 import time 7 import time
8 import urllib 8 import urllib
9 9
10 from . import config_validation
11 from . import depot_config 10 from . import depot_config
12 from . import revision_state 11 from . import revision_state
13 12
14 _DEPS_SHA_PATCH = """ 13 _DEPS_SHA_PATCH = """
15 diff --git DEPS.sha DEPS.sha 14 diff --git DEPS.sha DEPS.sha
16 new file mode 100644 15 new file mode 100644
17 --- /dev/null 16 --- /dev/null
18 +++ DEPS.sha 17 +++ DEPS.sha
19 @@ -0,0 +1 @@ 18 @@ -0,0 +1 @@
20 +%(deps_sha)s 19 +%(deps_sha)s
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 """This class abstracts an ongoing bisect (or n-sect) job.""" 68 """This class abstracts an ongoing bisect (or n-sect) job."""
70 69
71 def __init__(self, api, bisect_config, revision_class, init_revisions=True): 70 def __init__(self, api, bisect_config, revision_class, init_revisions=True):
72 """Initializes the state of a new bisect job from a dictionary. 71 """Initializes the state of a new bisect job from a dictionary.
73 72
74 Note that the initial good_rev and bad_rev MUST resolve to a commit position 73 Note that the initial good_rev and bad_rev MUST resolve to a commit position
75 in the chromium repo. 74 in the chromium repo.
76 """ 75 """
77 super(Bisector, self).__init__() 76 super(Bisector, self).__init__()
78 self._api = api 77 self._api = api
79 self.result_codes = set()
80 self.ensure_sync_master_branch() 78 self.ensure_sync_master_branch()
81 self.bisect_config = bisect_config 79 self.bisect_config = bisect_config
82 self.config_step() 80 self.config_step()
83 self._validate_config()
84 self.revision_class = revision_class 81 self.revision_class = revision_class
82 self.result_codes = set()
85 self.last_tested_revision = None 83 self.last_tested_revision = None
86 84
87 # Test-only properties. 85 # Test-only properties.
88 # TODO: Replace these with proper mod_test_data. 86 # TODO: Replace these with proper mod_test_data.
89 self.dummy_builds = bisect_config.get('dummy_builds', False) 87 self.dummy_builds = bisect_config.get('dummy_builds', False)
90 self.bypass_stats_check = bool(bisect_config.get('bypass_stats_check')) 88 self.bypass_stats_check = bool(bisect_config.get('bypass_stats_check'))
91 89
92 # Load configuration items. 90 # Load configuration items.
93 self.test_type = bisect_config.get('test_type', 'perf') 91 self.test_type = bisect_config.get('test_type', 'perf')
94 self.improvement_direction = int(bisect_config.get( 92 self.improvement_direction = int(bisect_config.get(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 results = step_result.stdout 182 results = step_result.stdout
185 if results is None: 183 if results is None:
186 assert self.dummy_builds 184 assert self.dummy_builds
187 return True 185 return True
188 significantly_different = results['significantly_different'] 186 significantly_different = results['significantly_different']
189 step_result.presentation.logs[str(significantly_different)] = [ 187 step_result.presentation.logs[str(significantly_different)] = [
190 'See json.output for details'] 188 'See json.output for details']
191 return significantly_different 189 return significantly_different
192 190
193 def config_step(self): 191 def config_step(self):
194 """Yields a step that prints the bisect config.""" 192 """Yields a simple echo step that outputs the bisect config."""
195 api = self.api 193 api = self.api
196
197 # bisect_config may come as a FrozenDict (which is not serializable). 194 # bisect_config may come as a FrozenDict (which is not serializable).
198 bisect_config = dict(self.bisect_config) 195 bisect_config = dict(self.bisect_config)
199 196
200 def fix_windows_backslashes(s): 197 def fix_windows_backslashes(s):
201 backslash_regex = re.compile(r'(?<!\\)\\(?!\\)') 198 backslash_regex = re.compile(r'(?<!\\)\\(?!\\)')
202 return backslash_regex.sub(r'\\', s) 199 return backslash_regex.sub(r'\\', s)
203 200
204 for k, v in bisect_config.iteritems(): 201 for k, v in bisect_config.iteritems():
205 if isinstance(v, basestring): 202 if isinstance(v, basestring):
206 bisect_config[k] = fix_windows_backslashes(v) 203 bisect_config[k] = fix_windows_backslashes(v)
207
208 # We sort the keys to prevent problems with orders changing when 204 # We sort the keys to prevent problems with orders changing when
209 # recipe_simulation_test compares against expectation files. 205 # recipe_simulation_test compares against expectation files.
210 config_string = json.dumps(bisect_config, indent=2, sort_keys=True) 206 config_string = json.dumps(bisect_config, indent=2, sort_keys=True)
211 step = api.m.step('config', []) 207 result = api.m.step('config', [])
212 config_lines = config_string.splitlines() 208 config_lines = config_string.splitlines()
213 step.presentation.logs['Bisect job configuration'] = config_lines 209 result.presentation.logs['Bisect job configuration'] = config_lines
214
215 def _validate_config(self):
216 """Raises an error and halts the bisect job if the config is invalid."""
217 try:
218 config_validation.validate_bisect_config(self.bisect_config)
219 except config_validation.ValidationFail as error:
220 self.surface_result('BAD_CONFIG')
221 self.api.m.halt(error.message)
222 raise self.api.m.step.StepFailure(error.message)
223 210
224 @property 211 @property
225 def api(self): 212 def api(self):
226 return self._api 213 return self._api
227 214
228 def compute_relative_change(self): 215 def compute_relative_change(self):
229 old_value = float(self.good_rev.mean_value) 216 old_value = float(self.good_rev.mean_value)
230 new_value = float(self.bad_rev.mean_value) 217 new_value = float(self.bad_rev.mean_value)
231 218
232 if new_value and not old_value: # pragma: no cover 219 if new_value and not old_value: # pragma: no cover
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 }) 844 })
858 return revision_rows 845 return revision_rows
859 846
860 def _get_build_url(self): 847 def _get_build_url(self):
861 properties = self.api.m.properties 848 properties = self.api.m.properties
862 bot_url = properties.get('buildbotURL', 849 bot_url = properties.get('buildbotURL',
863 'http://build.chromium.org/p/chromium/') 850 'http://build.chromium.org/p/chromium/')
864 builder_name = urllib.quote(properties.get('buildername', '')) 851 builder_name = urllib.quote(properties.get('buildername', ''))
865 builder_number = str(properties.get('buildnumber', '')) 852 builder_number = str(properties.get('buildnumber', ''))
866 return '%sbuilders/%s/builds/%s' % (bot_url, builder_name, builder_number) 853 return '%sbuilders/%s/builds/%s' % (bot_url, builder_name, builder_number)
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/auto_bisect/config_validation.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698