bbejeck opened a new pull request, #23438:
URL: https://github.com/apache/kafka/pull/23438
A lightweight Kafka wire-protocol fault-injection proxy for integration
tests. Sit it in front of an EmbeddedKafkaCluster, point any client’s
bootstrap.servers at it, and it can inject error codes, drop connections, or
blackhole a client — decoding/encoding with Kafka’s own protocol classes so it
is correct across every wire version (including flexible/tagged-field ones), no
hand-rolled byte offsets.
Placed in `clients/src/testFixtures` so it is reusable from any module. This
is internal test infrastructure only so it does not require a KIP.
Fault primitives, each armed with a fluent, deterministic trigger:
`injectError(apiKey, Errors)` — stamp an error code onto the matching
response,
re-serialized at the correct wire version. Supported APIs: `END_TXN`,
`INIT_PRODUCER_ID`, `ADD_OFFSETS_TO_TXN`, `TXN_OFFSET_COMMIT`, `PRODUCE`,
`FETCH`
(extensible by registering a per-API setter).
`disconnectOn(apiKey)` — drop the connection when the matching response
would return
(models the EOS "commit gap"). Works on any API.
`delayOn(apiKey, Duration)` — hold back the matching response to model a
slow broker,
isolated to that one connection.
`blackholeClient(clientIdSubstring)` — drop all requests from a targeted
client before
the broker sees them, so the broker evicts it by session timeout (a
reversible,
ungraceful one-node partition).
Shared trigger DSL (`Occurrence`): `once()`, `onCall`, `times`,
`everyTime()`,
`withProbability(p)`. The deterministic triggers are safe for assertions;
probability is
chaos-mode only. The proxy never closes sockets unless a `disconnectOn(...)`
rule fires,
so it is not itself a source of flakiness. Rules can be armed/disarmed live
from the test
thread and each returns a handle exposing match/fire counts.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]