OLD | NEW |
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 | 6 |
7 DEPS = [ | 7 DEPS = [ |
8 'auto_bisect', | 8 'auto_bisect', |
9 'chromium_tests', | 9 'chromium_tests', |
| 10 'depot_tools/gclient', |
10 'recipe_engine/json', | 11 'recipe_engine/json', |
11 'recipe_engine/path', | 12 'recipe_engine/path', |
12 'recipe_engine/properties', | 13 'recipe_engine/properties', |
13 'recipe_engine/raw_io', | 14 'recipe_engine/raw_io', |
14 'recipe_engine/step', | 15 'recipe_engine/step', |
15 ] | 16 ] |
16 | 17 |
17 """This file is a recipe demonstrating the auto_bisect recipe module. | 18 """This file is a recipe demonstrating the auto_bisect recipe module. |
18 | 19 |
19 For more information about recipes, see: https://goo.gl/xKnjz6 | 20 For more information about recipes, see: https://goo.gl/xKnjz6 |
20 """ | 21 """ |
21 | 22 |
22 | 23 |
23 def RunSteps(api): | 24 def RunSteps(api): |
| 25 mastername = api.properties.get('mastername') |
| 26 buildername = api.properties.get('buildername') |
| 27 bot_config = api.chromium_tests.create_bot_config_object(mastername, |
| 28 buildername) |
| 29 api.chromium_tests.configure_build(bot_config) |
| 30 api.gclient.apply_config('perf') |
| 31 update_step, bot_db = api.chromium_tests.prepare_checkout(bot_config) |
| 32 |
| 33 api.auto_bisect.bot_db = bot_db |
| 34 |
24 fake_checkout_path = api.path.mkdtemp('fake_checkout') | 35 fake_checkout_path = api.path.mkdtemp('fake_checkout') |
25 api.path['checkout'] = fake_checkout_path | 36 api.path['checkout'] = fake_checkout_path |
| 37 api.path.c.dynamic_paths['catapult'] = api.path['slave_build'].join( |
| 38 'catapult') |
26 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config'], | 39 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config'], |
27 do_not_nest_wait_for_revision=True) | 40 do_not_nest_wait_for_revision=True) |
28 | 41 |
29 # Request builds and tests for initial range and wait. | |
30 bisector.good_rev.start_job() | 42 bisector.good_rev.start_job() |
| 43 if bisector.good_rev.failed: |
| 44 return |
| 45 |
31 bisector.bad_rev.start_job() | 46 bisector.bad_rev.start_job() |
32 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) | 47 if bisector.bad_rev.failed: |
33 | |
34 if bisector.good_rev.failed or bisector.bad_rev.failed: | |
35 return | 48 return |
36 | 49 |
37 assert bisector.check_improvement_direction() | 50 assert bisector.check_improvement_direction() |
38 assert bisector.check_initial_confidence() | 51 assert bisector.check_initial_confidence() |
39 revision_to_check = bisector.get_revision_to_eval() | 52 revision_to_check = bisector.get_revision_to_eval() |
40 revision_to_check.start_job() | 53 revision_to_check.start_job() |
41 bisector.wait_for(revision_to_check) | |
42 bisector.check_bisect_finished(revision_to_check) | 54 bisector.check_bisect_finished(revision_to_check) |
43 | 55 |
44 # Evaluate inserted DEPS-modified revisions. | 56 # Evaluate inserted DEPS-modified revisions. |
45 revision_to_check = bisector.get_revision_to_eval() | 57 revision_to_check = bisector.get_revision_to_eval() |
46 if revision_to_check: | 58 if revision_to_check: |
47 revision_to_check.start_job() | 59 revision_to_check.start_job() |
48 # Only added for coverage. | 60 # Only added for coverage. |
49 revision_to_check.read_deps(bisector.get_perf_tester_name()) | 61 revision_to_check.read_deps(bisector.get_perf_tester_name()) |
50 api.auto_bisect.query_revision_info(revision_to_check) | 62 api.auto_bisect.query_revision_info(revision_to_check) |
51 else: | 63 else: |
52 raise api.step.StepFailure('Expected revision to check.') | 64 raise api.step.StepFailure('Expected revision to check.') |
53 # TODO(robertocn): Add examples for the following operations: | 65 # TODO(robertocn): Add examples for the following operations: |
54 # Abort unnecessary jobs | 66 # Abort unnecessary jobs |
55 # Print results (may be done in a unit test) | 67 # Print results (may be done in a unit test) |
56 | 68 |
57 # Test runner for classic bisect script; calls bisect script in recipe | 69 # Test runner for classic bisect script; calls bisect script in recipe |
58 # wrapper with extra_src and path_to_config to override default behavior for | 70 # wrapper with extra_src and path_to_config to override default behavior for |
59 # android-chrome bisect jobs. | 71 # android-chrome bisect jobs. |
60 if api.properties.get('mastername'): | 72 if api.properties.get('mastername'): |
61 # TODO(akuegel): Load the config explicitly instead of relying on the | 73 # TODO(akuegel): Load the config explicitly instead of relying on the |
62 # builders.py entries in chromium_tests. | 74 # builders.py entries in chromium_tests. |
63 mastername = api.properties.get('mastername') | 75 mastername = api.properties.get('mastername') |
64 buildername = api.properties.get('buildername') | 76 buildername = api.properties.get('buildername') |
65 bot_config = api.chromium_tests.create_bot_config_object( | 77 bot_config = api.chromium_tests.create_bot_config_object( |
66 mastername, buildername) | 78 mastername, buildername) |
67 api.chromium_tests.configure_build(bot_config) | 79 api.chromium_tests.configure_build(bot_config) |
| 80 api.gclient.c.got_revision_mapping.pop('catapult', None) |
68 api.chromium_tests.prepare_checkout(bot_config) | 81 api.chromium_tests.prepare_checkout(bot_config) |
69 kwargs = { | 82 kwargs = { |
70 'extra_src': 'dummy_extra_src', | 83 'extra_src': 'dummy_extra_src', |
71 'path_to_config': '/dummy/path/', | 84 'path_to_config': '/dummy/path/', |
72 } | 85 } |
73 api.auto_bisect.run_bisect_script(**kwargs) | 86 api.auto_bisect.run_bisect_script(**kwargs) |
74 | 87 |
75 | 88 |
76 def GenTests(api): | 89 def GenTests(api): |
77 dummy_gs_location = ('gs://chrome-perf/bisect-results/' | 90 dummy_gs_location = ('gs://chrome-perf/bisect-results/' |
78 'a6298e4afedbf2cd461755ea6f45b0ad64222222-test.results') | 91 'a6298e4afedbf2cd461755ea6f45b0ad64222222-test.results') |
| 92 bisect_script_test = _make_test( |
| 93 api, _get_basic_test_data(), 'basic_bisect_script') |
| 94 |
| 95 bisect_script_test += api.properties(mastername='tryserver.chromium.perf', |
| 96 buildername='linux_perf_bisect', |
| 97 slavename='dummyslave') |
| 98 yield bisect_script_test |
| 99 |
79 basic_test = _make_test(api, _get_basic_test_data(), 'basic') | 100 basic_test = _make_test(api, _get_basic_test_data(), 'basic') |
80 yield basic_test | 101 yield basic_test |
81 | 102 |
| 103 yield _make_test(api, _get_reversed_basic_test_data(), 'reversed_basic') |
| 104 |
82 invalid_config_test = api.test('invalid_config') | 105 invalid_config_test = api.test('invalid_config') |
83 invalid_config_test += api.properties( | 106 invalid_config_test += api.properties( |
84 bisect_config=_get_config({'good_revision': 'not a valid revision'})) | 107 bisect_config=_get_config({'good_revision': 'not a valid revision'})) |
85 yield invalid_config_test | 108 yield invalid_config_test |
86 | 109 |
87 failed_build_test = _make_test( | |
88 api, _get_ref_range_only_test_data(), 'failed_build_test', | |
89 extra_config={'dummy_builds': None}) | |
90 failed_build_test += api.step_data('gsutil ls', retcode=1) | |
91 failed_build_test += api.step_data('gsutil ls (2)' , retcode=1) | |
92 failed_build_test += api.step_data('gsutil ls (3)' , retcode=1) | |
93 failed_build_test += api.step_data( | |
94 'buildbucket.get', stdout=api.json.output( | |
95 {'build':{'status': 'COMPLETE', 'result': 'FAILED'}})) | |
96 yield failed_build_test | |
97 | |
98 | |
99 delayed_build_test = _make_test( | |
100 api, _get_ref_range_only_test_data(), 'delayed_build_test', | |
101 extra_config={'dummy_builds': None}) | |
102 delayed_build_test += api.step_data('gsutil ls', retcode=1) | |
103 delayed_build_test += api.step_data('gsutil ls (2)', retcode=1) | |
104 delayed_build_test += api.step_data('gsutil ls (3)', retcode=1) | |
105 delayed_build_test += api.step_data('gsutil ls (4)', retcode=1) | |
106 delayed_build_test += api.step_data('gsutil ls (5)', retcode=1) | |
107 delayed_build_test += api.step_data('gsutil ls (6)', retcode=1) | |
108 delayed_build_test += api.step_data( | |
109 'buildbucket.get', stdout=api.json.output( | |
110 {'build':{'status': 'PENDING'}})) | |
111 yield delayed_build_test | |
112 | |
113 missing_metric_test = _make_test( | 110 missing_metric_test = _make_test( |
114 api, _get_ref_range_only_missing_metric_test_data(), | 111 api, _get_ref_range_only_missing_metric_test_data(), |
115 'missing_metric_test') | 112 'missing_metric_test') |
116 yield missing_metric_test | 113 yield missing_metric_test |
117 | 114 |
118 windows_test = _make_test( | 115 windows_test = _make_test( |
119 api, _get_basic_test_data(), 'windows_bisector', platform='windows') | 116 api, _get_basic_test_data(), 'windows_bisector', platform='windows') |
120 yield windows_test | 117 yield windows_test |
121 | 118 |
122 winx64_test = _make_test( | 119 winx64_test = _make_test( |
(...skipping 16 matching lines...) Expand all Loading... |
139 failed_data = _get_basic_test_data() | 136 failed_data = _get_basic_test_data() |
140 failed_data[0].pop('DEPS') | 137 failed_data[0].pop('DEPS') |
141 failed_data[1]['test_results']['results']['errors'] = ['Dummy error.'] | 138 failed_data[1]['test_results']['results']['errors'] = ['Dummy error.'] |
142 failed_data[1].pop('DEPS_change') | 139 failed_data[1].pop('DEPS_change') |
143 failed_data[1].pop('DEPS') | 140 failed_data[1].pop('DEPS') |
144 failed_data[1].pop('DEPS_interval') | 141 failed_data[1].pop('DEPS_interval') |
145 failed_data[0].pop('git_diff') | 142 failed_data[0].pop('git_diff') |
146 failed_data[0].pop('cl_info') | 143 failed_data[0].pop('cl_info') |
147 yield _make_test(api, failed_data, 'failed_test') | 144 yield _make_test(api, failed_data, 'failed_test') |
148 | 145 |
149 yield _make_test(api, _get_reversed_basic_test_data(), 'reversed_basic') | 146 failed_build_test = _make_test( |
| 147 api, _get_ref_range_only_test_data(), 'failed_build_test', |
| 148 extra_config={'dummy_builds': None}) |
| 149 failed_build_test += api.step_data('gsutil ls', retcode=1) |
| 150 failed_build_test += api.step_data('gsutil ls (2)' , retcode=1) |
| 151 failed_build_test += api.step_data('gsutil ls (3)' , retcode=1) |
| 152 failed_build_test += api.step_data( |
| 153 'fetch builder state', |
| 154 api.raw_io.output(json.dumps({'cachedBuilds': ['2106']}))) |
| 155 failed_build_test += api.step_data( |
| 156 'fetch build details', |
| 157 api.raw_io.output(json.dumps({ |
| 158 'results': 2, |
| 159 'properties': [('build_archive_url', |
| 160 ('gs://chrome-perf/Linux Builder/full-build-linux_' |
| 161 'a6298e4afedbf2cd461755ea6f45b0ad64222222.zip'))] |
| 162 }))) |
| 163 yield failed_build_test |
150 | 164 |
151 bad_git_hash_data = _get_basic_test_data() | 165 delayed_build_test = _make_test( |
152 bad_git_hash_data[1]['interned_hashes'] = {'003': '12345', '002': 'Bad Hash'} | 166 api, _get_ref_range_only_test_data(), 'delayed_build_test', |
153 | 167 extra_config={'dummy_builds': None}) |
154 bisect_script_test = _make_test( | 168 delayed_build_test += api.step_data('gsutil ls', retcode=1) |
155 api, _get_basic_test_data(), 'basic_bisect_script') | 169 delayed_build_test += api.step_data('gsutil ls (2)', retcode=1) |
156 | 170 delayed_build_test += api.step_data('gsutil ls (3)', retcode=1) |
157 yield bisect_script_test | 171 delayed_build_test += api.step_data('gsutil ls (4)', retcode=1) |
| 172 delayed_build_test += api.step_data('gsutil ls (5)', retcode=1) |
| 173 delayed_build_test += api.step_data('gsutil ls (6)', retcode=1) |
| 174 delayed_build_test += api.step_data( |
| 175 'fetch builder state', |
| 176 api.raw_io.output(json.dumps({'cachedBuilds': []}))) |
| 177 delayed_build_test += api.step_data( |
| 178 'fetch builder state (2)', |
| 179 api.raw_io.output(json.dumps({'cachedBuilds': ['2106']}))) |
| 180 delayed_build_test += api.step_data( |
| 181 'fetch build details', |
| 182 api.raw_io.output(json.dumps({ |
| 183 'properties': [('build_archive_url', |
| 184 ('gs://chrome-perf/Linux Builder/full-build-linux_' |
| 185 'a6298e4afedbf2cd461755ea6f45b0ad64222222.zip'))] |
| 186 }))) |
| 187 delayed_build_test += api.step_data( |
| 188 'fetch build details (2)', |
| 189 api.raw_io.output(json.dumps({ |
| 190 'results': 2, |
| 191 'properties': [('build_archive_url', |
| 192 ('gs://chrome-perf/Linux Builder/full-build-linux_' |
| 193 'a6298e4afedbf2cd461755ea6f45b0ad64222222.zip'))] |
| 194 }))) |
| 195 yield delayed_build_test |
158 | 196 |
159 | 197 |
160 def _get_ref_range_only_test_data(): | 198 def _get_ref_range_only_test_data(): |
161 return [ | 199 return [ |
162 { | 200 { |
163 'refrange': True, | 201 'refrange': True, |
164 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', | 202 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', |
165 'commit_pos': '314015', | 203 'commit_pos': '314015', |
166 'fail_to_build': True, | 204 'fail_to_build': True, |
167 }, | 205 }, |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 "'src/third_party/WebKit': 'webkit.git@010'}"), | 349 "'src/third_party/WebKit': 'webkit.git@010'}"), |
312 'DEPS_interval': {'v8': '002 003 004'.split()}, | 350 'DEPS_interval': {'v8': '002 003 004'.split()}, |
313 }, | 351 }, |
314 ] | 352 ] |
315 | 353 |
316 | 354 |
317 def _make_test(api, test_data, test_name, platform='linux', extra_config=None): | 355 def _make_test(api, test_data, test_name, platform='linux', extra_config=None): |
318 basic_test = api.test(test_name) | 356 basic_test = api.test(test_name) |
319 basic_test += api.properties(mastername='tryserver.chromium.perf', | 357 basic_test += api.properties(mastername='tryserver.chromium.perf', |
320 buildername='linux_perf_bisect', | 358 buildername='linux_perf_bisect', |
321 slavename='dummyslave', | 359 slavename='dummyslave') |
322 buildnumber=123456) | 360 basic_test += api.auto_bisect() |
323 basic_test += _get_revision_range_step_data(api, test_data) | 361 basic_test += _get_revision_range_step_data(api, test_data) |
324 for revision_data in test_data: | 362 for revision_data in test_data: |
325 for step_data in _get_step_data_for_revision(api, revision_data): | 363 for step_data in _get_step_data_for_revision(api, revision_data): |
326 basic_test += step_data | 364 basic_test += step_data |
327 if 'win_x64' in platform: | 365 if 'win_x64' in platform: |
328 basic_test += api.properties(bisect_config=_get_config({ | 366 basic_test += api.properties(bisect_config=_get_config({ |
329 'command': ('src/tools/perf/run_benchmark -v --browser=release_x64' | 367 'command': ('src/tools/perf/run_benchmark -v --browser=release_x64' |
330 ' smoothness.tough_scrolling_cases'), | 368 ' smoothness.tough_scrolling_cases'), |
331 'recipe_tester_name': 'chromium_rel_win7_x64'})) | 369 'recipe_tester_name': 'chromium_rel_win7_x64'})) |
332 elif 'win' in platform: | 370 elif 'win' in platform: |
(...skipping 16 matching lines...) Expand all Loading... |
349 basic_test += api.properties(bisect_config=_get_config(extra_config)) | 387 basic_test += api.properties(bisect_config=_get_config(extra_config)) |
350 basic_test += api.properties( | 388 basic_test += api.properties( |
351 buildbotURL= 'https://build.chromium.org/p/tryserver.chromium.perf') | 389 buildbotURL= 'https://build.chromium.org/p/tryserver.chromium.perf') |
352 return basic_test | 390 return basic_test |
353 | 391 |
354 | 392 |
355 def _get_revision_range_step_data(api, range_data): | 393 def _get_revision_range_step_data(api, range_data): |
356 """Adds canned output for fetch_intervening_revisions.py.""" | 394 """Adds canned output for fetch_intervening_revisions.py.""" |
357 min_rev = range_data[0]['hash'] | 395 min_rev = range_data[0]['hash'] |
358 max_rev = range_data[-1]['hash'] | 396 max_rev = range_data[-1]['hash'] |
359 output = [[r['hash'], 'ignored'] for r in range_data[1:]] | 397 output = [[r['hash'], 'ignored'] for r in range_data[1:-1]] |
360 step_name = ('Expanding revision range.for revisions %s:%s' % | 398 step_name = ('Expanding revision range.for revisions %s:%s' % |
361 (min_rev, max_rev)) | 399 (min_rev, max_rev)) |
362 return api.step_data(step_name, stdout=api.json.output(output)) | 400 return api.step_data(step_name, stdout=api.json.output(output)) |
363 | 401 |
364 | 402 |
365 def _get_config(params=None): | 403 def _get_config(params=None): |
366 """Returns a sample bisect config dict with some fields overridden.""" | 404 """Returns a sample bisect config dict with some fields overridden.""" |
367 example_config = { | 405 example_config = { |
368 'test_type': 'perf', | 406 'test_type': 'perf', |
369 'command': ( | 407 'command': ( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 if revision_data.get('DEPS', False): | 450 if revision_data.get('DEPS', False): |
413 step_name = 'fetch file %s:DEPS' % commit_hash | 451 step_name = 'fetch file %s:DEPS' % commit_hash |
414 yield api.step_data(step_name, stdout=api.raw_io.output( | 452 yield api.step_data(step_name, stdout=api.raw_io.output( |
415 revision_data['DEPS'])) | 453 revision_data['DEPS'])) |
416 | 454 |
417 if 'git_diff' in revision_data: | 455 if 'git_diff' in revision_data: |
418 for deps_rev, diff_file in revision_data['git_diff'].iteritems(): | 456 for deps_rev, diff_file in revision_data['git_diff'].iteritems(): |
419 step_name = 'Generating patch for %s:DEPS to %s' | 457 step_name = 'Generating patch for %s:DEPS to %s' |
420 step_name %= (commit_hash, deps_rev) | 458 step_name %= (commit_hash, deps_rev) |
421 yield api.step_data(step_name, stdout=api.raw_io.output(diff_file)) | 459 yield api.step_data(step_name, stdout=api.raw_io.output(diff_file)) |
| 460 if deps_rev == '003': |
| 461 step_name = ('gsutil Get test results for build %s') % deps_rev |
| 462 yield api.step_data(step_name, stdout=api.json.output(test_results)) |
422 | 463 |
423 if 'DEPS_change' in revision_data: | 464 if 'DEPS_change' in revision_data: |
424 step_name = 'Checking DEPS for ' + commit_hash | 465 step_name = 'Checking DEPS for ' + commit_hash |
425 yield api.step_data(step_name, stdout=api.raw_io.output('DEPS')) | 466 yield api.step_data(step_name, stdout=api.raw_io.output('DEPS')) |
426 | 467 |
427 if 'DEPS_interval' in revision_data: | 468 if 'DEPS_interval' in revision_data: |
428 for depot_name, interval in revision_data['DEPS_interval'].iteritems(): | 469 for depot_name, interval in revision_data['DEPS_interval'].iteritems(): |
429 for item in reversed(interval[:-1]): | 470 for item in reversed(interval[:-1]): |
430 step_name = 'Hashing modified DEPS file with revision ' + item | 471 step_name = 'Hashing modified DEPS file with revision ' + item |
431 file_hash = 'f412e8458' | 472 file_hash = 'f412e8458' |
432 yield api.step_data(step_name, stdout=api.raw_io.output(file_hash)) | 473 yield api.step_data(step_name, stdout=api.raw_io.output(file_hash)) |
433 step_name = 'Expanding revision range for revision %s on depot %s' | 474 step_name = 'Expanding revision range for revision %s on depot %s' |
434 step_name %= (interval[-1], depot_name) | 475 step_name %= (interval[-1], depot_name) |
435 stdout = api.json.output([(r, 0) for r in interval[:-1]]) | 476 stdout = api.json.output([(r, 0) for r in interval[:-1]]) |
436 yield api.step_data(step_name, stdout=stdout) | 477 yield api.step_data(step_name, stdout=stdout) |
437 | 478 |
438 if 'cl_info' in revision_data: | 479 if 'cl_info' in revision_data: |
439 step_name = 'Reading culprit cl information.' | 480 step_name = 'Reading culprit cl information.' |
440 stdout = api.json.output(revision_data['cl_info']) | 481 stdout = api.json.output(revision_data['cl_info']) |
441 yield api.step_data(step_name, stdout=stdout) | 482 yield api.step_data(step_name, stdout=stdout) |
OLD | NEW |