def _StartReplayServer(self): """Start the replay server and return the started local_ports.""" self._StopReplayServer() # In case it was already running. self._wpr_server = webpagereplay_go_server.ReplayServer( self._archive_path, self.host_ip, http_port=0, https_port=0, replay_options=self._ReplayCommandLineArgs()) return self._wpr_server.StartServer()
def _BringUpWpr(self): """Start the WPR server on the host and the forwarder on the device.""" print 'Starting WPR on host...' _DownloadFromCloudStorage(self._WPR_BUCKET, self._wpr_archive_hash) if binary_manager.NeedsInit(): binary_manager.InitDependencyManager([]) self._wpr_server = webpagereplay_go_server.ReplayServer( self._wpr_archive, '127.0.0.1', 0, 0, replay_options=[]) ports = self._wpr_server.StartServer()[:-1] self._host_http_port = ports[0] self._host_https_port = ports[1]
def testKillingWebPageReplayProcessUponStartupFailure( self, atexit_with_log_register_patch): atexit_with_log_register_patch.side_effect = KeyError('Bang!') with self.assertRaises(webpagereplay_go_server.ReplayNotStartedError): server = webpagereplay_go_server.ReplayServer( self.archive_path, replay_host='127.0.0.1', http_port=0, https_port=0, replay_options=[]) server.StartServer() # Ensure replay process is probably cleaned up after StartServer crashed. self.assertIsNone(server.replay_process)
def testSmokeStartingWebPageReplayGoServer(self): with webpagereplay_go_server.ReplayServer( self.archive_path, replay_host='127.0.0.1', http_port=0, https_port=0, replay_options=[]) as server: self.assertIsNotNone(server.http_port) self.assertIsNotNone(server.https_port) # Make sure that we can establish connection to HTTP port. req = urllib2.Request('http://www.example.com/', origin_req_host='127.0.0.1') r = urllib2.urlopen(req) self.assertEquals(r.getcode(), 200) # Make sure that we can establish connection to HTTPS port. req = urllib2.Request('https://www.example.com/', origin_req_host='127.0.0.1') r = urllib2.urlopen(req) self.assertEquals(r.getcode(), 200)