Zookeeper, Kafka server, and Kafka consumer fixtures for Pytest
Project description
Pytest fixture factories for Zookeeper, Kafka server and Kafka consumer.
zookeeper_proc = make_zookeeper_process(ZOOKEEPER_BIN)
kafka_server = make_kafka_server(KAFKA_BIN, 'zookeeper_proc')
kafka_consumer = make_kafka_consumer(
'kafka_server', seek_to_beginning=True, kafka_topics=['topic'])
This creates 3 fixtures:
zookeeper_proc - Zookeeper process
kafka_server - Kafka process
kafka_consumer - usable kafka.KafkaConsumer instance
ZOOKEEPER_BIN and KAFKA_BIN are paths to launch scripts in your Kafka distribution. Check this project’s setup.py to see a way of installing Kafka for development.
It’s advised to pass seek_to_beginning=True because otherwise some messages may not be captured by the consumer. This requires knowing the topics upfront because without topics there’s no partitions to seek.
It’s possible to create multiple Kafka fixtures forming a cluster by passing the same Zookeeper fixture to them. For an example, check the tests.
Session-scoped fixtures are also available. Consult the test suite.
System requirements
Python 3.5+
JVM
Development
Execute ./setup.py develop in a virtualenv. This will take care of:
installing dependencies
updating pip
installing dev dependencies
installing Kafka to the project dir (for development only)
Acknowledgements
The library has been open-sourced from a codebase belonging to Infectious Media.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pytest_kafka-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a0abc19b03d226c17b73d3a9ea101a5510d1d9e0df45e1fbe619d37e42a4946 |
|
MD5 | 8cf34046886f66cf33b8b90741ba8f9f |
|
BLAKE2b-256 | 196f4032988cf02e34a8865f709ab3914f7e0af77309ba054e8d265a92a7de0c |