コード例 #1
0
ファイル: test_proxy.py プロジェクト: krast/oslo-incubator
    def test_serializer(self):
        ctxt = context.RequestContext("fake", "fake")
        serializer = rpc_serializer.NoOpSerializer()

        self.mox.StubOutWithMock(serializer, "serialize_entity")
        self.mox.StubOutWithMock(serializer, "deserialize_entity")
        self.mox.StubOutWithMock(rpc, "call")

        serializer.serialize_entity(ctxt, 1).AndReturn(1)
        serializer.serialize_entity(ctxt, 2).AndReturn(2)
        rpc.call(
            ctxt, "fake", {"args": {"a": 1, "b": 2}, "namespace": None, "method": "foo", "version": "1.0"}, None
        ).AndReturn("foo")
        serializer.deserialize_entity(ctxt, "foo").AndReturn("worked!")

        self.mox.ReplayAll()

        rpc_proxy = proxy.RpcProxy("fake", "1.0", serializer=serializer)
        msg = rpc_proxy.make_msg("foo", a=1, b=2)
        result = rpc_proxy.call(ctxt, msg)
        self.assertEqual(result, "worked!")
コード例 #2
0
    def test_serializer(self):
        ctxt = context.RequestContext('fake', 'fake')
        serializer = rpc_serializer.NoOpSerializer()

        self.mox.StubOutWithMock(serializer, 'serialize_entity')
        self.mox.StubOutWithMock(serializer, 'deserialize_entity')
        self.mox.StubOutWithMock(rpc, 'call')

        serializer.serialize_entity(ctxt, 1).AndReturn(1)
        serializer.serialize_entity(ctxt, 2).AndReturn(2)
        rpc.call(ctxt, 'fake',
                 {'args': {'a': 1, 'b': 2},
                  'namespace': None,
                  'method': 'foo',
                  'version': '1.0'},
                 None).AndReturn('foo')
        serializer.deserialize_entity(ctxt, 'foo').AndReturn('worked!')

        self.mox.ReplayAll()

        rpc_proxy = proxy.RpcProxy('fake', '1.0', serializer=serializer)
        msg = rpc_proxy.make_msg('foo', a=1, b=2)
        result = rpc_proxy.call(ctxt, msg)
        self.assertEqual(result, 'worked!')
コード例 #3
0
ファイル: test_proxy.py プロジェクト: thomasem/oslo-incubator
    def test_serializer(self):
        ctxt = context.RequestContext('fake', 'fake')
        serializer = rpc_serializer.NoOpSerializer()

        self.mox.StubOutWithMock(serializer, 'serialize_entity')
        self.mox.StubOutWithMock(serializer, 'deserialize_entity')
        self.mox.StubOutWithMock(rpc, 'call')

        serializer.serialize_entity(ctxt, 1).AndReturn(1)
        serializer.serialize_entity(ctxt, 2).AndReturn(2)
        rpc.call(ctxt, 'fake',
                 {'args': {'a': 1, 'b': 2},
                  'namespace': None,
                  'method': 'foo',
                  'version': '1.0'},
                 None).AndReturn('foo')
        serializer.deserialize_entity(ctxt, 'foo').AndReturn('worked!')

        self.mox.ReplayAll()

        rpc_proxy = proxy.RpcProxy('fake', '1.0', serializer=serializer)
        msg = rpc_proxy.make_msg('foo', a=1, b=2)
        result = rpc_proxy.call(ctxt, msg)
        self.assertEqual(result, 'worked!')
コード例 #4
0
ファイル: proxy.py プロジェクト: AsherBond/oslo-incubator
    def call(self, context, msg, topic=None, version=None, timeout=None):
        """rpc.call() a remote method.

        :param context: The request context
        :param msg: The message to send, including the method and args.
        :param topic: Override the topic for this message.
        :param timeout: (Optional) A timeout to use when waiting for the
               response.  If no timeout is specified, a default timeout will be
               used that is usually sufficient.
        :param version: (Optional) Override the requested API version in this
               message.

        :returns: The return value from the remote method.
        """
        self._set_version(msg, version)
        return rpc.call(context, self._get_topic(topic), msg, timeout)
コード例 #5
0
ファイル: proxy.py プロジェクト: managedit/oslo-incubator
    def call(self, context, msg, topic=None, version=None, timeout=None):
        """rpc.call() a remote method.

        :param context: The request context
        :param msg: The message to send, including the method and args.
        :param topic: Override the topic for this message.
        :param timeout: (Optional) A timeout to use when waiting for the
               response.  If no timeout is specified, a default timeout will be
               used that is usually sufficient.
        :param version: (Optional) Override the requested API version in this
               message.

        :returns: The return value from the remote method.
        """
        self._set_version(msg, version)
        return rpc.call(context, self._get_topic(topic), msg, timeout)
コード例 #6
0
    def call(self, context, msg, topic=None, version=None, timeout=None):
        """rpc.call() a remote method.

        :param context: The request context
        :param msg: The message to send, including the method and args.
        :param topic: Override the topic for this message.
        :param version: (Optional) Override the requested API version in this
               message.
        :param timeout: (Optional) A timeout to use when waiting for the
               response.  If no timeout is specified, a default timeout will be
               used that is usually sufficient.

        :returns: The return value from the remote method.
        """
        self._set_version(msg, version)
        msg['args'] = self._serialize_msg_args(context, msg['args'])
        real_topic = self._get_topic(topic)
        try:
            result = rpc.call(context, real_topic, msg, timeout)
            return self.serializer.deserialize_entity(context, result)
        except rpc.common.Timeout as exc:
            raise rpc.common.Timeout(exc.info, real_topic, msg.get('method'))
コード例 #7
0
ファイル: proxy.py プロジェクト: home-dog/oslo-incubator
    def call(self, context, msg, topic=None, version=None, timeout=None):
        """rpc.call() a remote method.

        :param context: The request context
        :param msg: The message to send, including the method and args.
        :param topic: Override the topic for this message.
        :param version: (Optional) Override the requested API version in this
               message.
        :param timeout: (Optional) A timeout to use when waiting for the
               response.  If no timeout is specified, a default timeout will be
               used that is usually sufficient.

        :returns: The return value from the remote method.
        """
        self._set_version(msg, version)
        msg['args'] = self._serialize_msg_args(context, msg['args'])
        real_topic = self._get_topic(topic)
        try:
            result = rpc.call(context, real_topic, msg, timeout)
            return self.serializer.deserialize_entity(context, result)
        except rpc.common.Timeout as exc:
            raise rpc.common.Timeout(
                exc.info, real_topic, msg.get('method'))