Skip to content

Commit 22bca33

Browse files
authored
Merge pull request #5347 from getsentry/fix/kafka-system-test-stale-container
fix(test): [Queue Instrumentation 39] Remove stale Kafka container before startup
2 parents d1b0233 + 60d8460 commit 22bca33

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

test/system-test-runner.py

Lines changed: 11 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:
@@ -439,6 +442,7 @@ def start_spring_server(self, sample_module: str, java_agent: str, java_agent_au
439442

440443
if self.module_requires_kafka_profile(sample_module):
441444
env["SPRING_PROFILES_ACTIVE"] = "kafka"
445+
env["SENTRY_ENABLE_QUEUE_TRACING"] = "true"
442446
print("Enabling Spring profile: kafka")
443447
else:
444448
env.pop("SPRING_PROFILES_ACTIVE", None)

0 commit comments

Comments
 (0)