| 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 'json', |
| 10 'path', | 11 'path', |
| 11 'properties', | 12 'properties', |
| 12 'raw_io', | 13 'raw_io', |
| 13 'step', | 14 'step', |
| 14 ] | 15 ] |
| 15 | 16 |
| 16 | 17 |
| 17 # This file is just a recipe showing how one would use this module. | 18 # This file is just a recipe showing how one would use this module. |
| 18 # | 19 # |
| 19 # The RunSteps and GenTests functions define the required interface for a | 20 # The RunSteps and GenTests functions define the required interface for a |
| (...skipping 11 matching lines...) Expand all Loading... |
| 31 def RunSteps(api): | 32 def RunSteps(api): |
| 32 fake_checkout_path = api.path.mkdtemp('fake_checkout') | 33 fake_checkout_path = api.path.mkdtemp('fake_checkout') |
| 33 api.path['checkout'] = fake_checkout_path | 34 api.path['checkout'] = fake_checkout_path |
| 34 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config']) | 35 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config']) |
| 35 | 36 |
| 36 # Request builds/tests for initial range and wait | 37 # Request builds/tests for initial range and wait |
| 37 bisector.good_rev.start_job() | 38 bisector.good_rev.start_job() |
| 38 bisector.bad_rev.start_job() | 39 bisector.bad_rev.start_job() |
| 39 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) | 40 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) |
| 40 | 41 |
| 42 if bisector.good_rev.failed or bisector.bad_rev.failed: |
| 43 return |
| 44 |
| 41 assert bisector.check_improvement_direction() | 45 assert bisector.check_improvement_direction() |
| 42 assert bisector.check_initial_confidence() | 46 assert bisector.check_initial_confidence() |
| 43 revisions_to_check = bisector.get_revisions_to_eval(1) | 47 revisions_to_check = bisector.get_revisions_to_eval(1) |
| 44 assert len(revisions_to_check) == 1 | 48 assert len(revisions_to_check) == 1 |
| 45 revisions_to_check[0].start_job() | 49 revisions_to_check[0].start_job() |
| 46 bisector.wait_for_any(revisions_to_check) | 50 bisector.wait_for_any(revisions_to_check) |
| 47 bisector.check_bisect_finished(revisions_to_check[0]) | 51 bisector.check_bisect_finished(revisions_to_check[0]) |
| 48 | 52 |
| 49 # Evaluate inserted DEPS-modified revisions | 53 # Evaluate inserted DEPS-modified revisions |
| 50 revisions_to_check = bisector.get_revisions_to_eval(2) | 54 revisions_to_check = bisector.get_revisions_to_eval(2) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 63 if api.properties.get('mastername'): | 67 if api.properties.get('mastername'): |
| 64 # TODO(akuegel): Load the config explicitly instead of relying on the | 68 # TODO(akuegel): Load the config explicitly instead of relying on the |
| 65 # builders.py entries in chromium_tests. | 69 # builders.py entries in chromium_tests. |
| 66 mastername = api.properties.get('mastername') | 70 mastername = api.properties.get('mastername') |
| 67 buildername = api.properties.get('buildername') | 71 buildername = api.properties.get('buildername') |
| 68 api.chromium_tests.configure_build(mastername, buildername) | 72 api.chromium_tests.configure_build(mastername, buildername) |
| 69 api.chromium_tests.prepare_checkout(mastername, buildername) | 73 api.chromium_tests.prepare_checkout(mastername, buildername) |
| 70 api.auto_bisect.run_bisect_script('dummy_extra_src', '/dummy/path/') | 74 api.auto_bisect.run_bisect_script('dummy_extra_src', '/dummy/path/') |
| 71 | 75 |
| 72 def GenTests(api): | 76 def GenTests(api): |
| 73 wait_for_any_output = ( | 77 dummy_gs_location = ('gs://chrome-perf/bisect-results/' |
| 74 'Build finished: gs://chrome-perf/bisect-results/' | 78 'a6298e4afedbf2cd461755ea6f45b0ad64222222-test.results') |
| 75 'a6298e4afedbf2cd461755ea6f45b0ad64222222-test.results') | 79 wait_for_any_output = { |
| 80 'completed': [ |
| 81 { |
| 82 'type': 'gs', |
| 83 'location': dummy_gs_location |
| 84 } |
| 85 ] |
| 86 } |
| 87 |
| 76 basic_data = _get_basic_test_data() | 88 basic_data = _get_basic_test_data() |
| 77 basic_test = _make_test(api, basic_data, 'basic') | 89 basic_test = _make_test(api, basic_data, 'basic') |
| 78 basic_test += api.step_data( | 90 basic_test += api.step_data( |
| 79 'Waiting for revision 314015 and 1 other revision(s). (2)', | 91 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 80 stdout=api.raw_io.output(wait_for_any_output)) | 92 stdout=api.json.output(wait_for_any_output)) |
| 81 | 93 |
| 82 yield basic_test | 94 yield basic_test |
| 83 | 95 |
| 96 failed_build_test_data = _get_ref_range_only_test_data() |
| 97 failed_build_test = _make_test( |
| 98 api, failed_build_test_data, 'failed_build_test') |
| 99 failed_build_test_step_data = {'failed': [ |
| 100 {'builder': 'linux_perf_tester', |
| 101 'job_name': 'a6298e4afedbf2cd461755ea6f45b0ad64222222-test', |
| 102 'master': 'tryserver.chromium.perf', |
| 103 'type': 'buildbot'} |
| 104 ]} |
| 105 failed_build_test += api.step_data( |
| 106 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 107 stdout=api.json.output(failed_build_test_step_data)) |
| 108 |
| 109 yield failed_build_test |
| 110 |
| 84 basic_data = _get_basic_test_data() | 111 basic_data = _get_basic_test_data() |
| 85 windows_test = _make_test( | 112 windows_test = _make_test( |
| 86 api, basic_data, 'windows_bisector', platform='windows') | 113 api, basic_data, 'windows_bisector', platform='windows') |
| 87 windows_test += api.step_data( | 114 windows_test += api.step_data( |
| 88 'Waiting for revision 314015 and 1 other revision(s). (2)', | 115 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 89 stdout=api.raw_io.output(wait_for_any_output)) | 116 stdout=api.json.output(wait_for_any_output)) |
| 90 | 117 |
| 91 yield windows_test | 118 yield windows_test |
| 92 | 119 |
| 93 basic_data = _get_basic_test_data() | 120 basic_data = _get_basic_test_data() |
| 94 winx64_test = _make_test( | 121 winx64_test = _make_test( |
| 95 api, basic_data, 'windows_x64_bisector', platform='win_x64') | 122 api, basic_data, 'windows_x64_bisector', platform='win_x64') |
| 96 winx64_test += api.step_data( | 123 winx64_test += api.step_data( |
| 97 'Waiting for revision 314015 and 1 other revision(s). (2)', | 124 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 98 stdout=api.raw_io.output(wait_for_any_output)) | 125 stdout=api.json.output(wait_for_any_output)) |
| 99 | 126 |
| 100 yield winx64_test | 127 yield winx64_test |
| 101 | 128 |
| 102 basic_data = _get_basic_test_data() | 129 basic_data = _get_basic_test_data() |
| 103 mac_test = _make_test(api, basic_data, 'mac_bisector', platform='mac') | 130 mac_test = _make_test(api, basic_data, 'mac_bisector', platform='mac') |
| 104 mac_test += api.step_data( | 131 mac_test += api.step_data( |
| 105 'Waiting for revision 314015 and 1 other revision(s). (2)', | 132 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 106 stdout=api.raw_io.output(wait_for_any_output)) | 133 stdout=api.json.output(wait_for_any_output)) |
| 107 | 134 |
| 108 yield mac_test | 135 yield mac_test |
| 109 | 136 |
| 110 basic_data = _get_basic_test_data() | 137 basic_data = _get_basic_test_data() |
| 111 android_test = _make_test( | 138 android_test = _make_test( |
| 112 api, basic_data, 'android_bisector', platform='android') | 139 api, basic_data, 'android_bisector', platform='android') |
| 113 android_test += api.step_data( | 140 android_test += api.step_data( |
| 114 'Waiting for revision 314015 and 1 other revision(s). (2)', | 141 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 115 stdout=api.raw_io.output(wait_for_any_output)) | 142 stdout=api.json.output(wait_for_any_output)) |
| 116 | 143 |
| 117 yield android_test | 144 yield android_test |
| 118 | 145 |
| 119 basic_data = _get_basic_test_data() | 146 basic_data = _get_basic_test_data() |
| 120 android_arm64_test = _make_test( | 147 android_arm64_test = _make_test( |
| 121 api, basic_data, 'android_arm64_bisector', platform='android_arm64') | 148 api, basic_data, 'android_arm64_bisector', platform='android_arm64') |
| 122 android_arm64_test += api.step_data( | 149 android_arm64_test += api.step_data( |
| 123 'Waiting for revision 314015 and 1 other revision(s). (2)', | 150 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 124 stdout=api.raw_io.output(wait_for_any_output)) | 151 stdout=api.json.output(wait_for_any_output)) |
| 125 | 152 |
| 126 yield android_arm64_test | 153 yield android_arm64_test |
| 127 | 154 |
| 128 failed_data = _get_basic_test_data() | 155 failed_data = _get_basic_test_data() |
| 129 failed_data[0].pop('DEPS') | 156 failed_data[0].pop('DEPS') |
| 130 failed_data[1]['test_results']['results']['error'] = 'Dummy error.' | 157 failed_data[1]['test_results']['results']['error'] = 'Dummy error.' |
| 131 failed_data[1]['test_results']['results'].pop('mean') | 158 failed_data[1]['test_results']['results'].pop('mean') |
| 132 failed_data[1]['test_results']['results'].pop('std_err') | 159 failed_data[1]['test_results']['results'].pop('std_err') |
| 133 failed_data[1].pop('DEPS_change') | 160 failed_data[1].pop('DEPS_change') |
| 134 failed_data[1].pop('DEPS') | 161 failed_data[1].pop('DEPS') |
| (...skipping 24 matching lines...) Expand all Loading... |
| 159 | 186 |
| 160 bad_deps_syntax_data = _get_basic_test_data() | 187 bad_deps_syntax_data = _get_basic_test_data() |
| 161 bad_deps_syntax_data[1]['DEPS']='raise RuntimeError("")' | 188 bad_deps_syntax_data[1]['DEPS']='raise RuntimeError("")' |
| 162 yield _make_test(api, bad_deps_syntax_data, 'bad_deps_syntax') | 189 yield _make_test(api, bad_deps_syntax_data, 'bad_deps_syntax') |
| 163 | 190 |
| 164 | 191 |
| 165 basic__data = _get_basic_test_data() | 192 basic__data = _get_basic_test_data() |
| 166 bisect_script_test = _make_test(api, basic_data, 'basic_bisect_script') | 193 bisect_script_test = _make_test(api, basic_data, 'basic_bisect_script') |
| 167 bisect_script_test += api.step_data( | 194 bisect_script_test += api.step_data( |
| 168 'Waiting for revision 314015 and 1 other revision(s). (2)', | 195 'Waiting for revision 314015 and 1 other revision(s). (2)', |
| 169 stdout=api.raw_io.output(wait_for_any_output)) | 196 stdout=api.json.output(wait_for_any_output)) |
| 170 | 197 |
| 171 bisect_script_test += api.properties(mastername='tryserver.chromium.perf', | 198 bisect_script_test += api.properties(mastername='tryserver.chromium.perf', |
| 172 buildername='linux_perf_bisect', | 199 buildername='linux_perf_bisect', |
| 173 slavename='dummyslave') | 200 slavename='dummyslave') |
| 174 yield bisect_script_test | 201 yield bisect_script_test |
| 175 | 202 |
| 176 | 203 |
| 204 def _get_ref_range_only_test_data(): |
| 205 return [ |
| 206 { |
| 207 'refrange': True, |
| 208 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', |
| 209 'commit_pos': '314015', |
| 210 }, |
| 211 { |
| 212 'refrange': True, |
| 213 'hash': '00316c9ddfb9d7b4e1ed2fff9fe6d964d2111111', |
| 214 'commit_pos': '314017', |
| 215 'test_results': { |
| 216 'results':{ |
| 217 'mean': 15, |
| 218 'std_err': 1, |
| 219 'values': [14, 15, 16], |
| 220 }, |
| 221 'retcodes': [0], |
| 222 } |
| 223 }, |
| 224 ] |
| 225 |
| 226 |
| 177 def _get_basic_test_data(): | 227 def _get_basic_test_data(): |
| 178 return [ | 228 return [ |
| 179 { | 229 { |
| 180 'refrange': True, | 230 'refrange': True, |
| 181 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', | 231 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', |
| 182 'commit_pos': '314015', | 232 'commit_pos': '314015', |
| 183 'test_results': { | 233 'test_results': { |
| 184 'results':{ | 234 'results':{ |
| 185 'mean': 20, | 235 'mean': 20, |
| 186 'std_err': 1, | 236 'std_err': 1, |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 'recipe_tester_name': 'linux_perf_tester' | 409 'recipe_tester_name': 'linux_perf_tester' |
| 360 } | 410 } |
| 361 example_config.update(params) | 411 example_config.update(params) |
| 362 return example_config | 412 return example_config |
| 363 | 413 |
| 364 | 414 |
| 365 def _get_step_data_for_revision(api, revision_data, include_build_steps=True): | 415 def _get_step_data_for_revision(api, revision_data, include_build_steps=True): |
| 366 """Generator that produces step patches for fake results.""" | 416 """Generator that produces step patches for fake results.""" |
| 367 commit_pos = revision_data['commit_pos'] | 417 commit_pos = revision_data['commit_pos'] |
| 368 commit_hash = revision_data['hash'] | 418 commit_hash = revision_data['hash'] |
| 369 test_results = revision_data['test_results'] | 419 test_results = revision_data.get('test_results') |
| 370 | 420 |
| 371 if 'refrange' in revision_data: | 421 if 'refrange' in revision_data: |
| 372 parent_step = 'Resolving reference range.' | 422 parent_step = 'Resolving reference range.' |
| 373 else: | 423 else: |
| 374 parent_step = 'Expanding revision range.' | 424 parent_step = 'Expanding revision range.' |
| 375 step_name = parent_step + 'resolving commit_pos ' + commit_pos | 425 step_name = parent_step + 'resolving commit_pos ' + commit_pos |
| 376 yield api.step_data(step_name, stdout=api.raw_io.output('hash:' + | 426 yield api.step_data(step_name, stdout=api.raw_io.output('hash:' + |
| 377 commit_hash)) | 427 commit_hash)) |
| 378 | 428 |
| 379 step_name = parent_step + 'resolving hash ' + commit_hash | 429 step_name = parent_step + 'resolving hash ' + commit_hash |
| 380 commit_pos_str = 'refs/heads/master@{#%s}' % commit_pos | 430 commit_pos_str = 'refs/heads/master@{#%s}' % commit_pos |
| 381 yield api.step_data(step_name, stdout=api.raw_io.output(commit_pos_str)) | 431 yield api.step_data(step_name, stdout=api.raw_io.output(commit_pos_str)) |
| 382 | 432 |
| 383 if include_build_steps: | 433 if include_build_steps: |
| 384 step_name = 'gsutil Get test results for build ' + commit_hash | 434 if test_results: |
| 385 yield api.step_data(step_name, stdout=api.raw_io.output(json.dumps( | 435 step_name = 'gsutil Get test results for build ' + commit_hash |
| 386 test_results))) | 436 yield api.step_data(step_name, stdout=api.json.output(test_results)) |
| 387 | 437 |
| 388 if revision_data.get('DEPS', False): | 438 if revision_data.get('DEPS', False): |
| 389 step_name = 'git cat-file %s:DEPS' % commit_hash | 439 step_name = 'git cat-file %s:DEPS' % commit_hash |
| 390 yield api.step_data(step_name, stdout=api.raw_io.output( | 440 yield api.step_data(step_name, stdout=api.raw_io.output( |
| 391 revision_data['DEPS'])) | 441 revision_data['DEPS'])) |
| 392 | 442 |
| 393 if 'git_diff' in revision_data: | 443 if 'git_diff' in revision_data: |
| 394 for deps_rev, diff_file in revision_data['git_diff'].iteritems(): | 444 for deps_rev, diff_file in revision_data['git_diff'].iteritems(): |
| 395 step_name = 'Generating patch for %s:DEPS to %s' | 445 step_name = 'Generating patch for %s:DEPS to %s' |
| 396 step_name %= (commit_hash, deps_rev) | 446 step_name %= (commit_hash, deps_rev) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 411 step_name = 'Expanding revision range for revision %s on depot %s' | 461 step_name = 'Expanding revision range for revision %s on depot %s' |
| 412 step_name %= (interval[0], depot_name) | 462 step_name %= (interval[0], depot_name) |
| 413 stdout = api.raw_io.output('\n'.join(interval)) | 463 stdout = api.raw_io.output('\n'.join(interval)) |
| 414 yield api.step_data(step_name, stdout=stdout) | 464 yield api.step_data(step_name, stdout=stdout) |
| 415 | 465 |
| 416 if 'cl_info' in revision_data: | 466 if 'cl_info' in revision_data: |
| 417 step_name = 'Reading culprit cl information.' | 467 step_name = 'Reading culprit cl information.' |
| 418 stdout = api.raw_io.output(revision_data['cl_info']) | 468 stdout = api.raw_io.output(revision_data['cl_info']) |
| 419 yield api.step_data(step_name, stdout=stdout) | 469 yield api.step_data(step_name, stdout=stdout) |
| 420 | 470 |
| OLD | NEW |