Skip to content

test: isolate kafka tests from host env#4561

Draft
pellared wants to merge 6 commits into
mainfrom
fix-4537
Draft

test: isolate kafka tests from host env#4561
pellared wants to merge 6 commits into
mainfrom
fix-4537

Conversation

@pellared

@pellared pellared commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Fixes #4537

The following should make the test better isolated from the host env:

  • Remove fixed dockertest.WithName values from Kafka integration test containers
  • Remove fixed dockertest.WithHostnames values from Kafka integration test containers
  • Remove fixed dockertest.WithPortBindings values from Kafka integration test containers

This helped in making the changes: https://www.confluent.io/blog/kafka-listeners-explained/

I think creating a test network is an overkill:

  • Remove custom test network

@pellared
pellared requested review from a team as code owners April 30, 2026 18:32
@codecov-commenter

codecov-commenter commented Apr 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.24%. Comparing base (cf7ae8c) to head (c57f519).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4561   +/-   ##
=======================================
  Coverage   77.24%   77.24%           
=======================================
  Files          88       88           
  Lines        3002     3002           
=======================================
  Hits         2319     2319           
  Misses        599      599           
  Partials       84       84           
Flag Coverage Δ
Linux 76.98% <ø> (ø)
Windows 75.91% <ø> (ø)
macOS 75.98% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pellared
pellared marked this pull request as draft April 30, 2026 18:40
@pellared pellared changed the title test: avoid fixed container names test: avoid fixed container names, hostnames and custom network Apr 30, 2026
@pellared pellared changed the title test: avoid fixed container names, hostnames and custom network test: avoid fixed container names, hostnames, port bindings and custom network Apr 30, 2026
@pellared
pellared marked this pull request as ready for review April 30, 2026 19:16
@pellared pellared changed the title test: avoid fixed container names, hostnames, port bindings and custom network test: make kafka tests isolated from host env Apr 30, 2026
@pellared pellared changed the title test: make kafka tests isolated from host env test: make kafka tests more isolated from host env Apr 30, 2026
@pellared
pellared requested a review from Copilot April 30, 2026 19:17
@pellared pellared changed the title test: make kafka tests more isolated from host env test: isolate kafka tests from host env Apr 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves Kafka integration test isolation from the host environment by removing hard-coded Docker container names, hostnames, port bindings, and the custom test network.

Changes:

  • Removed fixed dockertest.WithName / dockertest.WithHostname usage for Zookeeper/Kafka containers.
  • Removed fixed host port bindings and switched to deriving connection addresses at runtime.
  • Dropped the custom Docker network and added helper logic to read container IPs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
instrumentation/github.com/confluentinc/confluent-kafka-go/v2/kafka/splunkkafka/test/kafka_test.go Makes Kafka v2 integration tests use dynamically-derived container endpoints instead of fixed names/ports/networks.
instrumentation/github.com/confluentinc/confluent-kafka-go/kafka/splunkkafka/test/kafka_test.go Applies the same isolation changes to the deprecated (non-v2) Kafka instrumentation tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MrAlias MrAlias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks cleaner from an isolation standpoint, but I want to check whether you intended to narrow the environments these tests can run in.

Both Kafka test variants now advertise and connect to the broker via the container IP (containerIP(...):9092) instead of a host-reachable published port. That works when the test process can route directly to Docker’s bridge subnet, but it stops working with remote DOCKER_HOST setups, Docker Desktop-style VM networking, and other engines where container IPs are not reachable from the host test process.

Do you understand and accept that consequence? If these tests are only meant to run against a local Linux daemon, that seems consistent with the current CI signal. If not, I think we should keep using a host-reachable endpoint for the client/bootstrap path rather than relying on container IP reachability.

@pellared

pellared commented May 1, 2026

Copy link
Copy Markdown
Contributor Author

Regarding Docker Desktop-style VM networking, I thought that container IPs are not reachable, but I may be completely wrong. I wonder if the current setup on main would work anyway. I plan to experiment on my Windows laptop 😅

@pellared
pellared marked this pull request as draft May 1, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Do not use fixed container names

4 participants