Aiven-Open / Aiven-Open/kafka-testkit

Stabilize Kafka test startup by removing race-prone ephemeral port discovery in KafkaConnectRunner

Offen
#6 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Java
Sterne
0
Forks
0
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

# What happened?

In `KafkaConnectRunner`, `findListenerPorts()` discovers candidate ports by opening `ServerSocket(0)`, reading assigned ports, and then closing the sockets before Kafka binds.

This creates a race window: another process/test can claim one or more of those ports before Kafka starts. The recent change increases this from 2 to 3 ports (listeners + KRaft controller), which increases the probability of test flakiness under parallel or busy environments.

Observed risk:
- Intermittent startup failures due to bind conflicts on previously “found” ports.
- Non-deterministic CI/test behavior, especially with concurrent test execution.

# What did you expect to happen?

Port selection should be race-safe enough to improve startup stability rather than introduce/expand flake potential.

Expected behavior:
- Either reserve ports until Kafka is configured/bound, or
- Let Kafka/EmbeddedConnectCluster bind to port 0 directly and read back the effective assigned ports after startup.

This should eliminate the gap between port discovery and actual bind, reducing intermittent bind failures.

# What else do we need to know?

- Note: The Javadoc already states ports are not reserved, but current behavior still conflicts with the stabilization goal.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.