def testMethodCallArgList(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.assertEquals(self._callTimeout(client, "echo", (data,), apiTests.id, CALL_TIMEOUT), data)
def testMethodCallArgDict(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.assertEquals( self._callTimeout(client, "echo", {'text': data}, apiTests.id, CALL_TIMEOUT), data)
def testMethodCallArgList(self, rt, ssl): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(rt, bridge, ssl) as (server, clientFactory): with self._client(clientFactory) as client: self.log.info("Calling 'echo'") self.assertEquals( self._callTimeout(client, "echo", (data, ), apiTests.id, CALL_TIMEOUT), data)
def test(self, rt, ssl): data = dummyTextGenerator(((2 ** 10) * 200)) echosrv = _EchoServer() def serve(reactor): try: reactor.process_requests() except socket.error as e: pass except Exception as e: self.log.error("Reactor died unexpectedly", exc_info=True) self.fail("Reactor died: (%s) %s" % (type(e), e)) with constructReactor(rt, ssl) as \ (reactor, clientReactor, laddr): t = threading.Thread(target=echosrv.serve) t.setDaemon(True) t.start() reactor.createListener(laddr, echosrv.accept) clientNum = 2 repeats = 10 subRepeats = 10 clients = [] for i in range(clientNum): c = ReactorClientSyncWrapper( clientReactor.createClient(laddr)) c.connect() clients.append(c) for i in range(repeats): for client in clients: for i in range(subRepeats): self.log.info("Sending message...") client.send(data) for i in range(repeats * subRepeats): for client in clients: self.log.info("Waiting for reply...") retData = client.recv(CALL_TIMEOUT) self.log.info("Asserting reply...") self.assertTrue(isinstance(retData, (str, unicode))) plen = 20 # Preview len, used for debugging self.assertEquals( retData, data, "Data is not as expected " + "'%s...%s' (%d chars) != '%s...%s' (%d chars)" % (retData[:plen], retData[-plen:], len(retData), data[:plen], data[-plen:], len(data)))
def test(self, reactorType): data = dummyTextGenerator(((2 ** 10) * 200)) queue = Queue() echosrv = _EchoServer() def serve(reactor): try: reactor.process_requests() except socket.error as e: pass except Exception as e: self.log.error("Reactor died unexpectedly", exc_info=True) self.fail("Reactor died: (%s) %s" % (type(e), e)) with constructReactor(reactorType) as \ (reactor, clientFactory, laddr): t = threading.Thread(target=echosrv.serve) t.setDaemon(True) t.start() reactor.createListener(laddr, echosrv.accept) clientNum = 4 repeats = 2 subRepeats = 4 clients = [] try: for i in range(clientNum): c = clientFactory() c.connect() clients.append(c) for i in range(repeats): for client in clients: for i in range(subRepeats): self.log.info("Sending message...") client.send(data, CALL_TIMEOUT) for i in range(repeats * subRepeats): for client in clients: self.log.info("Waiting for reply...") retData = client.recv(CALL_TIMEOUT) self.log.info("Asserting reply...") self.assertEquals( retData, data, "Data is not as expected " + "'%s...%s' != '%s...%s'" % (retData[:10], retData[-10:], data[:10], data[-10:])) finally: queue.put((None, None))
def testMethodCallArgList(self, reactorType): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): self.assertEquals(client.callMethod("echo", (data,), 10, CALL_TIMEOUT), data)
def testMethodCallArgDict(self, reactorType): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructServer(reactorType, bridge) as (server, clientFactory): client = clientFactory() client.connect() with closing(client): self.assertEquals( client.callMethod("echo", {'text': data}, 10, CALL_TIMEOUT), data)
def test(self, reactorType): data = dummyTextGenerator(((2**10) * 200)) queue = Queue() echosrv = _EchoServer() def serve(reactor): try: reactor.process_requests() except socket.error as e: pass except Exception as e: self.log.error("Reactor died unexpectedly", exc_info=True) self.fail("Reactor died: (%s) %s" % (type(e), e)) with constructReactor(reactorType) as \ (reactor, clientFactory, laddr): t = threading.Thread(target=echosrv.serve) t.setDaemon(True) t.start() reactor.createListener(laddr, echosrv.accept) clientNum = 4 repeats = 2 subRepeats = 4 clients = [] try: for i in range(clientNum): c = clientFactory() c.connect() clients.append(c) for i in range(repeats): for client in clients: for i in range(subRepeats): self.log.info("Sending message...") client.send(data, CALL_TIMEOUT) for i in range(repeats * subRepeats): for client in clients: self.log.info("Waiting for reply...") retData = client.recv(CALL_TIMEOUT) self.log.info("Asserting reply...") self.assertEquals( retData, data, "Data is not as expected " + "'%s...%s' != '%s...%s'" % (retData[:10], retData[-10:], data[:10], data[-10:])) finally: queue.put((None, None))
def testMethodCallArgDict(self, ssl, type): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructClient(self.log, bridge, ssl, type) as clientFactory: with self._client(clientFactory) as client: if type == "xml": response = client.send("echo", (data,)) self.assertEquals(response, data) else: self.assertEquals(self._callTimeout(client, "echo", {'text': data}, CALL_ID, CALL_TIMEOUT), data)
def testMethodCallArgDict(self, ssl, type): data = dummyTextGenerator(1024) bridge = _DummyBridge() with constructClient(self.log, bridge, ssl, type) as clientFactory: with self._client(clientFactory) as client: if type == "xml": response = client.send("echo", (data, )) self.assertEquals(response, data) else: self.assertEquals( self._callTimeout(client, "echo", {'text': data}, CALL_ID, CALL_TIMEOUT), data)
def test(self, rt, ssl): data = dummyTextGenerator(((2**10) * 200)) echosrv = _EchoServer() def serve(reactor): try: reactor.process_requests() except socket.error as e: pass except Exception as e: self.log.error("Reactor died unexpectedly", exc_info=True) self.fail("Reactor died: (%s) %s" % (type(e), e)) with constructReactor(rt, ssl) as \ (reactor, clientReactor, laddr): t = threading.Thread(target=echosrv.serve) t.setDaemon(True) t.start() reactor.createListener(laddr, echosrv.accept) clientNum = 2 repeats = 10 subRepeats = 10 clients = [] for i in range(clientNum): c = ReactorClientSyncWrapper(clientReactor.createClient(laddr)) c.connect() clients.append(c) for i in range(repeats): for client in clients: for i in range(subRepeats): self.log.info("Sending message...") client.send(data) for i in range(repeats * subRepeats): for client in clients: self.log.info("Waiting for reply...") retData = client.recv(CALL_TIMEOUT) self.log.info("Asserting reply...") self.assertTrue(isinstance(retData, (str, unicode))) plen = 20 # Preview len, used for debugging self.assertEquals( retData, data, "Data is not as expected " + "'%s...%s' (%d chars) != '%s...%s' (%d chars)" % (retData[:plen], retData[-plen:], len(retData), data[:plen], data[-plen:], len(data)))