def test_produce_many_simple(simple_client, topic):
    """Test multiple produces using the SimpleClient
    """
    start_offset = current_offset(simple_client, topic, 0)

    assert_produce_request(
        simple_client,
        topic,
        [
            create_message(("Test message %d" % i).encode('utf-8'))
            for i in range(100)
        ],
        start_offset,
        100,
    )

    assert_produce_request(
        simple_client,
        topic,
        [
            create_message(("Test message %d" % i).encode('utf-8'))
            for i in range(100)
        ],
        start_offset + 100,
        100,
    )
Exemple #2
0
def assert_produce_request(client, topic, messages, initial_offset, message_ct,
                           partition=0):
    """Verify the correctness of a produce request
    """
    produce = ProduceRequestPayload(topic, partition, messages=messages)

    # There should only be one response message from the server.
    # This will throw an exception if there's more than one.
    resp = client.send_produce_request([produce])
    assert_produce_response(resp, initial_offset)

    assert current_offset(client, topic, partition) == initial_offset + message_ct
def assert_produce_request(client, topic, messages, initial_offset, message_ct,
                           partition=0):
    """Verify the correctness of a produce request
    """
    produce = ProduceRequestPayload(topic, partition, messages=messages)

    # There should only be one response message from the server.
    # This will throw an exception if there's more than one.
    resp = client.send_produce_request([produce])
    assert_produce_response(resp, initial_offset)

    assert current_offset(client, topic, partition) == initial_offset + message_ct
def test_produce_many_simple(simple_client, topic):
    """Test multiple produces using the SimpleClient
    """
    start_offset = current_offset(simple_client, topic, 0)

    assert_produce_request(
        simple_client, topic,
        [create_message(("Test message %d" % i).encode('utf-8'))
         for i in range(100)],
        start_offset,
        100,
    )

    assert_produce_request(
        simple_client, topic,
        [create_message(("Test message %d" % i).encode('utf-8'))
         for i in range(100)],
        start_offset+100,
        100,
    )