Ejemplo n.º 1
0
 def test_server_replies_ping(self):
     """
     Ensure server replies to a ping.
     """
     request = PingRequest()
     service = RpcService(EventsServerService_Stub, port, 'localhost')
     response = service.ping(request, timeout=1000)
     self.assertIsNotNone(response)
     self.assertEqual(EventResponse.OK, response.status,
                      'Wrong response status.')
Ejemplo n.º 2
0
 def test_client_replies_ping(self):
     """
     Ensure clients reply to a ping.
     """
     daemon = client.ensure_client_daemon()
     port = daemon.get_port()
     request = PingRequest()
     service = RpcService(EventsClientService_Stub, port, 'localhost')
     response = service.ping(request, timeout=1000)
     self.assertEqual(EventResponse.OK, response.status,
                      'Wrong response status.')
Ejemplo n.º 3
0
def ping(port=SERVER_PORT, reqcbk=None, timeout=1000):
    """
    Ping the server.

    :param port: the port in which server should be listening
    :type port: int
    :param reqcbk: a callback to be called when a response from server is
                   received
    :type reqcbk: function(proto.PingRequest, proto.EventResponse)
    :param timeout: the timeout for synch calls
    :type timeout: int

    :return: the response from server for synch calls or nothing for asynch
             calls.
    :rtype: leap.common.events.events_pb2.EventsResponse or None
    """
    request = proto.PingRequest()
    service = RpcService(
        proto.EventsServerService_Stub,
        port,
        'localhost')
    logger.info("Pinging server in port %d..." % port)
    return service.ping(request, callback=reqcbk, timeout=timeout)
Ejemplo n.º 4
0
def ping(port, reqcbk=None, timeout=1000):
    """
    Ping a client running in C{port}.

    :param port: the port in which the client should be listening
    :type port: int
    :param reqcbk: a callback to be called when a response from client is
                   received
    :type reqcbk: function(proto.PingRequest, proto.EventResponse)
    :param timeout: the timeout for synch calls
    :type timeout: int

    :return: the response from client for synch calls or nothing for asynch
             calls.
    :rtype: leap.common.events.events_pb2.EventsResponse or None
    """
    request = proto.PingRequest()
    service = RpcService(
        proto.EventsClientService_Stub,
        port,
        'localhost')
    logger.debug("Pinging a client in port %d..." % port)
    return service.ping(request, callback=reqcbk, timeout=timeout)