Skip to content

CICD-339 · Kafka integration testing ​

Encyclopedia · Distributed systems and reliability testing · All snippets

Previous · CICD-338 · Next · CICD-340

1. Where it fits ​

  • Placement CI run step or authorized lab terminal.
  • Prerequisites disposable integration environment, synthetic traffic and controlled test faults.
  • Platforms local-linux, github-actions, gitea-actions.
  • Parameters GITHUB_RUN_ID, KAFKA_BOOTSTRAP.

2. Copy the snippet ​

bash
topic="ci-${GITHUB_RUN_ID:-local}"
kafka-topics.sh --bootstrap-server "${KAFKA_BOOTSTRAP:?}" --create --if-not-exists --topic "$topic" --partitions 1 --replication-factor 1
printf '%s\n' fixture | kafka-console-producer.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --topic "$topic"
kafka-console-consumer.sh --bootstrap-server "$KAFKA_BOOTSTRAP" --topic "$topic" --from-beginning --max-messages 1 --timeout-ms 10000 | grep -Fx fixture

3. How it works ​

An isolated topic carries one synthetic message. The consumer must receive the exact value within the test deadline, which verifies the declared broker route.

4. Verify the result ​

Use an isolated topic and clean up by test lifecycle. Validate publish and delivery before testing consumer lag.

Validation syntax-validated (Bash parse). Status definitions.