Skip to content

test(spring): [Sample Tests 27] Move the Spring jakarta WAR sample's tests into the module - #6319

Draft
runningcode wants to merge 2 commits into
no/boot2-otel-agent-integration-testfrom
no/spring-jakarta-integration-test
Draft

runningcode wants to merge 2 commits into
no/boot2-otel-agent-integration-testfrom
no/spring-jakarta-integration-test

Conversation

@runningcode

@runningcode runningcode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Adds an integrationTest suite to sentry-spring-jakarta that runs a plain Spring MVC app, without Spring Boot, in an embedded Tomcat against MockSentryServer. It ports sentry-samples-spring-jakarta's Person and Metrics tests. The sample is the first WAR sample, and this PR settles how the WAR flavor moves: an embedded-Tomcat suite rather than adding to the existing mvc/SentrySpringIntegrationTest.

Why a suite of its own. SentrySpringIntegrationTest runs on Spring Boot with a mocked transport. The WAR samples cover what it can't:

  • No-Boot setup: an AbstractAnnotationConfigDispatcherServletInitializer starts the app in a servlet container, and Sentry's SentrySpringServletContainerInitializer adds SentrySpringFilter, which it only does when Spring Boot is absent.
  • Real transport: what actually reaches Sentry over HTTP: logs, metrics, flags and profiles.
  • External configuration: the options come from sentry.properties and system properties.

How the app starts. Like a servlet container does for a WAR, the suite has Tomcat run every ServletContainerInitializer that the classpath registers through META-INF/services. Spring's initializer starts the app's initializer, and Sentry's adds SentrySpringFilter. Spring Boot is kept off the suite's classpath; only its BOM supplies versions. The tests use a plain RestTemplate, because TestRestTemplate is part of Spring Boot.

Tests:

  • Person:
    • the failed request's error with its flag, the http.server transaction and the logs;
    • creating a person, with its profile.
      The sample's separate "create person works" test was a subset of the profile test, so it's folded in. The error also has to carry its request, which only SentrySpringFilter attaches, so the test covers that path.
  • Metrics: the servlet suites' test.

Two SDK quirks the port ran into. Neither is fixed here.

  • Path check: the async profiler rejects a traces path that contains a . anywhere in its absolute form. A relative path in this worktree became …/.claude/worktrees/…, and profiling turned off. CI paths have no dot. The suite puts the path in the temp dir, like the Boot suites.
  • First start only: the profiler only checks the path on its first start. When that check fails, the first transaction goes without a profile, and later ones start the profiler anyway. So the profile test failed only when it happened to run first.

With no system tests left, the sample comes off the runner, the backend workflow and the Spring Boot 3 matrix. That was the matrix's last runner step, so the matrix also drops the Python setup, SENTRY_URL and the runner's log uploads. integrationTests includes the suite.

💡 Motivation and Context

Plain Spring, without Boot, now runs end to end in the module. The suite runs 5 tests in about 2 seconds. The sample's version started Tomcat with a WAR and slept 10 seconds before checking the logs.

💚 How did you test it?

  • All 5 tests pass on Spring Boot 3.5.0's BOM (Spring 6.2, Tomcat 10.1).
  • They also pass with the catalog set to 3.2.12 (Spring 6.1).
  • The suite's runtime classpath has no Spring Boot jar.
  • Without Sentry's initializer, the error has no request and the profile test fails.
  • With the profile test running first, it fails with a relative traces path and passes with the temp dir.
  • :sentry-spring-jakarta:check passes, and the sample's WAR still builds.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.

🔮 Next steps

The sentry-spring-7 and sentry-spring WAR samples, with the same shape.

#skip-changelog

🤖 Generated with Claude Code

Adds an integrationTest suite to sentry-spring-jakarta that runs a plain
Spring MVC app, set up by an AbstractAnnotationConfigDispatcherServletInitializer
as in a WAR, in an embedded Tomcat against MockSentryServer. Tomcat runs
every servlet container initializer the classpath registers, as it does
for a WAR, and Spring Boot stays off the classpath, so Sentry's
initializer adds SentrySpringFilter the way it does in a real
deployment. The suite ports the sample's Person and Metrics tests and
also checks that the error carries its request.

The profiler rejects a traces path with a dot anywhere in its absolute
form, so the suite puts it in the temp dir.

The sample has no system tests left, so it comes off the system-test
runner, the backend workflow and the Spring Boot 3 matrix. That was the
matrix's last runner step, so it drops the Python setup and the runner's
logs too. integrationTests includes the suite.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 20, 2026
@sentry

sentry Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.61.0 (1) release

⚙️ sentry-android Build Distribution Settings

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant