Esempio n. 1
0
    def setUp(self):
        super(TestPubSub, self).setUp()

        kwargs = {'use_pub_sub': True}
        self.config(**kwargs)

        self.publisher = zmq_pub_publisher.PubPublisherProxy(
            self.conf, self.driver.matchmaker)

        self.listeners = []
        for i in range(self.LISTENERS_COUNT):
            self.listeners.append(zmq_common.TestServerListener(self.driver))
Esempio n. 2
0
    def setUp(self):
        super(TestPubSub, self).setUp()

        kwargs = {'use_pub_sub': True,
                  'rpc_zmq_serialization': self.serialization}
        self.config(group='oslo_messaging_zmq', **kwargs)

        self.config(host="127.0.0.1", group="zmq_proxy_opts")
        self.config(publisher_port="0", group="zmq_proxy_opts")

        self.publisher = zmq_publisher_proxy.PublisherProxy(
            self.conf, self.driver.matchmaker)
        self.driver.matchmaker.register_publisher(
            (self.publisher.host, ""))

        self.listeners = []
        for i in range(self.LISTENERS_COUNT):
            self.listeners.append(zmq_common.TestServerListener(self.driver))
Esempio n. 3
0
    def setUp(self):
        super(TestZmqAckManager, self).setUp()

        # register and set necessary config opts
        self.messaging_conf.transport_driver = 'zmq'
        zmq_options.register_opts(self.conf)
        kwargs = {
            'rpc_zmq_matchmaker': 'dummy',
            'use_pub_sub': False,
            'use_router_proxy': True,
            'rpc_thread_pool_size': 1,
            'rpc_use_acks': True,
            'rpc_ack_timeout_base': 5,
            'rpc_ack_timeout_multiplier': 1,
            'rpc_retry_attempts': 2
        }
        self.config(group='oslo_messaging_zmq', **kwargs)
        self.conf.register_opts(zmq_proxy.zmq_proxy_opts,
                                group='zmq_proxy_opts')

        # mock set_result method of futures
        self.set_result_patcher = mock.patch.object(
            zmq_receivers.futurist.Future,
            'set_result',
            side_effect=zmq_receivers.futurist.Future.set_result,
            autospec=True)
        self.set_result = self.set_result_patcher.start()

        # mock send method of senders
        self.send_patcher = mock.patch.object(
            zmq_senders.RequestSenderProxy,
            'send',
            side_effect=zmq_senders.RequestSenderProxy.send,
            autospec=True)
        self.send = self.send_patcher.start()

        # get driver
        transport = oslo_messaging.get_transport(self.conf)
        self.driver = transport._driver

        # prepare and launch proxy
        self.proxy = zmq_proxy.ZmqProxy(self.conf)
        vars(self.driver.matchmaker).update(vars(self.proxy.matchmaker))
        self.executor = zmq_async.get_executor(self.proxy.run)
        self.executor.execute()

        # create listener
        self.listener = zmq_common.TestServerListener(self.driver)

        # create target and message
        self.target = oslo_messaging.Target(topic='topic', server='server')
        self.message = {'method': 'xyz', 'args': {'x': 1, 'y': 2, 'z': 3}}

        # start listening to target
        self.listener.listen(self.target)

        # get ack manager
        self.ack_manager = self.driver.client.get().publishers['default']

        self.addCleanup(
            zmq_common.StopRpc(self, [('listener', 'stop'),
                                      ('executor', 'stop'), ('proxy', 'close'),
                                      ('driver', 'cleanup'),
                                      ('send_patcher', 'stop'),
                                      ('set_result_patcher', 'stop')]))

        # wait for all connections to be established
        # and all parties to be ready for messaging
        time.sleep(1)