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

Unified Diff: build/android/pylib/base/base_test_runner.py

Issue 15151003: Use a single Python Forwarder instance for each base test runner instance. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Craig + Frank comments Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/pylib/chrome_test_server_spawner.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/base/base_test_runner.py
diff --git a/build/android/pylib/base/base_test_runner.py b/build/android/pylib/base/base_test_runner.py
index 9316a0f695b1e99c1c69e55d5a6f4dd05761c6d9..559fa38f4d1bc7743a8e307261f1d71dd331dcde 100644
--- a/build/android/pylib/base/base_test_runner.py
+++ b/build/android/pylib/base/base_test_runner.py
@@ -125,12 +125,11 @@ class BaseTestRunner(object):
self.StartForwarderForHttpServer()
return (self._forwarder_device_port, self._http_server.port)
- def _CreateAndRunForwarder(
- self, adb, port_pairs, tool, host_name, build_type):
- """Creates and run a forwarder."""
- forwarder = Forwarder(adb, build_type)
- forwarder.Run(port_pairs, tool, host_name)
- return forwarder
+ def _ForwardPort(self, port_pairs):
+ """Creates a forwarder instance if needed and forward a port."""
+ if not self._forwarder:
+ self._forwarder = Forwarder(self.adb, self.build_type)
+ self._forwarder.Run(port_pairs, self.tool, '127.0.0.1')
def StartForwarder(self, port_pairs):
"""Starts TCP traffic forwarding for the given |port_pairs|.
@@ -138,17 +137,14 @@ class BaseTestRunner(object):
Args:
host_port_pairs: A list of (device_port, local_port) tuples to forward.
"""
- if self._forwarder:
- self._forwarder.Close()
- self._forwarder = self._CreateAndRunForwarder(
- self.adb, port_pairs, self.tool, '127.0.0.1', self.build_type)
+ self._ForwardPort(port_pairs)
def StartForwarderForHttpServer(self):
"""Starts a forwarder for the HTTP server.
The forwarder forwards HTTP requests and responses between host and device.
"""
- self.StartForwarder([(self._forwarder_device_port, self._http_server.port)])
+ self._ForwardPort([(self._forwarder_device_port, self._http_server.port)])
def RestartHttpServerForwarderIfNecessary(self):
"""Restarts the forwarder if it's not open."""
@@ -187,14 +183,18 @@ class BaseTestRunner(object):
"""Launches test server spawner."""
server_ready = False
error_msgs = []
+ # TODO(pliard): deflake this function. The for loop should be removed as
+ # well as IsHttpServerConnectable(). spawning_server.Start() should also
+ # block until the server is ready.
# Try 3 times to launch test spawner server.
for i in xrange(0, 3):
- # Do not allocate port for test server here. We will allocate
- # different port for individual test in TestServerThread.
self.test_server_spawner_port = ports.AllocateTestServerPort()
+ self._ForwardPort(
+ [(self.test_server_spawner_port, self.test_server_spawner_port)])
self._spawning_server = SpawningServer(self.test_server_spawner_port,
self.adb,
self.tool,
+ self._forwarder,
self.build_type)
self._spawning_server.Start()
server_ready, error_msg = ports.IsHttpServerConnectable(
@@ -211,7 +211,3 @@ class BaseTestRunner(object):
logging.error(';'.join(error_msgs))
raise Exception('Can not start the test spawner server.')
self._PushTestServerPortInfoToDevice()
- self._spawner_forwarder = self._CreateAndRunForwarder(
- self.adb,
- [(self.test_server_spawner_port, self.test_server_spawner_port)],
- self.tool, '127.0.0.1', self.build_type)
« no previous file with comments | « no previous file | build/android/pylib/chrome_test_server_spawner.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698