A rubbish Kafka broker, for testing simple messaging
Nafka implements just enough of the Kafka broker for simple producer/consumer code to talk to it for testing. It's designed to be convenient to launch, run some tests, and shut down again.
Usage
The package provides a pytest fixture nafka_broker. The broker is running
while the fixture is in use, and it has these attributes and methods:
nb.address: The broker address to connect to, a string like"127.0.0.1:32977"nb.topics(): Get a list of topic names for which at least 1 record exists.nb.records(topic, start_offset=0, limit=1000): Get a list of records in the given topic.nb.next_offset(topic): Get the offset for the next record to be added to the given topic.with nb.assert_produces(topic): Check that there are more records in the topic at the end of thewithblock than at the start. Usingwith ... as new_recs:also gives an iterable to inspect the new records.nb.add_record(topic, value, key=None, timestamp_ms=None): Add a record as if it was sent by a producer. The new record is sent to any waiting consumers.nb.consumer_offset(group, topic): Get the committed consumer group offset for the given group in the given topic.
The records are saved in a kafka.sqlite file in a per-test temp directory
managed by pytest - this can be useful for investigation.
Limitations
- Standalone single broker, no distributed architecture
- One partition per topic
- Not optimised for performance
- No log compaction: messages are all stored (until test cleanup removes the entire store)
- Listens only on localhost
- Many Kafka features are not implemented, only what we've needed for tests
Metadata
Release files for nafka 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nafka-0.1.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nafka-0.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 22.4 kB
Release files / nafka-0.1.tar.gz
| Download URL | nafka-0.1.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42857e8adbf4b77b92734476fca69d4a6472a55d9d30de5095bd0118e786f18f
|
|
BLAKE2b-256 checksum How to use checksums |
ba0bf4093ade2dfe8dd21353af028c156286d8305cfc89e75a046e7f5c471507
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|
Release files / nafka-0.1-py2.py3-none-any.whl
| Download URL | nafka-0.1-py2.py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
2158e953a213df6fa30fbda9ba34552ee962fe22fd978c39fedbbe52412e334c
|
|
BLAKE2b-256 checksum How to use checksums |
420fa53925bd0bcdb01649fe8462f21338ea411959cc71166cf41587c6129ab0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.32.5
|