Skip to content

Commit 327df95

Browse files
adinauerclaude
andcommitted
fix(test): Enable Kafka profile for Spring Kafka system tests
Make the system test runner configure Kafka requirements by module. Start Kafka and set SPRING_PROFILES_ACTIVE=kafka for modules that need Kafka-backed Spring endpoints so queue system tests run with the expected routing and broker configuration. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2844be7 commit 327df95

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/system-test-runner.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@
6868

6969
KAFKA_CONTAINER_NAME = "sentry-java-system-test-kafka"
7070
KAFKA_BOOTSTRAP_SERVERS = "localhost:9092"
71+
KAFKA_BROKER_REQUIRED_MODULES = {
72+
"sentry-samples-console",
73+
"sentry-samples-spring-boot-jakarta",
74+
}
75+
KAFKA_PROFILE_REQUIRED_MODULES = {
76+
"sentry-samples-spring-boot-jakarta",
77+
}
7178

7279
class ServerType(Enum):
7380
TOMCAT = 0
@@ -202,7 +209,10 @@ def kill_process(self, pid: int, name: str) -> None:
202209
print(f"Process {pid} was already dead")
203210

204211
def module_requires_kafka(self, sample_module: str) -> bool:
205-
return sample_module == "sentry-samples-console"
212+
return sample_module in KAFKA_BROKER_REQUIRED_MODULES
213+
214+
def module_requires_kafka_profile(self, sample_module: str) -> bool:
215+
return sample_module in KAFKA_PROFILE_REQUIRED_MODULES
206216

207217
def wait_for_port(self, host: str, port: int, max_attempts: int = 20) -> bool:
208218
for _ in range(max_attempts):
@@ -423,6 +433,12 @@ def start_spring_server(self, sample_module: str, java_agent: str, java_agent_au
423433
env.update(SENTRY_ENVIRONMENT_VARIABLES)
424434
env["SENTRY_AUTO_INIT"] = java_agent_auto_init
425435

436+
if self.module_requires_kafka_profile(sample_module):
437+
env["SPRING_PROFILES_ACTIVE"] = "kafka"
438+
print("Enabling Spring profile: kafka")
439+
else:
440+
env.pop("SPRING_PROFILES_ACTIVE", None)
441+
426442
# Build command
427443
jar_path = f"sentry-samples/{sample_module}/build/libs/{sample_module}-0.0.1-SNAPSHOT.jar"
428444
cmd = ["java"]

0 commit comments

Comments
 (0)