Exemple #1
0
    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())
Exemple #2
0
    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)
Exemple #3
0
    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
            with utils.closing(StandAloneRpcClient(acceptor._host,
                                                   acceptor._port,
                                                   'jms.topic.vdsm_requests',
                                                   'jms.queue.events',
                                                   sslctx, False)) as client:

                def callback(client, event, params):
                    self.assertEqual(event, 'vdsm.event')
                    self.assertEqual(params['content'], True)
                    done.set()

                client.registerEventCallback(callback)
                client.callMethod("event", [], str(uuid4()))
                done.wait(timeout=CALL_TIMEOUT)
                self.assertTrue(done.is_set())
Exemple #4
0
    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)