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

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

Issue 940123005: Adding ability to bisect recipe to bisect into dependency repos. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@hax
Patch Set: Missing docstring Created 5 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
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import json
6
7 DEPS = [
8 'auto_bisect',
9 'path',
10 'properties',
11 'raw_io',
12 'step',
13 ]
14
15
16 def GenSteps(api):
17 # Setting `api.path['checkout']` would ordinarily be done by
18 # `api.chromium_tests.sync_and_configure_build`
19 fake_checkout_path = api.path.mkdtemp('fake_checkout')
20 api.path['checkout'] = fake_checkout_path
21 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config'])
22
23 # Request builds/tests for initial range and wait
24 bisector.good_rev.start_job()
25 bisector.bad_rev.start_job()
26 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev])
27
28 assert bisector.check_improvement_direction()
29 assert bisector.check_regression_confidence()
30 revisions_to_check = bisector.get_revisions_to_eval(1)
31 assert len(revisions_to_check) == 1
32 revisions_to_check[0].start_job()
33 bisector.wait_for_any(revisions_to_check)
34 bisector.check_bisect_finished(revisions_to_check[0])
35
36 # Evaluate inserted DEPS-modified revisions
37 revisions_to_check = bisector.get_revisions_to_eval(2)
38 if revisions_to_check:
39 revisions_to_check[0].start_job()
40 revisions_to_check[0].read_deps() # Only added for coverage.
41 else:
42 raise api.step.StepFailure('Expected revisions to check.')
43 # TODO(robertocn): Add examples for the following operations
44 # Abort unnecesary jobs # Print results
45
46
47 def GenTests(api):
qyearsley 2015/03/10 23:20:49 Optional: You could add notes about when GenSteps
RobertoCN 2015/03/13 20:55:59 Done.
48 basic_data = _get_basic_test_data()
49 yield _make_test(api, basic_data, 'basic')
50
51 reversed_basic_data = _get_reversed_basic_test_data()
52 yield _make_test(api, reversed_basic_data, 'reversed_basic')
53
54 bad_git_hash_data = _get_basic_test_data()
55 bad_git_hash_data[1]['interned_hashes'] = {'003': '12345', '002': 'Bad Hash'}
56 yield _make_test(api, bad_git_hash_data, 'failed_git_hash_object')
57
58 missing_dep_data = _get_basic_test_data()
59 tricked_DEPS_file = ("vars={'v8_' + 'revision': '001'};"
60 "deps = {'src/v8': 'v8.git@' + Var('v8_revision'),"
61 "'src/third_party/WebKit': 'webkit.git@010'}")
62 missing_dep_data[0]['DEPS'] = tricked_DEPS_file
63 yield _make_test(api, missing_dep_data, 'missing_vars_entry')
64
65 missing_dep_data = _get_basic_test_data()
66 tricked_DEPS_file = ("vars={'v8_revision': '001'};"
67 "deps = {'src/v8': 'v8.XXX@' + Var('v8_revision'),"
68 "'src/third_party/WebKit': 'webkit.git@010'}")
69 missing_dep_data[0]['DEPS'] = tricked_DEPS_file
70 yield _make_test(api, missing_dep_data, 'missing_deps_entry')
71
72 bad_deps_syntax_data = _get_basic_test_data()
73 bad_deps_syntax_data[1]['DEPS']='raise RuntimeError("")'
74 yield _make_test(api, bad_deps_syntax_data, 'bad_deps_syntax')
75
76
77 def _get_basic_test_data():
78 return [
79 {
80 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222',
81 'commit_pos': '314015',
82 'test_results': {
83 'results':{
84 'mean': 20,
85 'std_err': 1,
86 'values': [19, 20, 21],
87 }
88 },
89 "DEPS": ("vars={'v8_revision': '001'};"
90 "deps = {'src/v8': 'v8.git@' + Var('v8_revision'),"
91 "'src/third_party/WebKit': 'webkit.git@010'}"),
92 'git_diff': {
93 '002': 'Dummy .diff contents 001 - 002',
94 '003': 'Dummy .diff contents 001 - 003',
95 },
96 },
97 {
98 'hash': 'dcdcdc0ff1122212323134879ddceeb1240b0988',
99 'commit_pos': '314016',
100 'test_results': {
101 'results':{
102 'mean': 15,
103 'std_err': 1,
104 'values': [14, 15, 16],
105 }
106 },
107 'DEPS_change': 'True',
108 "DEPS": ("vars={'v8_revision': '004'};"
109 "deps = {'src/v8': 'v8.git@' + Var('v8_revision'),"
110 "'src/third_party/WebKit': 'webkit.git@010'}"),
111 'DEPS_interval': {'v8': '004 003 002'.split()},
112 },
113 {
114 'hash': '00316c9ddfb9d7b4e1ed2fff9fe6d964d2111111',
115 'commit_pos': '314017',
116 'test_results': {
117 'results':{
118 'mean': 15,
119 'std_err': 1,
120 'values': [14, 15, 16],
121 }
122 }
123 },
124 ]
125
126
127 def _get_reversed_basic_test_data():
128 return [
129 {
130 'hash': '00316c9ddfb9d7b4e1ed2fff9fe6d964d2111111',
131 'commit_pos': '314015',
132 'test_results': {
133 'results':{
134 'mean': 20,
135 'std_err': 1,
136 'values': [19, 20, 21],
137 }
138 }
139 },
140 {
141 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222',
142 'commit_pos': '314016',
143 'test_results': {
144 'results':{
145 'mean': 20,
146 'std_err': 1,
147 'values': [19, 20, 21],
148 }
149 },
150 "DEPS": ("vars={'v8_revision': '001'};"
151 "deps = {'src/v8': 'v8.git@' + Var('v8_revision'),"
152 "'src/third_party/WebKit': 'webkit.git@010'}"),
153 'git_diff': {
154 '002': 'Dummy .diff contents 001 - 002',
155 '003': 'Dummy .diff contents 001 - 003',
156 },
157 },
158 {
159 'hash': 'dcdcdc0ff1122212323134879ddceeb1240b0988',
160 'commit_pos': '314017',
161 'test_results': {
162 'results':{
163 'mean': 15,
164 'std_err': 1,
165 'values': [14, 15, 16],
166 }
167 },
168 'DEPS_change': 'True',
169 "DEPS": ("vars={'v8_revision': '004'};"
170 "deps = {'src/v8': 'v8.git@' + Var('v8_revision'),"
171 "'src/third_party/WebKit': 'webkit.git@010'}"),
172 'DEPS_interval': {'v8': '004 003 002'.split()},
173 },
174 ]
175
176
177 def _make_test(api, test_data, test_name):
178 basic_test = api.test(test_name)
179 for revision_data in test_data:
180 for step_data in _get_step_data_for_revision(api, revision_data):
181 basic_test += step_data
182 basic_test += api.properties(bisect_config=_get_default_config())
183 return basic_test
184
185
186 def _get_default_config():
187 example_config = {
188 'test_type':'perf',
189 'command':
190 ('src/tools/perf/run_benchmark -v --browser=release smoothness.'
191 'tough_scrolling_cases'),
192 'good_revision': '314015',
193 'bad_revision': '314017',
194 'metric': 'mean_input_event_latency/mean_input_event_latency',
195 'repeat_count': '2',
196 'max_time_minutes': '5',
197 'truncate_percent': '0',
198 'bug_id': '',
199 'gs_bucket': 'chrome-perf',
200 'builder_host': 'master4.golo.chromium.org',
201 'builder_port': '8341',
202 'dummy_builds': 'True',
203 }
204 return example_config
205
206
207 def _get_step_data_for_revision(api, revision_data, include_build_steps=True):
208 """Generator that produces step patches for fake results."""
209 commit_pos = revision_data['commit_pos']
210 commit_hash = revision_data['hash']
211 test_results = revision_data['test_results']
qyearsley 2015/03/10 23:20:49 You don't have to do anything about this comment,
RobertoCN 2015/03/13 20:55:59 Acknowledged.
212
213 step_name = 'resolving commit_pos ' + commit_pos
214 yield api.step_data(step_name, stdout=api.raw_io.output('hash:' +
215 commit_hash))
216
217 step_name = 'resolving hash ' + commit_hash
218 commit_pos_str = 'refs/heads/master@{#%s}' % commit_pos
219 yield api.step_data(step_name, stdout=api.raw_io.output(commit_pos_str))
220
221 if include_build_steps:
222 step_name = 'gsutil Get test results for build ' + commit_hash
223 yield api.step_data(step_name, stdout=api.raw_io.output(json.dumps(
224 test_results)))
225
226 step_name = 'Get test status for build ' + commit_hash
227 yield api.step_data(step_name, stdout=api.raw_io.output('Complete'))
228
229 step_name = 'gsutil Get test status url for build ' + commit_hash
230 yield api.step_data(step_name, stdout=api.raw_io.output('dummy/url'))
231
232 if revision_data.get('DEPS', False):
233 step_name = 'git cat-file %s:DEPS' % commit_hash
234 yield api.step_data(step_name, stdout=api.raw_io.output(
235 revision_data['DEPS']))
236
237 if 'git_diff' in revision_data:
238 for deps_rev, diff_file in revision_data['git_diff'].iteritems():
239 step_name = 'Generating patch for %s:DEPS to %s'
240 step_name %= (commit_hash, deps_rev)
241 yield api.step_data(step_name, stdout=api.raw_io.output(diff_file))
242
243 if 'DEPS_change' in revision_data:
244 step_name = 'Checking DEPS for ' + commit_hash
245 yield api.step_data(step_name, stdout=api.raw_io.output('DEPS'))
246
247 if 'DEPS_interval' in revision_data:
248 for depot_name, interval in revision_data['DEPS_interval'].iteritems():
249 for item in interval[1:]:
250 step_name = 'Hashing modified DEPS file with revision ' + item
251 file_hash = 'f412e8458'
252 if 'interned_hashes' in revision_data:
253 file_hash = revision_data['interned_hashes'][item]
254 yield api.step_data(step_name, stdout=api.raw_io.output(file_hash))
255 step_name = 'Expanding revision range for revision %s on depot %s'
256 step_name %= (interval[0], depot_name)
257 stdout = api.raw_io.output('\n'.join(interval))
258 yield api.step_data(step_name, stdout=stdout)
259
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698