Skip to content

Commit da7d400

Browse files
committed
fix: update system test runner for shadow JAR compatibility
- Auto-detect shadowJar vs bootJar build task based on build.gradle.kts - Add fallback HTTP readiness check for shadow JAR apps that lack actuator endpoints (actuator web endpoints don't work in flat JARs) - Append spring-autoconfigure-metadata.properties in shadow JAR config
1 parent 0e43fc7 commit da7d400

File tree

6 files changed

+38
-2
lines changed

6 files changed

+38
-2
lines changed

sentry-samples/sentry-samples-netflix-dgs/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ tasks.shadowJar {
4545
append("META-INF/spring.handlers")
4646
append("META-INF/spring.schemas")
4747
append("META-INF/spring.factories")
48+
append("META-INF/spring-autoconfigure-metadata.properties")
4849
}
4950

5051
tasks.jar {

sentry-samples/sentry-samples-spring-boot-opentelemetry-noagent/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ tasks.shadowJar {
8686
append("META-INF/spring.handlers")
8787
append("META-INF/spring.schemas")
8888
append("META-INF/spring.factories")
89+
append("META-INF/spring-autoconfigure-metadata.properties")
8990
}
9091

9192
tasks.jar {

sentry-samples/sentry-samples-spring-boot-opentelemetry/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ tasks.shadowJar {
8282
append("META-INF/spring.handlers")
8383
append("META-INF/spring.schemas")
8484
append("META-INF/spring.factories")
85+
append("META-INF/spring-autoconfigure-metadata.properties")
8586
}
8687

8788
tasks.jar {

sentry-samples/sentry-samples-spring-boot-webflux/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ tasks.shadowJar {
5555
append("META-INF/spring.handlers")
5656
append("META-INF/spring.schemas")
5757
append("META-INF/spring.factories")
58+
append("META-INF/spring-autoconfigure-metadata.properties")
5859
}
5960

6061
tasks.jar {

sentry-samples/sentry-samples-spring-boot/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ tasks.shadowJar {
8282
append("META-INF/spring.handlers")
8383
append("META-INF/spring.schemas")
8484
append("META-INF/spring.factories")
85+
append("META-INF/spring-autoconfigure-metadata.properties")
8586
}
8687

8788
tasks.jar {

test/system-test-runner.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,20 @@ def wait_for_spring(self, max_attempts: int = 20) -> bool:
418418
except:
419419
pass
420420

421+
# Fallback: shadow JAR apps may not have actuator endpoints,
422+
# so also try any HTTP connection to confirm the server is up
423+
try:
424+
response = requests.head(
425+
"http://localhost:8080/",
426+
auth=("user", "password"),
427+
timeout=5
428+
)
429+
if response.status_code is not None:
430+
print("Spring application is ready! (actuator not available)")
431+
return True
432+
except:
433+
pass
434+
421435
print(f"Waiting... (attempt {attempt}/{max_attempts})")
422436
time.sleep(1)
423437

@@ -447,6 +461,18 @@ def get_spring_status(self) -> dict:
447461
except:
448462
pass
449463

464+
if not status["http_ready"]:
465+
try:
466+
response = requests.head(
467+
"http://localhost:8080/",
468+
auth=("user", "password"),
469+
timeout=2
470+
)
471+
if response.status_code is not None:
472+
status["http_ready"] = True
473+
except:
474+
pass
475+
450476
return status
451477

452478
def get_sentry_status(self) -> dict:
@@ -528,18 +554,23 @@ def stop_spring_server(self) -> None:
528554
# Clean up PID file and instance variable
529555
cleanup_pid(self.spring_server)
530556

531-
def get_build_task(self, server_type: Optional[ServerType]) -> str:
557+
def get_build_task(self, sample_module: str, server_type: Optional[ServerType]) -> str:
532558
"""Get the appropriate build task for a module."""
533559
if server_type == ServerType.TOMCAT:
534560
return "war"
535561
elif server_type == ServerType.SPRING:
562+
# Modules using Shadow plugin (e.g. Spring Boot 2 samples) use shadowJar,
563+
# modules using Spring Boot plugin (SB3/SB4 samples) use bootJar
564+
build_file = Path(f"sentry-samples/{sample_module}/build.gradle.kts")
565+
if build_file.exists() and "shadow" in build_file.read_text():
566+
return "shadowJar"
536567
return "bootJar"
537568

538569
return "assemble"
539570

540571
def build_module(self, sample_module: str, server_type: Optional[ServerType]) -> int:
541572
"""Build a sample module using the appropriate task."""
542-
build_task = self.get_build_task(server_type)
573+
build_task = self.get_build_task(sample_module, server_type)
543574
print(f"Building {sample_module} using {build_task} task")
544575
return self.run_gradle_task(f":sentry-samples:{sample_module}:{build_task}")
545576

0 commit comments

Comments
 (0)