Пример #1
0
def records() -> RecordList:
    """
    Just a list of simple records, ready to be used as messages.
    """
    return [(rand_text(8), {
        "a": rand_text(64),
        "b": random.randint(0, 1000)
    }) for _ in range(15)]
Пример #2
0
def topic_and_partitions(
        request, confluent_admin_client: AdminClient,
        running_cluster_config: Dict[str, str]) -> Iterable[Tuple[str, int]]:
    """
    Creates a kafka topic consisting of a random 5 character string and being partition into 1, 2 or 4 partitions.
    Then it yields the tuple (topic, n_partitions).

    Prints topic information before and after topic was used by a test.
    :return: Topic and number of partitions within it.
    """
    topic_id = rand_text(5)
    partitions = request.param

    confluent_admin_client.create_topics(
        [NewTopic(topic_id, num_partitions=partitions, replication_factor=1)])

    yield topic_id, partitions

    confluent_admin_client.delete_topics(
        [NewTopic(topic_id, num_partitions=partitions, replication_factor=1)])