Commit fe1eaff0 authored by pliard@chromium.org's avatar pliard@chromium.org

Ensure host_forwarder is killed when setting up sharding.

This fixes the following issue:
- TestSharder.SetupSharding() in run_java_tests.py wasn't calling
  the super class' SetupSharding() method which kills host_forwarder. The call
  to Forwarder.KillHost() was moved to RunShardedTest() which isn't supposed to
  be overridden. This should be more robust.

Additionally in case '$ host_forwarder kill-server' failed for any reason,
Forwarder.KillHost() now falls back to pkill.

BUG=163036


Review URL: https://chromiumcodereview.appspot.com/11421149

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170437 0039d316-1c4b-4281-b951-d872f2087c98
parent 09e1727e
...@@ -66,10 +66,13 @@ class BaseTestSharder(object): ...@@ -66,10 +66,13 @@ class BaseTestSharder(object):
def SetupSharding(self, tests): def SetupSharding(self, tests):
"""Called before starting the shards.""" """Called before starting the shards."""
Forwarder.KillHost(self.build_type) pass
def OnTestsCompleted(self, test_runners, test_results): def OnTestsCompleted(self, test_runners, test_results):
"""Notifies that we completed the tests.""" """Notifies that we completed the tests."""
pass
def _KillHostForwarder(self):
Forwarder.KillHost(self.build_type) Forwarder.KillHost(self.build_type)
def RunShardedTests(self): def RunShardedTests(self):
...@@ -85,6 +88,7 @@ class BaseTestSharder(object): ...@@ -85,6 +88,7 @@ class BaseTestSharder(object):
logging.warning('Look for the "Final result" banner in the end.') logging.warning('Look for the "Final result" banner in the end.')
logging.warning('*' * 80) logging.warning('*' * 80)
final_results = TestResults() final_results = TestResults()
self._KillHostForwarder()
for retry in xrange(self.retries): for retry in xrange(self.retries):
logging.warning('Try %d of %d', retry + 1, self.retries) logging.warning('Try %d of %d', retry + 1, self.retries)
self.SetupSharding(self.tests) self.SetupSharding(self.tests)
...@@ -142,4 +146,5 @@ class BaseTestSharder(object): ...@@ -142,4 +146,5 @@ class BaseTestSharder(object):
# There's no recovery at this point. # There's no recovery at this point.
raise Exception('Unrecoverable error while retrying test runs.') raise Exception('Unrecoverable error while retrying test runs.')
self.OnTestsCompleted(test_runners, final_results) self.OnTestsCompleted(test_runners, final_results)
self._KillHostForwarder()
return final_results return final_results
...@@ -105,12 +105,16 @@ class Forwarder(object): ...@@ -105,12 +105,16 @@ class Forwarder(object):
@staticmethod @staticmethod
def KillHost(build_type): def KillHost(build_type):
logging.info('Killing host_forwarder.')
host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder') host_forwarder_path = _MakeBinaryPath(build_type, 'host_forwarder')
(exit_code, output) = cmd_helper.GetCmdStatusAndOutput( (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
[host_forwarder_path, 'kill-server']) [host_forwarder_path, 'kill-server'])
if exit_code != 0: if exit_code != 0:
raise Exception('%s exited with %d:\n%s' % (host_forwarder_path, (exit_code, output) = cmd_helper.GetCmdStatusAndOutput(
exit_code, '\n'.join(output))) ['pkill', 'host_forwarder'])
if exit_code != 0:
raise Exception('%s exited with %d:\n%s' % (
host_forwarder_path, exit_code, '\n'.join(output)))
@staticmethod @staticmethod
def KillDevice(adb): def KillDevice(adb):
......
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