Skip to content

Add transaction tests for KafkaContainer and ConfluentKafkaContainer - #12102

Open
aymenjam wants to merge 1 commit into
testcontainers:mainfrom
aymenjam:test/kafka-transactions
Open

aymenjam wants to merge 1 commit into
testcontainers:mainfrom
aymenjam:test/kafka-transactions

Conversation

@aymenjam

@aymenjam aymenjam commented Oct 4, 2026 •

Copy link
Copy Markdown

Kafka transactions need transaction.state.log.replication.factor and transaction.state.log.min.isr set to 1 on a single broker. Without them, initTransactions() times out while waiting for InitProducerId.

KafkaContainer and ConfluentKafkaContainer already set these values, but no test checks it. This PR adds a test for each class. The test commits a transaction and reads the message with a read_committed consumer.

Refs #1816

Summary by CodeRabbit

  • Tests
    • Expanded Kafka container test coverage to verify that committed transactional messages are received by consumers configured to read committed records. The checks run against both Confluent Kafka and Apache Kafka containers.

@aymenjam
aymenjam requested a review from a team as a code owner October 4, 2026 14:06
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 96dfbafb-59b6-4685-a288-1711129cab31
📥 Commits

Reviewing files that changed from the base of the PR and between 8e54951 and ea074e5.

📒 Files selected for processing (3)
  • modules/kafka/src/test/java/org/testcontainers/AbstractKafka.java
  • modules/kafka/src/test/java/org/testcontainers/kafka/ConfluentKafkaContainerTest.java
  • modules/kafka/src/test/java/org/testcontainers/kafka/KafkaContainerTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Adds a shared Kafka test that commits a record in a transaction and checks that a read_committed consumer receives it. The test runs against Confluent Kafka and Apache Kafka containers.

Changes

Kafka Transaction Test Coverage

Layer / File(s) Summary
Shared transactional test
modules/kafka/src/test/java/org/testcontainers/AbstractKafka.java
Creates a topic, sends and commits a record in a transaction, and asserts that a read_committed consumer receives exactly that record within 10 seconds.
Container implementation coverage
modules/kafka/src/test/java/org/testcontainers/kafka/ConfluentKafkaContainerTest.java, modules/kafka/src/test/java/org/testcontainers/kafka/KafkaContainerTest.java
Adds tests that run the shared transactional test against Confluent Kafka 7.4.0 and apache/kafka-native:3.8.0.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Suggested reviewers: eddumelendez

Merge Risk: ⚪ Minimal · up to ea074

This change only adds tests for Kafka transactions on both container types and does not change production behavior. No merge-blocking risk was found.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: adding transaction tests for both Kafka container classes.
Description check ✅ Passed The description explains the single-broker transaction issue, the tests being added, and the purpose of the change. It also references issue #1816.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant