OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 contextlib | 5 import contextlib |
6 import httplib | 6 import httplib |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import tempfile | 9 import tempfile |
10 import time | 10 import time |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 def LaunchChromeTestServerSpawner(self): | 206 def LaunchChromeTestServerSpawner(self): |
207 """Launches test server spawner.""" | 207 """Launches test server spawner.""" |
208 server_ready = False | 208 server_ready = False |
209 error_msgs = [] | 209 error_msgs = [] |
210 # Try 3 times to launch test spawner server. | 210 # Try 3 times to launch test spawner server. |
211 for i in xrange(0, 3): | 211 for i in xrange(0, 3): |
212 # Do not allocate port for test server here. We will allocate | 212 # Do not allocate port for test server here. We will allocate |
213 # different port for individual test in TestServerThread. | 213 # different port for individual test in TestServerThread. |
214 self.test_server_spawner_port = ports.AllocateTestServerPort() | 214 self.test_server_spawner_port = ports.AllocateTestServerPort() |
215 self._spawning_server = SpawningServer(self.test_server_spawner_port, | 215 self._spawning_server = SpawningServer(self.test_server_spawner_port, |
216 self.adb, | 216 self.test_server_port) |
217 self.tool) | |
218 self._spawning_server.Start() | 217 self._spawning_server.Start() |
219 server_ready, error_msg = ports.IsHttpServerConnectable( | 218 server_ready, error_msg = ports.IsHttpServerConnectable( |
220 '127.0.0.1', self.test_server_spawner_port, path='/ping', | 219 '127.0.0.1', self.test_server_spawner_port, path='/ping', |
221 expected_read='ready') | 220 expected_read='ready') |
222 if server_ready: | 221 if server_ready: |
223 break | 222 break |
224 else: | 223 else: |
225 error_msgs.append(error_msg) | 224 error_msgs.append(error_msg) |
226 self._spawning_server.Stop() | 225 self._spawning_server.Stop() |
227 # Wait for 2 seconds then restart. | 226 # Wait for 2 seconds then restart. |
228 time.sleep(2) | 227 time.sleep(2) |
229 if not server_ready: | 228 if not server_ready: |
230 logging.error(';'.join(error_msgs)) | 229 logging.error(';'.join(error_msgs)) |
231 raise Exception('Can not start the test spawner server.') | 230 raise Exception('Can not start the test spawner server.') |
232 self._PushTestServerPortInfoToDevice() | 231 self._PushTestServerPortInfoToDevice() |
233 self._spawner_forwarder = Forwarder( | 232 self._spawner_forwarder = Forwarder( |
234 self.adb, | 233 self.adb, |
235 [(self.test_server_spawner_port, self.test_server_spawner_port)], | 234 [(self.test_server_spawner_port, self.test_server_spawner_port)], |
236 self.tool, '127.0.0.1') | 235 self.tool, '127.0.0.1') |
OLD | NEW |