def LaunchChromeTestServerSpawner(self):
   """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):
     self.test_server_spawner_port = ports.AllocateTestServerPort()
     self._ForwardPorts(
         [(self.test_server_spawner_port, self.test_server_spawner_port)])
     self._spawning_server = SpawningServer(self.test_server_spawner_port,
                                            self.adb,
                                            self.tool,
                                            self.build_type)
     self._spawning_server.Start()
     server_ready, error_msg = ports.IsHttpServerConnectable(
         '127.0.0.1', self.test_server_spawner_port, path='/ping',
         expected_read='ready')
     if server_ready:
       break
     else:
       error_msgs.append(error_msg)
     self._spawning_server.Stop()
     # Wait for 2 seconds then restart.
     time.sleep(2)
   if not server_ready:
     logging.error(';'.join(error_msgs))
     raise Exception('Can not start the test spawner server.')
   self._PushTestServerPortInfoToDevice()
Exemplo n.º 2
0
 def LaunchChromeTestServerSpawner(self):
     """Launches test server spawner."""
     server_ready = False
     error_msgs = []
     # 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._spawning_server = SpawningServer(
             self.test_server_spawner_port, self.adb, self.tool,
             self.build_type)
         self._spawning_server.Start()
         server_ready, error_msg = ports.IsHttpServerConnectable(
             '127.0.0.1',
             self.test_server_spawner_port,
             path='/ping',
             expected_read='ready')
         if server_ready:
             break
         else:
             error_msgs.append(error_msg)
         self._spawning_server.Stop()
         # Wait for 2 seconds then restart.
         time.sleep(2)
     if not server_ready:
         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)