Ejemplo n.º 1
0
def test_communicate(result, msg_num, msg_size, endpoint, com1):
    """Sends multiple messages and receives replies using communicator."""

    com1.connect()

    endpoint.wait_for_connections()
    msg = random_str(msg_size)

    communicate_time = Duration()
    for _ in xrange(msg_num):
        with measure(communicate_time):
            request = com1.communicate(msg)

        reply = communication_stack.prepareReply(request, msg)

        with measure(communicate_time):
            endpoint.wait_for_specific_messages(request)
            endpoint.send(reply)

        with measure(communicate_time):
            assert reply == com1.communicateReceive()

    result.set([
        Parameter.communicate_time(communicate_time),
        Parameter.mbps(msg_num, msg_size, communicate_time),
        Parameter.msgps(msg_num, communicate_time)
    ])
Ejemplo n.º 2
0
def test_communicate(result, msg_num, msg_size, endpoint, com1):
    """Sends multiple messages and receives replies using communicator."""

    com1.connect()

    endpoint.wait_for_connections()
    msg = random_str(msg_size)

    communicate_time = Duration()
    for _ in xrange(msg_num):
        with measure(communicate_time):
            request = com1.communicate(msg)

        reply = communication_stack.prepareReply(request, msg)

        with measure(communicate_time):
            endpoint.wait_for_specific_messages(request)
            endpoint.send(reply)

        with measure(communicate_time):
            assert reply == com1.communicateReceive()

    result.set([
        Parameter.communicate_time(communicate_time),
        Parameter.mbps(msg_num, msg_size, communicate_time),
        Parameter.msgps(msg_num, communicate_time)
    ])
Ejemplo n.º 3
0
def test_unsuccessful_handshake(endpoint, com3):
    handshake = com3.setHandshake("anotherHanshake", True)
    com3.connect()

    endpoint.wait_for_specific_messages(handshake, msg_count=3)

    reply = communication_stack.prepareReply(handshake, "anotherHandshakeR")
    endpoint.send(reply)

    # The connections should now be recreated and another handshake sent
    endpoint.wait_for_specific_messages(handshake, msg_count=6)
Ejemplo n.º 4
0
def test_unsuccessful_handshake(endpoint, com3):
    handshake = com3.setHandshake("anotherHanshake", True)
    com3.connect()

    endpoint.wait_for_specific_messages(handshake, msg_count=3)

    reply = communication_stack.prepareReply(handshake, "anotherHandshakeR")
    endpoint.send(reply)

    # The connections should now be recreated and another handshake sent
    endpoint.wait_for_specific_messages(handshake, msg_count=6)
Ejemplo n.º 5
0
def test_successful_handshake(endpoint, com1):
    handshake = com1.setHandshake("handshake", False)
    com1.connect()

    com1.sendAsync("this is another request")

    endpoint.wait_for_specific_messages(handshake)
    assert 1 == endpoint.all_messages_count()

    reply = communication_stack.prepareReply(handshake, "handshakeReply")
    endpoint.send(reply)

    assert com1.handshakeResponse() == reply
    endpoint.wait_for_any_messages(msg_count=2)
Ejemplo n.º 6
0
def test_successful_handshake(endpoint, com1):
    handshake = com1.setHandshake("handshake", False)
    com1.connect()

    com1.sendAsync("this is another request")

    endpoint.wait_for_specific_messages(handshake)
    assert 1 == endpoint.all_messages_count()

    reply = communication_stack.prepareReply(handshake, "handshakeReply")
    endpoint.send(reply)

    assert com1.handshakeResponse() == reply
    endpoint.wait_for_any_messages(msg_count=2)