def test_ping(): service_thread = create_service_thread(serve_time=3) print 'Starting service thread' service_thread.start() gevent.sleep(1) print 'Creating service and client channels' channel_factory = ChannelFactory.get_instance() service_channel = channel_factory.create_channel('urb.service.monitor') client_channel_name = 'urb.client.response' client_channel = channel_factory.create_channel(client_channel_name) client_channel.clear() msg = {'target': 'PingMessage', 'reply_to': client_channel_name} print 'Writing ping message' service_channel.write(json.dumps(msg)) msg2 = client_channel.read_blocking(timeout=5) assert msg2 != None msg2 = json.loads(msg2[1]) payload = msg2.get('payload') assert payload.get('ack') != None print 'Service response: ', payload.get('ack') service_thread.urb_service.shutdown_callback() service_thread.join()
sys.path.append('../../urb-core/source/python/test') # add path to urb sys.path.append('../../urb-core/source/python') from common_utils import needs_setup from common_utils import needs_cleanup from common_utils import create_service_thread from common_utils import create_service_channel from urb.messaging.channel_factory import ChannelFactory from urb.messaging.channel import Channel if os.environ.get("URB_CONFIG_FILE") is None: raise Exception("URB_CONFIG_FILE environment variable has to be defined") SERVICE_THREAD = create_service_thread(serve_time=10) SERVICE_CHANNEL = create_service_channel('urb.endpoint.0.mesos') @needs_setup def test_setup(): print 'Starting service thread' SERVICE_CHANNEL.clear() SERVICE_THREAD.start() def test_register_framework(): print 'Creating service and client channels' client_channel_name = 'urb.endpoint.1.notify' channel_factory = ChannelFactory.get_instance() client_channel = channel_factory.create_channel(client_channel_name) client_channel.clear()