Skip to content

Commit 00d11a0

Browse files
adinauerclaude
andcommitted
fix(test): Remove stale Kafka container before startup
Always remove the named Kafka system-test container before starting a new broker. This avoids docker name conflicts after crashed or interrupted runs while still keeping stop_kafka_broker ownership-aware for reused brokers. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1411bb7 commit 00d11a0

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

test/system-test-runner.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,21 @@ def wait_for_port(self, host: str, port: int, max_attempts: int = 20) -> bool:
227227
time.sleep(1)
228228
return False
229229

230+
def remove_kafka_broker_container(self) -> None:
231+
subprocess.run(
232+
["docker", "rm", "-f", KAFKA_CONTAINER_NAME],
233+
check=False,
234+
stdout=subprocess.DEVNULL,
235+
stderr=subprocess.DEVNULL,
236+
)
237+
230238
def start_kafka_broker(self) -> None:
231239
if self.wait_for_port("localhost", 9092, max_attempts=1):
232240
print("Kafka broker already running on localhost:9092, reusing it.")
233241
self.kafka_started_by_runner = False
234242
return
235243

236-
self.stop_kafka_broker()
244+
self.remove_kafka_broker_container()
237245

238246
print("Starting Kafka broker (Redpanda) for system tests...")
239247
run_result = subprocess.run(
@@ -280,12 +288,7 @@ def stop_kafka_broker(self) -> None:
280288
if not self.kafka_started_by_runner:
281289
return
282290

283-
subprocess.run(
284-
["docker", "rm", "-f", KAFKA_CONTAINER_NAME],
285-
check=False,
286-
stdout=subprocess.DEVNULL,
287-
stderr=subprocess.DEVNULL,
288-
)
291+
self.remove_kafka_broker_container()
289292
self.kafka_started_by_runner = False
290293

291294
def start_sentry_mock_server(self) -> None:

0 commit comments

Comments
 (0)