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 'recipe_engine/json', | 9 'recipe_engine/json', |
10 'recipe_engine/path', | 10 'recipe_engine/path', |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 dummy_mode=True) | 63 dummy_mode=True) |
64 # Load the simulated results of a bisect | 64 # Load the simulated results of a bisect |
65 dummy_bisector_attributes = dict(api.properties['dummy_bisector_attributes']) | 65 dummy_bisector_attributes = dict(api.properties['dummy_bisector_attributes']) |
66 | 66 |
67 # Simulate the side-effects of a bisect by setting the bisector attributes | 67 # Simulate the side-effects of a bisect by setting the bisector attributes |
68 # directly. | 68 # directly. |
69 if dummy_bisector_attributes.pop('culprit_present'): | 69 if dummy_bisector_attributes.pop('culprit_present'): |
70 bisector.culprit = bisector.bad_rev | 70 bisector.culprit = bisector.bad_rev |
71 set_attributes(bisector, dummy_bisector_attributes) | 71 set_attributes(bisector, dummy_bisector_attributes) |
72 | 72 |
73 bisector.print_result() | 73 bisector.post_result() |
| 74 |
74 | 75 |
75 def set_attributes(target, attributes): | 76 def set_attributes(target, attributes): |
76 """Sets values to the attributes of an object based on a dict. | 77 """Sets values to the attributes of an object based on a dict. |
77 | 78 |
78 This goes one extra level deep so as to set an attribute's attribute: | 79 This goes one extra level deep so as to set an attribute's attribute: |
79 e.g.: set_attributes(some_object, {'some_attribute': 1, | 80 e.g.: set_attributes(some_object, {'some_attribute': 1, |
80 'other_attribute.nested_val': False}) | 81 'other_attribute.nested_val': False}) |
81 """ | 82 """ |
82 for k, v in attributes.iteritems(): | 83 for k, v in attributes.iteritems(): |
83 if '.' in k: | 84 if '.' in k: |
84 sub_target = getattr(target, k.split('.')[0]) | 85 sub_target = getattr(target, k.split('.')[0]) |
85 setattr(sub_target, k.split('.')[1], v) | 86 setattr(sub_target, k.split('.')[1], v) |
86 else: | 87 else: |
87 setattr(target, k, v) | 88 setattr(target, k, v) |
88 | 89 |
| 90 |
89 def add_revision_mapping(api, test, pos, sha): | 91 def add_revision_mapping(api, test, pos, sha): |
90 step_name = 'Resolving reference range.resolving commit_pos ' + pos | 92 step_name = 'Resolving reference range.resolving commit_pos ' + pos |
91 stdout = api.raw_io.output('hash:' + sha) | 93 stdout = api.raw_io.output('hash:' + sha) |
92 test += api.step_data(step_name, stdout=stdout) | 94 test += api.step_data(step_name, stdout=stdout) |
93 step_name = 'Resolving reference range.resolving hash ' + sha | 95 step_name = 'Resolving reference range.resolving hash ' + sha |
94 pos = 'refs/heads/master@{#%s}' % pos | 96 pos = 'refs/heads/master@{#%s}' % pos |
95 stdout = api.raw_io.output(pos) | 97 stdout = api.raw_io.output(pos) |
96 test += api.step_data(step_name, stdout=stdout) | 98 test += api.step_data(step_name, stdout=stdout) |
97 return test | 99 return test |
98 | 100 |
| 101 |
99 def add_revision_info(api, test): | 102 def add_revision_info(api, test): |
100 step_name = 'Reading culprit cl information.' | 103 step_name = 'Reading culprit cl information.' |
101 rev_info = { | 104 rev_info = { |
102 'author': 'DummyAuthor', | 105 'author': 'DummyAuthor', |
103 'email': 'dummy@nowhere.com', | 106 'email': 'dummy@nowhere.com', |
104 'subject': 'Some random CL', | 107 'subject': 'Some random CL', |
105 'date': '01/01/2015', | 108 'date': '01/01/2015', |
106 'body': ('A long description for a CL.\n' | 109 'body': ('A long description for a CL.\n' |
107 'Containing multiple lines'), | 110 'Containing multiple lines'), |
108 } | 111 } |
109 return test + api.step_data(step_name, stdout=api.json.output(rev_info)) | 112 return test + api.step_data(step_name, stdout=api.json.output(rev_info)) |
110 | 113 |
| 114 |
| 115 def get_post_bisect_step_data(api, test): |
| 116 """Gets step data for perf_dashboard/resource/post_json.py.""" |
| 117 response = {'status_code': 200} |
| 118 return test + api.step_data('Post bisect results', |
| 119 stdout=api.json.output(response)) |
| 120 |
| 121 |
111 def GenTests(api): | 122 def GenTests(api): |
112 basic_test = api.test('basic_test') | 123 basic_test = api.test('basic_test') |
| 124 basic_test = get_post_bisect_step_data(api, basic_test) |
113 basic_test = add_revision_mapping(api, basic_test, '314015', 'c001c0de') | 125 basic_test = add_revision_mapping(api, basic_test, '314015', 'c001c0de') |
114 basic_test = add_revision_mapping(api, basic_test, '314017', 'deadbeef') | 126 basic_test = add_revision_mapping(api, basic_test, '314017', 'deadbeef') |
115 basic_test = add_revision_info(api, basic_test) | 127 basic_test = add_revision_info(api, basic_test) |
116 basic_test += api.properties( | 128 basic_test += api.properties( |
117 bisect_config = BASIC_CONFIG, | 129 bisect_config = BASIC_CONFIG, |
118 dummy_bisector_attributes = BASIC_ATTRIBUTES) | 130 dummy_bisector_attributes = BASIC_ATTRIBUTES) |
119 yield basic_test | 131 yield basic_test |
120 | 132 |
121 deps_culprit_test = api.test('deps_culprit_test') | 133 deps_culprit_test = api.test('deps_culprit_test') |
| 134 deps_culprit_test = get_post_bisect_step_data(api, deps_culprit_test) |
122 deps_culprit_test = add_revision_mapping( | 135 deps_culprit_test = add_revision_mapping( |
123 api, deps_culprit_test, '314015', 'c001c0de') | 136 api, deps_culprit_test, '314015', 'c001c0de') |
124 deps_culprit_test = add_revision_mapping( | 137 deps_culprit_test = add_revision_mapping( |
125 api, deps_culprit_test, '314017', 'deadbeef') | 138 api, deps_culprit_test, '314017', 'deadbeef') |
126 deps_culprit_test = add_revision_info(api, deps_culprit_test) | 139 deps_culprit_test = add_revision_info(api, deps_culprit_test) |
127 deps_culprit_test += api.properties( | 140 deps_culprit_test += api.properties( |
128 bisect_config = BASIC_CONFIG, | 141 bisect_config = BASIC_CONFIG, |
129 dummy_bisector_attributes = DEPS_CULPRIT_ATTRIBUTES) | 142 dummy_bisector_attributes = DEPS_CULPRIT_ATTRIBUTES) |
130 yield deps_culprit_test | 143 yield deps_culprit_test |
131 | 144 |
132 failed_test = api.test('failed_test') | 145 failed_test = api.test('failed_test') |
| 146 failed_test = get_post_bisect_step_data(api, failed_test) |
133 failed_test = add_revision_mapping(api, failed_test, '314015', 'c001c0de') | 147 failed_test = add_revision_mapping(api, failed_test, '314015', 'c001c0de') |
134 failed_test = add_revision_mapping(api, failed_test, '314017', 'deadbeef') | 148 failed_test = add_revision_mapping(api, failed_test, '314017', 'deadbeef') |
135 failed_test += api.properties( | 149 failed_test += api.properties( |
136 bisect_config = BASIC_CONFIG, | 150 bisect_config = BASIC_CONFIG, |
137 dummy_bisector_attributes = FAILED_ATTRIBUTES) | 151 dummy_bisector_attributes = FAILED_ATTRIBUTES) |
138 yield failed_test | 152 yield failed_test |
139 | 153 |
140 failed_direction_test = api.test('failed_direction_test') | 154 failed_direction_test = api.test('failed_direction_test') |
| 155 failed_direction_test = get_post_bisect_step_data(api, |
| 156 failed_direction_test) |
141 failed_direction_test = add_revision_mapping(api, failed_direction_test, | 157 failed_direction_test = add_revision_mapping(api, failed_direction_test, |
142 '314015', 'c001c0de') | 158 '314015', 'c001c0de') |
143 failed_direction_test = add_revision_mapping(api, failed_direction_test, | 159 failed_direction_test = add_revision_mapping(api, failed_direction_test, |
144 '314017', 'deadbeef') | 160 '314017', 'deadbeef') |
145 failed_direction_test += api.properties( | 161 failed_direction_test += api.properties( |
146 bisect_config = BASIC_CONFIG, | 162 bisect_config = BASIC_CONFIG, |
147 dummy_bisector_attributes = FAILED_DIRECTION_ATTRIBUTES) | 163 dummy_bisector_attributes = FAILED_DIRECTION_ATTRIBUTES) |
148 yield failed_direction_test | 164 yield failed_direction_test |
149 | 165 |
150 aborted_bisect_test = api.test('aborted_non_telemetry_test') | 166 aborted_bisect_test = api.test('aborted_non_telemetry_test') |
| 167 aborted_bisect_test = get_post_bisect_step_data(api, aborted_bisect_test) |
151 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314015', | 168 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314015', |
152 'c001c0de') | 169 'c001c0de') |
153 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314017', | 170 aborted_bisect_test = add_revision_mapping(api, aborted_bisect_test, '314017', |
154 'deadbeef') | 171 'deadbeef') |
155 aborted_bisect_test += api.properties( | 172 aborted_bisect_test += api.properties( |
156 bisect_config = NON_TELEMETRY_TEST_CONFIG, | 173 bisect_config = NON_TELEMETRY_TEST_CONFIG, |
157 dummy_bisector_attributes = ABORTED_BISECT_ATTRIBUTES) | 174 dummy_bisector_attributes = ABORTED_BISECT_ATTRIBUTES) |
158 yield aborted_bisect_test | 175 yield aborted_bisect_test |
159 | |
OLD | NEW |