Commit c6ca3b42 authored by tonyg@chromium.org's avatar tonyg@chromium.org

A kinder, gentler adbd restart

Background: We restart adbd between runs because we noticed that the
likelyhood of an adbd hang goes up with the length of time the process
has been running.

Killing was just a convenient way to do that, but it isn't the most robust.
The chromium.perf bots are very frequently going offline now and they
always are getting stuck at the point of the adbd restart. So I'm trying
this gentler method of restarting to see if it improves reliability.

BUG=

Review URL: https://codereview.chromium.org/304053002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274360 0039d316-1c4b-4281-b951-d872f2087c98
parent 6949e0d2
...@@ -544,19 +544,16 @@ class AndroidCommands(object): ...@@ -544,19 +544,16 @@ class AndroidCommands(object):
raise errors.MsgException('Remount failed: %s' % out) raise errors.MsgException('Remount failed: %s' % out)
def RestartAdbdOnDevice(self): def RestartAdbdOnDevice(self):
logging.info('Killing adbd on the device...') logging.info('Restarting adbd on the device...')
adb_pids = self.ExtractPid('adbd') with DeviceTempFile(self, suffix=".sh") as temp_script_file:
if not adb_pids: host_script_path = os.path.join(constants.DIR_SOURCE_ROOT,
raise errors.MsgException('Unable to obtain adbd pid') 'build',
try: 'android',
self.KillAll('adbd', signum=signal.SIGTERM, with_su=True) 'pylib',
logging.info('Waiting for device to settle...') 'restart_adbd.sh')
self._adb.Push(host_script_path, temp_script_file.name)
self.RunShellCommand('. %s' % temp_script_file.name)
self._adb.SendCommand('wait-for-device') self._adb.SendCommand('wait-for-device')
new_adb_pids = self.ExtractPid('adbd')
if new_adb_pids == adb_pids:
logging.warning('adbd on the device may not have been restarted.')
except Exception as e:
logging.error('Exception when trying to kill adbd on the device [%s]', e)
def RestartAdbServer(self): def RestartAdbServer(self):
"""Restart the adb server.""" """Restart the adb server."""
......
#!/system/bin/sh
# Copyright 2014 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.
# Android shell script to restart adbd on the device. This has to be run
# atomically as a shell script because stopping adbd prevents further commands
# from running (even if called in the same adb shell).
trap '' HUP
trap '' TERM
trap '' PIPE
function restart() {
stop adbd
start adbd
}
restart &
...@@ -220,13 +220,12 @@ def FindAllAvailableBrowsers(finder_options, logging=real_logging): ...@@ -220,13 +220,12 @@ def FindAllAvailableBrowsers(finder_options, logging=real_logging):
if ret: if ret:
logging.warn('Failed to taskset %d (%s)', pid, ret) logging.warn('Failed to taskset %d (%s)', pid, ret)
if not os.environ.get('BUILDBOT_BUILDERNAME'): if not os.environ.get('BUILDBOT_BUILDERNAME'):
# Killing adbd before running tests has proven to make them less likely to # Killing adbd before running tests has proven to make them less likely to
# flake out during the test. We skip this if Telemetry is running under a # flake out during the test. We skip this if Telemetry is running under a
# buildbot because build/android/test_runner.py wrapper already took care # buildbot because build/android/test_runner.py wrapper already took care
# of it before starting the shards. # of it before starting the shards.
adb.RestartAdbdOnDevice() adb.RestartAdbdOnDevice()
adb.WaitForDevicePm()
packages = adb.RunShellCommand('pm list packages') packages = adb.RunShellCommand('pm list packages')
possible_browsers = [] possible_browsers = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment