Aiven-Open / Aiven-Open/kafka-testkit

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

Aperta
#6 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

# 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.

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.