| 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 """This example file is meant to provide coverage to bisect_results.""" | 5 """This example file is meant to provide coverage to bisect_results.""" |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'auto_bisect', | 8 'auto_bisect', |
| 9 'gsutil', |
| 9 'recipe_engine/json', | 10 'recipe_engine/json', |
| 10 'recipe_engine/path', | 11 'recipe_engine/path', |
| 11 'recipe_engine/properties', | 12 'recipe_engine/properties', |
| 12 'recipe_engine/raw_io', | 13 'recipe_engine/raw_io', |
| 13 ] | 14 ] |
| 14 | 15 |
| 15 BASIC_CONFIG = { | 16 BASIC_CONFIG = { |
| 16 'test_type': 'perf', | 17 'test_type': 'perf', |
| 17 'command': | 18 'command': |
| 18 ('src/tools/perf/run_benchmark -v --browser=release smoothness.' | 19 ('src/tools/perf/run_benchmark -v --browser=release smoothness.' |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 FAILED_DIRECTION_ATTRIBUTES = dict(BASIC_ATTRIBUTES) | 52 FAILED_DIRECTION_ATTRIBUTES = dict(BASIC_ATTRIBUTES) |
| 52 FAILED_DIRECTION_ATTRIBUTES['failed_direction'] = True | 53 FAILED_DIRECTION_ATTRIBUTES['failed_direction'] = True |
| 53 FAILED_DIRECTION_ATTRIBUTES['culprit_present'] = False | 54 FAILED_DIRECTION_ATTRIBUTES['culprit_present'] = False |
| 54 | 55 |
| 55 ABORTED_BISECT_ATTRIBUTES = dict(BASIC_ATTRIBUTES) | 56 ABORTED_BISECT_ATTRIBUTES = dict(BASIC_ATTRIBUTES) |
| 56 ABORTED_BISECT_ATTRIBUTES['failed_initial_confidence'] = True | 57 ABORTED_BISECT_ATTRIBUTES['failed_initial_confidence'] = True |
| 57 ABORTED_BISECT_ATTRIBUTES['culprit_present'] = False | 58 ABORTED_BISECT_ATTRIBUTES['culprit_present'] = False |
| 58 | 59 |
| 59 | 60 |
| 60 def RunSteps(api): | 61 def RunSteps(api): |
| 62 # For coverage only |
| 63 api.gsutil.cat('gs://fakebucket/fake/path/fake_file.txt') |
| 64 |
| 61 api.path['checkout'] = api.path.mkdtemp('bogus') | 65 api.path['checkout'] = api.path.mkdtemp('bogus') |
| 62 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config'], | 66 bisector = api.auto_bisect.create_bisector(api.properties['bisect_config'], |
| 63 dummy_mode=True) | 67 dummy_mode=True) |
| 64 # Load the simulated results of a bisect | 68 # Load the simulated results of a bisect |
| 65 dummy_bisector_attributes = dict(api.properties['dummy_bisector_attributes']) | 69 dummy_bisector_attributes = dict(api.properties['dummy_bisector_attributes']) |
| 66 | 70 |
| 67 # Simulate the side-effects of a bisect by setting the bisector attributes | 71 # Simulate the side-effects of a bisect by setting the bisector attributes |
| 68 # directly. | 72 # directly. |
| 69 if dummy_bisector_attributes.pop('culprit_present'): | 73 if dummy_bisector_attributes.pop('culprit_present'): |
| 70 bisector.culprit = bisector.bad_rev | 74 bisector.culprit = bisector.bad_rev |
| (...skipping 10 matching lines...) Expand all Loading... |
| 81 'other_attribute.nested_val': False}) | 85 'other_attribute.nested_val': False}) |
| 82 """ | 86 """ |
| 83 for k, v in attributes.iteritems(): | 87 for k, v in attributes.iteritems(): |
| 84 if '.' in k: | 88 if '.' in k: |
| 85 sub_target = getattr(target, k.split('.')[0]) | 89 sub_target = getattr(target, k.split('.')[0]) |
| 86 setattr(sub_target, k.split('.')[1], v) | 90 setattr(sub_target, k.split('.')[1], v) |
| 87 else: | 91 else: |
| 88 setattr(target, k, v) | 92 setattr(target, k, v) |
| 89 | 93 |
| 90 | 94 |
| 91 def add_revision_mapping(api, test, pos, sha): | |
| 92 step_name = ('Resolving reference range.crrev get commit hash for ' + | |
| 93 'refs/heads/master@{#%s}' % pos) | |
| 94 stdout = api.json.output({'git_sha': sha}) | |
| 95 test += api.step_data(step_name, stdout=stdout) | |
| 96 | |
| 97 step_name = 'Resolving reference range.resolving hash ' + sha | |
| 98 pos = 'refs/heads/master@{#%s}' % pos | |
| 99 stdout = api.raw_io.output(pos) | |
| 100 return test | |
| 101 | |
| 102 | |
| 103 def add_revision_info(api, test): | 95 def add_revision_info(api, test): |
| 104 step_name = 'Reading culprit cl information.' | 96 step_name = 'Reading culprit cl information.' |
| 105 rev_info = { | 97 rev_info = { |
| 106 'author': 'DummyAuthor', | 98 'author': 'DummyAuthor', |
| 107 'email': 'dummy@nowhere.com', | 99 'email': 'dummy@nowhere.com', |
| 108 'subject': 'Some random CL', | 100 'subject': 'Some random CL', |
| 109 'date': '01/01/2015', | 101 'date': '01/01/2015', |
| 110 'body': ('A long description for a CL.\n' | 102 'body': ('A long description for a CL.\n' |
| 111 'Containing multiple lines'), | 103 'Containing multiple lines'), |
| 112 } | 104 } |
| 113 return test + api.step_data(step_name, stdout=api.json.output(rev_info)) | 105 return test + api.step_data(step_name, stdout=api.json.output(rev_info)) |
| 114 | 106 |
| 115 | 107 |
| 116 def get_post_bisect_step_data(api, test): | 108 def get_post_bisect_step_data(api, test): |
| 117 """Gets step data for perf_dashboard/resource/post_json.py.""" | 109 """Gets step data for perf_dashboard/resource/post_json.py.""" |
| 118 response = {'status_code': 200} | 110 response = {'status_code': 200} |
| 119 return test + api.step_data('Post bisect results', | 111 return test + api.step_data('Post bisect results', |
| 120 stdout=api.json.output(response)) | 112 stdout=api.json.output(response)) |
| 121 | 113 |
| 122 | 114 |
| 123 def GenTests(api): | 115 def GenTests(api): |
| 124 basic_test = api.test('basic_test') | 116 basic_test = api.test('basic_test') |
| 125 basic_test = get_post_bisect_step_data(api, basic_test) | 117 basic_test = get_post_bisect_step_data(api, basic_test) |
| 126 basic_test = add_revision_mapping(api, basic_test, '314015', 'c001c0de') | |
| 127 basic_test = add_revision_mapping(api, basic_test, '314017', 'deadbeef') | |
| 128 basic_test = add_revision_info(api, basic_test) | 118 basic_test = add_revision_info(api, basic_test) |
| 129 basic_test += api.properties( | 119 basic_test += api.properties( |
| 130 bisect_config = BASIC_CONFIG, | 120 bisect_config = BASIC_CONFIG, |
| 131 dummy_bisector_attributes = BASIC_ATTRIBUTES) | 121 dummy_bisector_attributes = BASIC_ATTRIBUTES) |
| 122 basic_test += api.auto_bisect([ |
| 123 {'hash': 'c001c0de', 'commit_pos': '314015'}, |
| 124 {'hash': 'deadc0de', 'commit_pos': '314016'}, |
| 125 {'hash': 'deadbeef', 'commit_pos': '314017'}, |
| 126 ]) |
| 132 yield basic_test | 127 yield basic_test |
| 133 | 128 |
| 134 deps_culprit_test = api.test('deps_culprit_test') | 129 deps_culprit_test = api.test('deps_culprit_test') |
| 135 deps_culprit_test = get_post_bisect_step_data(api, deps_culprit_test) | 130 deps_culprit_test = get_post_bisect_step_data(api, deps_culprit_test) |
| 136 deps_culprit_test = add_revision_mapping( | |
| 137 api, deps_culprit_test, '314015', 'c001c0de') | |
| 138 deps_culprit_test = add_revision_mapping( | |
| 139 api, deps_culprit_test, '314017', 'deadbeef') | |
| 140 deps_culprit_test = add_revision_info(api, deps_culprit_test) | 131 deps_culprit_test = add_revision_info(api, deps_culprit_test) |
| 141 deps_culprit_test += api.properties( | 132 deps_culprit_test += api.properties( |
| 142 bisect_config = BASIC_CONFIG, | 133 bisect_config = BASIC_CONFIG, |
| 143 dummy_bisector_attributes = DEPS_CULPRIT_ATTRIBUTES) | 134 dummy_bisector_attributes = DEPS_CULPRIT_ATTRIBUTES) |
| 135 deps_culprit_test += api.auto_bisect([ |
| 136 {'hash': 'c001c0de', 'commit_pos': '314015'}, |
| 137 {'hash': 'deadc0de', 'commit_pos': '314016'}, |
| 138 {'hash': 'deadbeef', 'commit_pos': '314017'}, |
| 139 ]) |
| 144 yield deps_culprit_test | 140 yield deps_culprit_test |
| 145 | 141 |
| 146 failed_test = api.test('failed_test') | 142 failed_test = api.test('failed_test') |
| 147 failed_test = get_post_bisect_step_data(api, failed_test) | 143 failed_test = get_post_bisect_step_data(api, failed_test) |
| 148 failed_test = add_revision_mapping(api, failed_test, '314015', 'c001c0de') | |
| 149 failed_test = add_revision_mapping(api, failed_test, '314017', 'deadbeef') | |
| 150 failed_test += api.properties( | 144 failed_test += api.properties( |
| 151 bisect_config = BASIC_CONFIG, | 145 bisect_config = BASIC_CONFIG, |
| 152 dummy_bisector_attributes = FAILED_ATTRIBUTES) | 146 dummy_bisector_attributes = FAILED_ATTRIBUTES) |
| 147 failed_test += api.auto_bisect([ |
| 148 {'hash': 'c001c0de', 'commit_pos': '314015'}, |
| 149 {'hash': 'deadc0de', 'commit_pos': '314016'}, |
| 150 {'hash': 'deadbeef', 'commit_pos': '314017'}, |
| 151 ]) |
| 153 yield failed_test | 152 yield failed_test |
| 154 | 153 |
| 155 failed_direction_test = api.test('failed_direction_test') | 154 failed_direction_test = api.test('failed_direction_test') |
| 156 failed_direction_test = get_post_bisect_step_data(api, | 155 failed_direction_test = get_post_bisect_step_data( |
| 157 failed_direction_test) | 156 api, failed_direction_test) |
| 158 failed_direction_test = add_revision_mapping(api, failed_direction_test, | |
| 159 '314015', 'c001c0de') | |
| 160 failed_direction_test = add_revision_mapping(api, failed_direction_test, | |
| 161 '314017', 'deadbeef') | |
| 162 failed_direction_test += api.properties( | 157 failed_direction_test += api.properties( |
| 163 bisect_config = BASIC_CONFIG, | 158 bisect_config = BASIC_CONFIG, |
| 164 dummy_bisector_attributes = FAILED_DIRECTION_ATTRIBUTES) | 159 dummy_bisector_attributes = FAILED_DIRECTION_ATTRIBUTES) |
| 160 failed_direction_test += api.auto_bisect([ |
| 161 {'hash': 'c001c0de', 'commit_pos': '314015'}, |
| 162 {'hash': 'deadc0de', 'commit_pos': '314016'}, |
| 163 {'hash': 'deadbeef', 'commit_pos': '314017'}, |
| 164 ]) |
| 165 yield failed_direction_test | 165 yield failed_direction_test |
| 166 | 166 |
| 167 aborted_bisect_test = api.test('aborted_non_telemetry_test') | 167 aborted_bisect_test = api.test('aborted_non_telemetry_test') |
| 168 aborted_bisect_test = get_post_bisect_step_data(api, aborted_bisect_test) | 168 aborted_bisect_test = get_post_bisect_step_data(api, aborted_bisect_test) |
| 169 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314015', | |
| 170 'c001c0de') | |
| 171 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314017', | |
| 172 'deadbeef') | |
| 173 aborted_bisect_test += api.properties( | 169 aborted_bisect_test += api.properties( |
| 174 bisect_config = NON_TELEMETRY_TEST_CONFIG, | 170 bisect_config = NON_TELEMETRY_TEST_CONFIG, |
| 175 dummy_bisector_attributes = ABORTED_BISECT_ATTRIBUTES) | 171 dummy_bisector_attributes = ABORTED_BISECT_ATTRIBUTES) |
| 172 aborted_bisect_test += api.auto_bisect([ |
| 173 {'hash': 'c001c0de', 'commit_pos': '314015'}, |
| 174 {'hash': 'deadc0de', 'commit_pos': '314016'}, |
| 175 {'hash': 'deadbeef', 'commit_pos': '314017'}, |
| 176 ]) |
| 176 yield aborted_bisect_test | 177 yield aborted_bisect_test |
| OLD | NEW |