def test_echo(self, size, use_ssl): data = dummyTextGenerator(size) with constructAcceptor(self.log, use_ssl, _SampleBridge()) as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None with utils.running( StandAloneRpcClient(acceptor._host, acceptor._port, "jms.topic.vdsm_requests", str(uuid4()), sslctx) ) as client: self.assertEquals(client.callMethod("echo", (data,), str(uuid4())), data)
def test_echo(self, size, use_ssl): data = dummyTextGenerator(size) ssl_ctx = self.ssl_ctx if use_ssl else None with constructAcceptor(self.log, ssl_ctx, _SampleBridge()) as acceptor: with utils.closing( StandAloneRpcClient(acceptor._host, acceptor._port, 'jms.topic.vdsm_requests', str(uuid4()), ssl_ctx, False)) as client: self.assertEqual( client.callMethod('echo', (data, ), str(uuid4())), data)
def test_echo(self, use_ssl): data = dummyTextGenerator(1024) with constructAcceptor(self.log, use_ssl, _SampleBridge()) as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None with utils.running( StandAloneRpcClient(acceptor._host, acceptor._port, 'jms.topic.vdsm_requests', str(uuid4()), sslctx)) as client: self.assertEquals( client.callMethod('echo', (data, ), str(uuid4())), data)
def test_event(self, use_ssl): done = threading.Event() with constructAcceptor(self.log, use_ssl, _SampleBridge(), "jms.queue.events") as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None client = StandAloneRpcClient( acceptor._host, acceptor._port, "jms.topic.vdsm_requests", "jms.queue.events", sslctx, False ) def callback(client, event, params): self.assertEquals(event, "vdsm.event") self.assertEquals(params["content"], True) done.set() client.registerEventCallback(callback) client.callMethod("event", [], str(uuid4())) done.wait(timeout=CALL_TIMEOUT) self.assertTrue(done.is_set())
def test_event(self, use_ssl): done = threading.Event() with constructAcceptor(self.log, use_ssl, _SampleBridge(), 'jms.queue.events') as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None client = StandAloneRpcClient(acceptor._host, acceptor._port, 'jms.topic.vdsm_requests', 'jms.queue.events', sslctx, False) def callback(client, event, params): self.assertEquals(event, 'vdsm.event') self.assertEquals(params['content'], True) done.set() client.registerEventCallback(callback) client.callMethod("event", [], str(uuid4())) done.wait(timeout=CALL_TIMEOUT) self.assertTrue(done.is_set())
def test_event(self, use_ssl): with constructAcceptor(self.log, use_ssl, _SampleBridge(), 'jms.queue.events') as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None with utils.closing( StandAloneRpcClient(acceptor._host, acceptor._port, 'jms.topic.vdsm_requests', 'jms.queue.events', sslctx, False)) as client: event_queue = queue.Queue() custom_topic = 'jms.queue.events' client.subscribe(custom_topic, event_queue) client.callMethod("event", [], str(uuid4())) try: event, event_params = event_queue.get(timeout=CALL_TIMEOUT) except queue.Empty: self.fail("Event queue timed out.") self.assertEqual(event, 'vdsm.event') self.assertEqual(event_params['content'], True)
def test_event(self, use_ssl): with constructAcceptor(self.log, use_ssl, _SampleBridge(), 'jms.queue.events') as acceptor: sslctx = DEAFAULT_SSL_CONTEXT if use_ssl else None with utils.closing(StandAloneRpcClient(acceptor._host, acceptor._port, 'jms.topic.vdsm_requests', 'jms.queue.events', sslctx, False)) as client: event_queue = queue.Queue() custom_topic = 'jms.queue.events' client.subscribe(custom_topic, event_queue) client.callMethod("event", [], str(uuid4())) try: event, event_params = event_queue.get(timeout=CALL_TIMEOUT) except queue.Empty: self.fail("Event queue timed out.") self.assertEqual(event, 'vdsm.event') self.assertEqual(event_params['content'], True)