Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Verification against real brokers

The map is not the territory. Unit tests prove kacrab is self-consistent — they do not prove it is Kafka-consistent: a codec framed the wrong way, or a SASL round skipped, passes a Rust-only round trip because kacrab is on both ends. Most of the discoveries in this book — the OAUTHBEARER error round, the GSSAPI security layer, the burst wedge, the IPv6 hang, the topic-id codec traps — were found here, walking the actual territory: every path exercised end-to-end against real Apache Kafka, with the environments captured as docker-compose.*.yml files.

Across four broker releases, not one

The suites below run against Apache Kafka 4.3.0 by default, but every compose file reads ${KAFKA_IMAGE:-apache/kafka:4.3.0}, and .github/workflows/real-broker.yml matrixes the base job over four releases:

LegImageCompose fileSuite
4.3.0apache/kafka:4.3.0docker-compose.kafka.ymlfull (blocking)
4.0.0apache/kafka:4.0.0docker-compose.kafka.ymlcore
3.9.0apache/kafka:3.9.0docker-compose.kafka.ymlcore
3.6.2bitnamilegacy/kafka:3.6.2docker-compose.kafka-bitnami.ymlcore

docker-compose.kafka-bitnami.yml exists because apache/kafka publishes no tag older than 3.7. It is a second file rather than an overlay: Bitnami configures the broker through KAFKA_CFG_* variables instead of the KAFKA_* shape the Apache image reads, and an overlay can only add keys — it cannot drop the Apache-shaped ones, which would then sit in the environment doing nothing while reading as if they applied.

Every leg runs every suite unfiltered, and every leg blocks: tests that need an API an old broker does not serve — KIP-848, the share consumer — carry a require_broker_api! guard and self-skip with a named SKIPPED line. Which surfaces run on which release (the per-surface floor table), how the guard works, and what the golden ApiVersions fixtures prove offline is all in Which brokers kacrab speaks to.

Quote

“A few minutes of docker compose proves a path works; proving it holds up needs hours of load.” — see Benchmarks and the production acceptance plan.

SASL — every mechanism

docker-compose.auth.yml (a single broker with PLAIN + SCRAM-256/512 + OAUTHBEARER) and docker-compose.gssapi.yml (a real MIT Kerberos KDC + a GSSAPI broker). Each mechanism authenticates and runs ApiVersions; negative cases confirm rejection is fast and clear.

MechanismResult
PLAIN✅ + wrong password rejected (fast)
SCRAM-SHA-256 / -512✅
OAUTHBEARER✅ + expired token rejected (error round)
GSSAPI✅ via real KDC (security-layer round)

TLS — SSL, SASL_SSL, mutual TLS

docker-compose.tls.yml publishes three listeners; certs are generated by scripts/gen-tls-certs.sh. One-way SSL, SASL/SCRAM over TLS, and mutual TLS all authenticate; an untrusted server certificate is rejected fast with the rustls reason.

Compression — every codec, proven on disk

The decisive test: produce gzip/snappy/lz4/zstd batches, then verify three things end to end — the broker accepts the produce, kafka-dump-log shows the on-disk batch stored with the correct codec (so a silently-uncompressed send would fail), and kafka-console-consumer decompresses the exact payloads back.

on-disk batch codecs: [gzip×3, snappy×3, lz4×3, zstd×3]
all 12 compressed records round-tripped through the broker and CLI consumer

Consumer — groups, offsets, and both protocols

kacrab/tests/real_kafka_consumer.rs (12 tests, --test-threads=1) walks the consumer surface against a real broker: manual assignment and commit round-trips; one subscriber owning a whole topic; two consumers splitting it via a real rebalance; cooperative-sticky converging with no double-owned partition; the roundrobin assignor; pattern subscription; interceptors; offset queries and lag; async commits landing in call order; seek-past-end recovering; and a KIP-848 (group.protocol=consumer) member joining, consuming, and committing through ConsumerGroupHeartbeat. See the consumer chapters for what each proves.

Share consumer — acquisition, acknowledgement & redelivery

kacrab/tests/real_kafka_share_consumer.rs runs on the same docker-compose.kafka.yml broker, whose share.version feature finalizes at 1, so KIP-932 share groups are on without a special fixture. Share groups are almost entirely broker-side behaviour, so this suite — not a unit test — is what proves the surface works: implicit and explicit acknowledgement end to end; Accept/Release/Reject (the Released record returns, the Rejected one does not); delivery counts climbing to the broker’s archive limit; three consumers on a one-partition topic consuming every record exactly once, the case a consumer group cannot serve; acquisition-lock expiry redelivering the records of a consumer that went away without acknowledging; and the admin share-group operations reading back the live group.

Multi-broker — dispatch & leadership-change

docker-compose.cluster.yml runs a 3-broker KRaft cluster. The tests confirm records route to every broker’s leaders, and that a broker loss re-routes affected partitions to their new leaders without wedging the healthy partitions batched alongside them — the bug described in Idempotency & transactions and Failure modes. A 6-partition burst across a broker loss delivers 6/6.

Admin — the full operation surface

docker-compose.kafka.yml (core ops), docker-compose.kafka-admin.yml (a broker with StandardAuthorizer and the share/streams features, for ACLs and the Kafka 4.x group families), and docker-compose.auth.yml (SASL, for delegation tokens) back kacrab/tests/real_kafka_admin*.rs. Every one of the 62 admin operations is exercised across all four routing paths (controller, coordinator, per-leader, broadcast). Operations that need cluster state the test cannot create are asserted at the wire layer — a well-formed broker error code proves correct encode/decode. On the older matrix legs the smoke half is capability-aware: an operation the broker genuinely cannot express (list_config_resources(Topic) on 3.9.0 and 3.6.2, list_client_metrics_resources on 3.6.2) is reported as a named SKIPPED line plus a capability summary rather than a failure — see Which brokers kacrab speaks to. This pass caught real wire bugs the unit tests could not: an empty ApiVersions client name, the OffsetCommit/OffsetFetch v10 topic-name-vs-id switch, and the missing transient-coordinator-error retry (see The admin client).

Note

These are #[ignore] integration tests — they need the compose environments and (for the cluster/compression cases) the docker CLI. They are not part of the default cargo test run; CI runs the in-process suite.