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

Side by Side Diff: build/android/pylib/local/device/local_device_instrumentation_test_run.py

Issue 2791613003: [Instrumentation Test Speed] Install apks in parallel with concurrent_adb enabled (Closed)
Patch Set: John comment Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 logging 5 import logging
6 import os 6 import os
7 import posixpath 7 import posixpath
8 import re 8 import re
9 import time 9 import time
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #override 68 #override
69 def TestPackage(self): 69 def TestPackage(self):
70 return self._test_instance.suite 70 return self._test_instance.suite
71 71
72 #override 72 #override
73 def SetUp(self): 73 def SetUp(self):
74 @local_device_environment.handle_shard_failures_with( 74 @local_device_environment.handle_shard_failures_with(
75 self._env.BlacklistDevice) 75 self._env.BlacklistDevice)
76 @trace_event.traced 76 @trace_event.traced
77 def individual_device_set_up(dev, host_device_tuples): 77 def individual_device_set_up(dev, host_device_tuples):
78 def install_apk(): 78 def install_apk():
jbudorick 2017/04/05 16:32:29 This function should no longer exist. We should ju
shenghuazhang 2017/04/05 18:57:05 Done.
79 steps = []
80 def install_helper(apk, permissions):
81 return lambda: dev.Install(apk, permissions=permissions)
79 if self._test_instance.apk_under_test: 82 if self._test_instance.apk_under_test:
80 if self._test_instance.apk_under_test_incremental_install_script: 83 if self._test_instance.apk_under_test_incremental_install_script:
81 local_device_test_run.IncrementalInstall( 84 steps.append(lambda: local_device_test_run.IncrementalInstall(
82 dev, 85 dev,
83 self._test_instance.apk_under_test, 86 self._test_instance.apk_under_test,
84 self._test_instance.apk_under_test_incremental_install_script) 87 self._test_instance.
88 apk_under_test_incremental_install_script))
85 else: 89 else:
86 permissions = self._test_instance.apk_under_test.GetPermissions() 90 permissions = self._test_instance.apk_under_test.GetPermissions()
87 dev.Install(self._test_instance.apk_under_test, 91 steps.append(install_helper(self._test_instance.apk_under_test,
shenghuazhang 2017/04/05 03:00:16 Seems like python doesn't create closure binding t
88 permissions=permissions) 92 permissions))
89 93
90 if self._test_instance.test_apk_incremental_install_script: 94 if self._test_instance.test_apk_incremental_install_script:
91 local_device_test_run.IncrementalInstall( 95 steps.append(lambda: local_device_test_run.IncrementalInstall(
92 dev, 96 dev,
93 self._test_instance.test_apk, 97 self._test_instance.test_apk,
94 self._test_instance.test_apk_incremental_install_script) 98 self._test_instance.
99 test_apk_incremental_install_script))
95 else: 100 else:
96 permissions = self._test_instance.test_apk.GetPermissions() 101 permissions = self._test_instance.test_apk.GetPermissions()
97 dev.Install(self._test_instance.test_apk, permissions=permissions) 102 steps.append(install_helper(self._test_instance.test_apk,
103 permissions))
98 104
99 for apk in self._test_instance.additional_apks: 105 steps.extend([install_helper(apk, ())
100 dev.Install(apk) 106 for apk in self._test_instance.additional_apks])
mikecase (-- gone --) 2017/04/05 15:46:10 nit: some of the indentation looks off.
shenghuazhang 2017/04/05 18:57:05 Done.
101 107
108 if self._env.concurrent_adb:
jbudorick 2017/04/05 16:32:29 Again: we shouldn't need to branch based on this h
shenghuazhang 2017/04/05 18:57:05 Done.
109 return steps
110 else:
111 def install_apk_func():
mikecase (-- gone --) 2017/04/05 15:46:10 Would rename to something like... sequential_inst
jbudorick 2017/04/05 16:32:29 As mentioned, this shouldn't exist. Use the same s
shenghuazhang 2017/04/05 18:57:05 Done.
112 for step in steps:
113 step()
114 return [install_apk_func]
115
116 def set_debug_app():
102 # Set debug app in order to enable reading command line flags on user 117 # Set debug app in order to enable reading command line flags on user
103 # builds 118 # builds
104 if self._test_instance.flags: 119 if self._test_instance.flags:
105 if not self._test_instance.package_info: 120 if not self._test_instance.package_info:
106 logging.error("Couldn't set debug app: no package info") 121 logging.error("Couldn't set debug app: no package info")
107 elif not self._test_instance.package_info.package: 122 elif not self._test_instance.package_info.package:
108 logging.error("Couldn't set debug app: no package defined") 123 logging.error("Couldn't set debug app: no package defined")
109 else: 124 else:
110 dev.RunShellCommand(['am', 'set-debug-app', '--persistent', 125 dev.RunShellCommand(['am', 'set-debug-app', '--persistent',
111 self._test_instance.package_info.package], 126 self._test_instance.package_info.package],
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 logging.error("Couldn't set flags: no cmdline_file") 173 logging.error("Couldn't set flags: no cmdline_file")
159 else: 174 else:
160 self._CreateFlagChangerIfNeeded(dev) 175 self._CreateFlagChangerIfNeeded(dev)
161 logging.debug('Attempting to set flags: %r', 176 logging.debug('Attempting to set flags: %r',
162 self._test_instance.flags) 177 self._test_instance.flags)
163 self._flag_changers[str(dev)].AddFlags(self._test_instance.flags) 178 self._flag_changers[str(dev)].AddFlags(self._test_instance.flags)
164 179
165 valgrind_tools.SetChromeTimeoutScale( 180 valgrind_tools.SetChromeTimeoutScale(
166 dev, self._test_instance.timeout_scale) 181 dev, self._test_instance.timeout_scale)
167 182
168 steps = (install_apk, edit_shared_prefs, push_test_data, 183 install_apk_steps = install_apk()
169 create_flag_changer) 184 steps = install_apk_steps + [set_debug_app, edit_shared_prefs,
mikecase (-- gone --) 2017/04/05 15:46:10 Could something go wrong is set_debug_app step is
mikecase (-- gone --) 2017/04/05 16:29:06 Tested it. Seems to work fine.
shenghuazhang 2017/04/05 18:57:05 Thanks for bringing this up! I just do a quick res
185 push_test_data, create_flag_changer]
170 if self._env.concurrent_adb: 186 if self._env.concurrent_adb:
171 reraiser_thread.RunAsync(steps) 187 reraiser_thread.RunAsync(steps)
172 else: 188 else:
173 for step in steps: 189 for step in steps:
174 step() 190 step()
175 if self._test_instance.store_tombstones: 191 if self._test_instance.store_tombstones:
176 tombstones.ClearAllTombstones(dev) 192 tombstones.ClearAllTombstones(dev)
177 193
178 self._env.parallel_devices.pMap( 194 self._env.parallel_devices.pMap(
179 individual_device_set_up, 195 individual_device_set_up,
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if k in annotations: 447 if k in annotations:
432 timeout = v 448 timeout = v
433 break 449 break
434 else: 450 else:
435 logging.warning('Using default 1 minute timeout for %s', test_name) 451 logging.warning('Using default 1 minute timeout for %s', test_name)
436 timeout = 60 452 timeout = 60
437 453
438 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations) 454 timeout *= cls._GetTimeoutScaleFromAnnotations(annotations)
439 455
440 return timeout 456 return timeout
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698