oslo.messaging/doc/messaging/test-rabbit-client.py
Mark McLoughlin 29dcc87052 Add test code for the rabbit driver
These are just a couple of silly sample scripts. Proper unit tests will
follow.

Change-Id: I6f27ae071c7e6f96059fd665d1163c89227833b9
2013-07-24 08:15:35 +01:00

40 lines
765 B
Python

import eventlet
eventlet.monkey_patch(os=False)
import logging
import socket
from oslo.config import cfg
from oslo import messaging
_opts = [
cfg.StrOpt('host', default=socket.gethostname()),
]
CONF = cfg.CONF
CONF.register_opts(_opts)
LOG = logging.getLogger('client')
logging.basicConfig(level=logging.DEBUG)
CONF()
CONF.log_opt_values(LOG, logging.DEBUG)
class Client(object):
def __init__(self, transport):
target = messaging.Target(topic='topic')
self._client = messaging.RPCClient(transport, target)
super(Client, self).__init__()
def ping(self, ctxt):
return self._client.call(ctxt, 'ping')
transport = messaging.get_transport(CONF, 'rabbit:///test')
client = Client(transport)
print client.ping({})