Python KafkaTest library is a Python package that provides testing utilities for Apache Kafka. It is built on top of the Python unittest module and the popular Kafka-Python client.
The KafkaService class provided by KafkaTest's kafka module is used to start and stop a Kafka broker and ZooKeeper server for testing purposes.
Here's an example:
from kafkatest.services.kafka import KafkaService
kafka = KafkaService()
kafka.start()
# your Kafka producer and consumer tests here...
kafka.stop()
In this example, we create an instance of KafkaService and call its start method to start both the Kafka broker and ZooKeeper server. After running our Kafka producer and consumer tests, we call the service's stop method to shut down the Kafka cluster.
The KafkaService class takes several optional parameters for configuring the Kafka broker and ZooKeeper server, such as port numbers and log directories.
The KafkaTest package can be installed via pip:
pip install kafkatest
Python KafkaService.start - 60 examples found. These are the top rated real world Python examples of kafkatest.services.kafka.KafkaService.start extracted from open source projects. You can rate examples to help us improve the quality of examples.