Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: scripts/slave/recipe_modules/auto_bisect/local_bisect.py

Issue 2247373002: Refactor stages 1, 2 and test_api overhaul. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 base64 5 import base64
6 import collections 6 import collections
7 import json 7 import json
8 8
9 9
10 def perform_bisect(api, **flags): 10 def perform_bisect(api, **flags):
(...skipping 17 matching lines...) Expand all
28 except api.m.step.StepFailure: 28 except api.m.step.StepFailure:
29 # Redo the bisect job if target platform is android and bisect 29 # Redo the bisect job if target platform is android and bisect
30 # failed because the test device disconnected 30 # failed because the test device disconnected
31 current_connected_devices = _get_connected_devices(api) 31 current_connected_devices = _get_connected_devices(api)
32 if (api.m.bisect_tester.device_to_test not in 32 if (api.m.bisect_tester.device_to_test not in
33 current_connected_devices): 33 current_connected_devices):
34 continue 34 continue
35 else: 35 else:
36 raise 36 raise
37 except: # pylint: disable=bare-except 37 except: # pylint: disable=bare-except
38 raise
RobertoCN 2016/08/23 00:26:23 Remove?
RobertoCN 2016/09/07 00:33:24 Done.
38 if bisect_attempts: 39 if bisect_attempts:
39 bisect_attempts[-1].post_result(halt_on_failure=True) 40 bisect_attempts[-1].post_result(halt_on_failure=True)
40 raise 41 raise
41 42
42 def _perform_single_bisect(api, bisect_attempts, **flags): 43 def _perform_single_bisect(api, bisect_attempts, **flags):
43 bisect_config = dict(api.m.properties.get('bisect_config')) 44 bisect_config = dict(api.m.properties.get('bisect_config'))
44 if bisect_attempts: 45 if bisect_attempts:
45 bisect_config['good_revision'] = bisect_attempts[-1].lkgr.commit_hash 46 bisect_config['good_revision'] = bisect_attempts[-1].lkgr.commit_hash
46 bisect_config['bad_revision'] = bisect_attempts[-1].fkbr.commit_hash 47 bisect_config['bad_revision'] = bisect_attempts[-1].fkbr.commit_hash
47 bisector = api.create_bisector(bisect_config, **flags) 48 bisector = api.create_bisector(bisect_config, **flags)
48 bisect_attempts.append(bisector) 49 bisect_attempts.append(bisector)
49 with api.m.step.nest('Gathering reference values'): 50 with api.m.step.nest('Gathering reference values'):
50 _gather_reference_range(api, bisector) 51 _gather_reference_range(api, bisector)
51 if (not bisector.failed and bisector.check_improvement_direction() and 52 if (not bisector.failed and bisector.check_improvement_direction() and
52 bisector.check_initial_confidence()): 53 bisector.check_initial_confidence()):
54 bisector.compute_relative_change()
53 if bisector.check_reach_adjacent_revision( 55 if bisector.check_reach_adjacent_revision(
54 bisector.good_rev): # pragma: no cover 56 bisector.good_rev): # pragma: no cover
55 # Only show this step if bisect has reached adjacent revisions. 57 # Only show this step if bisect has reached adjacent revisions.
56 with api.m.step.nest(str('Check bisect finished on revision ' + 58 with api.m.step.nest(str('Check bisect finished on revision ' +
57 bisector.good_rev.revision_string())): 59 bisector.good_rev.revision_string())):
58 if bisector.check_bisect_finished(bisector.good_rev): 60 if bisector.check_bisect_finished(bisector.good_rev):
59 bisector.bisect_over = True 61 bisector.bisect_over = True
60 if not bisector.bisect_over: 62 if not bisector.bisect_over:
61 _bisect_main_loop(bisector) 63 _bisect_main_loop(bisector)
62 else: 64 else:
63 bisector.bisect_over = True 65 bisector.bisect_over = True
64 bisector.print_result_debug_info() 66 bisector.print_result_debug_info()
65 bisector.post_result(halt_on_failure=True) 67 bisector.post_result(halt_on_failure=True)
66 68
67 def _get_connected_devices(api): 69 def _get_connected_devices(api):
68 api.m.chromium_android.device_status() 70 api.m.chromium_android.device_status()
69 return api.m.chromium_android.devices 71 return api.m.chromium_android.devices
70 72
71 def _gather_reference_range(api, bisector): # pragma: no cover 73 def _gather_reference_range(api, bisector): # pragma: no cover
72 bisector.good_rev.start_job() 74 bisector.good_rev.start_job()
73 bisector.bad_rev.start_job() 75 bisector.bad_rev.start_job()
74 bisector.wait_for_all([bisector.good_rev, bisector.bad_rev])
75 if bisector.good_rev.failed: 76 if bisector.good_rev.failed:
76 bisector.surface_result('REF_RANGE_FAIL') 77 bisector.surface_result('REF_RANGE_FAIL')
77 api.m.halt('Testing the "good" revision failed') 78 api.m.halt('Testing the "good" revision failed')
78 bisector.failed = True 79 bisector.failed = True
79 elif bisector.bad_rev.failed: 80 elif bisector.bad_rev.failed:
80 bisector.surface_result('REF_RANGE_FAIL') 81 bisector.surface_result('REF_RANGE_FAIL')
81 api.m.halt('Testing the "bad" revision failed') 82 api.m.halt('Testing the "bad" revision failed')
82 bisector.failed = True 83 bisector.failed = True
83 api.m.halt('Testing the "good" revision failed') 84 api.m.halt('Testing the "good" revision failed')
84 else:
85 bisector.compute_relative_change()
86
87 85
88 def _bisect_main_loop(bisector): # pragma: no cover 86 def _bisect_main_loop(bisector): # pragma: no cover
89 """This is the main bisect loop. 87 """This is the main bisect loop.
90 88
91 It gets an evenly distributed number of revisions in the candidate range, 89 It gets an evenly distributed number of revisions in the candidate range,
92 then it starts them in parallel and waits for them to finish. 90 then it starts them in parallel and waits for them to finish.
93 """ 91 """
94 while not bisector.bisect_over: 92 while not bisector.bisect_over:
95 revision_to_check = bisector.get_revision_to_eval() 93 revision_to_check = bisector.get_revision_to_eval()
96 if not revision_to_check: 94 if not revision_to_check:
97 bisector.bisect_over = True 95 bisector.bisect_over = True
98 break 96 break
99 97
100 with bisector.api.m.step.nest(str('Working on revision ' + 98 with bisector.api.m.step.nest(str('Working on revision ' +
101 revision_to_check.revision_string())): 99 revision_to_check.revision_string())):
102 bisector.post_result(halt_on_failure=False) 100 bisector.post_result(halt_on_failure=False)
103 revision_to_check.start_job() 101 revision_to_check.start_job()
104 bisector.wait_for(revision_to_check)
105 102
106 if bisector.check_reach_adjacent_revision(revision_to_check): 103 if bisector.check_reach_adjacent_revision(revision_to_check):
107 # Only show this step if bisect has reached adjacent revisions. 104 # Only show this step if bisect has reached adjacent revisions.
108 with bisector.api.m.step.nest( 105 with bisector.api.m.step.nest(
109 str('Check bisect finished on revision ' + 106 str('Check bisect finished on revision ' +
110 revision_to_check.revision_string())): 107 revision_to_check.revision_string())):
111 if bisector.check_bisect_finished(revision_to_check): 108 if bisector.check_bisect_finished(revision_to_check):
112 bisector.bisect_over = True 109 bisector.bisect_over = True
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698