Chromium Code Reviews| Index: scripts/slave/recipe_modules/auto_bisect/example.py |
| diff --git a/scripts/slave/recipe_modules/auto_bisect/example.py b/scripts/slave/recipe_modules/auto_bisect/example.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a95aea0ea08f5a704e3c6bedc98eb310b438aa3f |
| --- /dev/null |
| +++ b/scripts/slave/recipe_modules/auto_bisect/example.py |
| @@ -0,0 +1,115 @@ |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import json |
| + |
| +DEPS = [ |
| + 'auto_bisect', |
| + 'path', |
| + 'properties', |
| + 'raw_io', |
| +] |
| + |
| + |
| +def GenSteps(api): |
| + # This would ordinarily be done by |
| + # api.chromium_tests.sync_and_configure_build |
|
qyearsley
2015/02/22 20:37:55
# This would ordinarily be done by
# `api.chromium
RobertoCN
2015/02/24 20:01:14
Yes. Changing the comment to make it more clear.
|
| + fake_checkout_path = api.path.mkdtemp('fake_checkout') |
| + api.path['checkout'] = fake_checkout_path |
| + #Create a bisector |
|
qyearsley
2015/02/22 20:37:55
Space after "#".
RobertoCN
2015/02/24 20:01:14
Done.
|
| + bisector = api.auto_bisect.create_bisector(api.properties['bisect_config']) |
| + # Request builds |
| + bisector.good_rev.start_job() |
| + bisector.bad_rev.start_job() |
| + # Wait for builds and tests to finish |
| + bisector.wait_for_all([bisector.good_rev, bisector.bad_rev]) |
| + |
| + # TODO(robertocn): Add examples for the following operations |
| + # Check improvement direction |
| + # Check regression confidence |
| + # Get revisions to check |
| + # Check if bisect is finished |
| + # Abort unnecesary jobs |
| + # Print results |
| + |
| + |
| +def GenTests(api): |
| + yield _basic_test(api) |
| + |
| + |
| +def _basic_test(api): |
| + test_data = [ |
| + { |
| + 'hash': 'a6298e4afedbf2cd461755ea6f45b0ad64222222', |
| + 'commit_pos': '314015', |
|
qyearsley
2015/02/22 20:37:55
Indentation alignment.
RobertoCN
2015/02/24 20:01:14
Done.
|
| + 'test_results': {'results':{ |
| + 'mean': 20, |
| + 'std_err': 1, |
| + 'values': [19, 20, 21], |
| + }} |
| + }, |
| + { |
| + 'hash': '00316c9ddfb9d7b4e1ed2fff9fe6d964d2111111', |
| + 'commit_pos': '314016', |
| + 'test_results': {'results':{ |
| + 'mean': 15, |
| + 'std_err': 1, |
| + 'values': [14, 15, 16], |
| + }} |
| + }, |
| + ] |
|
qyearsley
2015/02/22 20:37:55
Indentation alignment.
RobertoCN
2015/02/24 20:01:14
Done.
|
| + basic_test = api.test('basic') |
| + for revision_data in test_data: |
| + for step_data in _get_step_data_for_revision(api, revision_data): |
| + basic_test += step_data |
| + basic_test += api.properties(bisect_config=_get_default_config()) |
| + return basic_test |
| + |
| + |
| +def _get_default_config(): |
| + example_config = { |
| + 'test_type':'perf', |
| + 'command': |
| + ('src/tools/perf/run_benchmark -v --browser=release smoothness.' |
|
qyearsley
2015/02/22 20:37:55
Indent 4 spaces.
RobertoCN
2015/02/24 20:01:14
Done.
|
| + 'tough_scrolling_cases'), |
| + 'good_revision': '314015', |
| + 'bad_revision': '314016', |
| + 'metric': 'mean_input_event_latency/mean_input_event_latency', |
| + 'repeat_count': '2', |
| + 'max_time_minutes': '5', |
| + 'truncate_percent': '0', |
| + 'bug_id': '', |
| + 'gs_bucket': 'chrome-perf', |
| + 'builder_host': 'master4.golo.chromium.org', |
| + 'builder_port': '8341', |
| + 'dummy_builds': 'True', |
| + } |
| + return example_config |
| + |
| + |
| +def _get_step_data_for_revision(api, revision_data, include_build_steps=True): |
| + """Generator that produces step patches for fake results.""" |
| + commit_pos = revision_data['commit_pos'] |
| + commit_hash = revision_data['hash'] |
| + test_results = revision_data['test_results'] |
| + |
| + step_name ='resolving commit_pos ' + commit_pos |
| + yield api.step_data(step_name, stdout=api.raw_io.output('hash:' + |
| + commit_hash)) |
| + |
| + step_name ='resolving hash ' + commit_hash |
| + commit_pos_str = 'refs/heads/master@{#%s}' % commit_pos |
| + yield api.step_data(step_name, stdout=api.raw_io.output(commit_pos_str)) |
| + |
| + if include_build_steps: |
| + step_name ='gsutil Get test results for build ' + commit_hash |
| + yield api.step_data(step_name, stdout=api.raw_io.output(json.dumps( |
| + test_results))) |
| + |
| + step_name = 'Get test status for build ' + commit_hash |
| + yield api.step_data(step_name, stdout=api.raw_io.output('Complete')) |
| + |
| + step_name ='gsutil Get test status url for build ' + commit_hash |
| + yield api.step_data(step_name, stdout=api.raw_io.output('dummy/url')) |
| + |