Skip to content

test(spring-boot): [Sample Tests 16] Replace the log4j2 Boot samples' system tests with a Log4j2 suite - #6306

Merged
runningcode merged 3 commits into
mainfrom
no/delete-log4j2-boot-system-tests
Oct 23, 2026
Merged

runningcode merged 3 commits into
mainfrom
no/delete-log4j2-boot-system-tests

Conversation

@runningcode

@runningcode runningcode commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Stack (Sample Tests)


📜 Description

Deletes the system tests of sentry-samples-spring-boot-jakarta-log4j2 and sentry-samples-spring-boot-4-log4j2, and takes both samples off the system-test runner and the backend workflow. Their app code stays as examples. Their one Log4j2-specific check moves to a new integrationTestLog4j2 suite in sentry-spring-boot-jakarta and sentry-spring-boot-4.

Everything else was a byte-for-byte copy of the plain samples' tests, which now run in the integrationTest suites of sentry-spring-boot-jakarta and sentry-spring-boot-4. There was one exception:

  • The one extra assertion: the log4j2 variants' PersonSystemTest also checked that the logged error carries the Log4j integration, i.e. that Boot wired Sentry's Log4j2 appender.
  • What already covered parts of it:
    • SentryLog4j2AppenderAutoConfigurationTest in both modules checks that Spring Boot attaches the appender, and with which settings.
    • sentry-log4j2's SentryAppenderTest checks that the appender's events carry the integration.

After a coverage audit against the sample's tests:

  • What those tests missed. No test sent an event through the auto-configured appender to a server; the tests above use a mocked or no-op transport. integrationTestLog4j2 runs a servlet app with Log4j2 instead of Logback, swapped with Gradle's module replacement as Spring Boot documents. It logs an error through SLF4J and checks that the error reaches MockSentryServer with the request's feature flag and the Log4j integration. Sentry only attaches the appender with sentry.logging.enabled=true, which the samples set.
  • The module replacement only acts on a classpath with both starters, which only this suite has. The suite is in the Spring Boot 3 and 4 matrices.

💡 Motivation and Context

These two samples had 19 duplicated test classes between them, and they needed the Python runner, a packaged app and a Kafka container.

💚 How did you test it?

  • Both slimmed samples still build.
  • I checked the only difference between the log4j2 and plain PersonSystemTest with a diff.
  • integrationTestLog4j2 passes in both modules, also on Spring Boot 3.2.12 and 4.0.0. Without sentry.logging.enabled=true, its logged-error test fails because no event arrives.

📝 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 WebFlux samples.

#skip-changelog

@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.1 (1) release

⚙️ sentry-android Build Distribution Settings

This was referenced Oct 20, 2026
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 7473271 to 7b862db Compare October 22, 2026 13:31
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from 39df936 to ea995a8 Compare October 22, 2026 14:02
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 7b862db to 0e8e63c Compare October 22, 2026 14:02
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from ea995a8 to 20cb23c Compare October 22, 2026 16:02
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 0e8e63c to 0dd9a37 Compare October 22, 2026 16:02
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from 20cb23c to dc5d79e Compare October 23, 2026 08:24
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 0dd9a37 to 411f8e5 Compare October 23, 2026 08:24
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from dc5d79e to 34f896b Compare October 23, 2026 08:58
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 411f8e5 to 13cce21 Compare October 23, 2026 08:58
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from 34f896b to 922c453 Compare October 23, 2026 09:35
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 13cce21 to 7658695 Compare October 23, 2026 09:35
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from 922c453 to 99c94c8 Compare October 23, 2026 11:51
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 7658695 to 0d7fbb8 Compare October 23, 2026 11:51
@runningcode
runningcode force-pushed the no/integration-tests-aggregate branch from 99c94c8 to c8fb997 Compare October 23, 2026 12:48
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch 2 times, most recently from cac3297 to 0e2c0b7 Compare October 23, 2026 13:02
@runningcode
runningcode changed the base branch from no/integration-tests-aggregate to no/boot2-graphql-kafka-test October 23, 2026 13:02
Base automatically changed from no/boot2-graphql-kafka-test to main October 23, 2026 13:18
The jakarta-log4j2 and 4-log4j2 samples' system tests were copies of the
plain samples' tests, which now run in the modules' integrationTest
suites. The only addition was a check that a logged error carries the
Log4j integration. That's covered by SentryLog4j2AppenderAutoConfigurationTest,
which checks the appender Spring Boot attaches, and by sentry-log4j2's
own tests of what the appender sends.

Both samples come off the system-test runner and the backend workflow.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The log4j2 Boot samples' tests were removed as covered elsewhere, but
nothing else sends an event through the Log4j2 appender that Spring
Boot's auto-configuration attaches. integrationTestLog4j2, in
sentry-spring-boot-jakarta and sentry-spring-boot-4, runs a servlet app
with Log4j2 instead of Logback and checks that an error logged through
SLF4J reaches Sentry with the request's feature flag and the Log4j
integration, as the samples' Person test did.

Gradle's module replacement swaps the starters, as Spring Boot
documents. It only acts on a classpath with both, which only this
suite has.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode force-pushed the no/delete-log4j2-boot-system-tests branch from 0e2c0b7 to 0523822 Compare October 23, 2026 13:28
@runningcode
runningcode marked this pull request as ready for review October 23, 2026 13:35
… tests into the module (#6308)

* test(spring-boot): Move the Boot 3 WebFlux sample's tests into the module

Adds an integrationTestWebflux suite to sentry-spring-boot-jakarta. It
runs a reactive app without the servlet stack, so Spring Boot starts a
WebFlux server, and ports the WebFlux sample's Person,
DistributedTracing, Todo and GraphQL tests. The sample's Cache and
Metrics tests were copies of the servlet ones and don't depend on the
web stack, so the integrationTest suite already covers them.

The WebFlux sample has no system tests left, so it comes off the
system-test runner, the backend workflow and the Spring Boot 3 matrix,
which now runs the new suite.

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

* test(spring-boot): Tighten the Boot 3 WebFlux tracing checks and restore Cache and Metrics

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

* test(spring-boot): Return a Mono from the Boot 3 WebFlux GraphQL resolver

The sample's resolver returned a Mono, so its test covered Sentry
finishing the field's span when the Mono completes. The port returned a
String, which only covers the synchronous path.

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

* test(spring-boot): [Sample Tests 18] Move the Boot 4 WebFlux sample's tests into the module (#6310)

* test(spring-boot): Move the Boot 4 WebFlux sample's tests into the module

Adds an integrationTestWebflux suite to sentry-spring-boot-4 that
mirrors the Boot 3 one, adjusted for Spring Boot 4: the webclient
starter for WebClient.Builder, the restclient starter that
TestRestTemplate needs, Jackson 3, and @AutoConfigureTestRestTemplate.
The Todo test reads the port with @LocalServerPort because
TestRestTemplate's root URI doesn't hold the port on Boot 4.0.

The Boot 4 WebFlux sample has no system tests left, so it comes off the
system-test runner, the backend workflow and the Spring Boot 4 matrix,
which now runs the new suite.

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

* test: Port the audit fixes to Boot 4 WebFlux

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

* test(spring-boot): Return a Mono from the Boot 4 WebFlux GraphQL resolver

The sample's resolver returned a Mono, so its test covered Sentry
finishing the field's span when the Mono completes. The port returned a
String, which only covers the synchronous path.

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

* test(spring-boot): [Sample Tests 19] Move the Boot 2 WebFlux sample's tests into the module (#6311)

* test(spring-boot): Move the Boot 2 WebFlux sample's tests into the module

Adds an integrationTestWebflux suite to sentry-spring-boot that mirrors
the Boot 3 one, without the Reactor thread-local accessor that Spring
Boot 2's Reactor lacks. The GraphQL greeting lives in its own file so
the suite can leave it out below Spring Boot 2.7, like the servlet
suite's GraphQL.

The Boot 2 WebFlux sample has no system tests left, so it comes off the
system-test runner, the backend workflow and the Spring Boot 2 matrix,
which now runs the new suite.

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

* test(spring-boot): Tighten the Boot 2 WebFlux tracing checks and restore Metrics

Ports the tracing checks and the plain test client from the servlet
suite, and runs the WebFlux sample's Metrics tests in the reactive app
too, rather than only in the servlet suite.

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

* test(spring-boot): Return a Mono from the Boot 2 WebFlux GraphQL resolver

The sample's resolver returned a Mono, so its test covered Sentry
finishing the field's span when the Mono completes. The port returned a
String, which only covers the synchronous path.

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

* test(spring-boot): [Sample Tests 20] Move the Boot 3 OTel no-agent sample's tests (#6312)

* test(spring-boot): Move the Boot 3 OTel no-agent sample's tests into the module

Adds an integrationTestOtelNoAgent suite to sentry-spring-boot-jakarta.
The app traces through the OpenTelemetry SDK in its own JVM, set up by
sentry-opentelemetry-agentless-spring, and the suite ports the no-agent
sample's tests: spans from the OTel annotation, the OTel API and the
Sentry API with their feature flags, the OTel database span, trace
continuation, client spans, cache spans, GraphQL, and Kafka traced by
OTel instead of Sentry's Spring Kafka integration. The sample's Metrics
tests were copies of the servlet ones and don't depend on tracing.

The suite needs a TestRestTemplate built outside the context: the one
Spring Boot provides is instrumented by the OTel starter, which replaced
the trace headers the tests send and started a new trace.

Sentry exports OTel spans in batches every 5 seconds, so every test
waited that long. MockSentryServer gets a hook that runs before each
check while waiting, which the suite uses to flush the tracer provider,
taking the suite from about 112s to 8s of test time.

The sample has no system tests left, so it comes off the system-test
runner, the backend workflow and the Spring Boot 3 matrix, which now
runs the new suite.

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

* test(spring-boot): Rejoin a wrapped comment in the Boot 3 OTel no-agent suite

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

* test: Port the audit fixes to Boot 3 no-agent

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

* test(spring-boot): [Sample Tests 21] Move the Boot 4 OTel no-agent sample's tests (#6313)

* test(spring-boot): Move the Boot 4 OTel no-agent sample's tests into the module

Adds an integrationTestOtelNoAgent suite to sentry-spring-boot-4, the
Boot 4 counterpart of the Boot 3 one: the app traces through the
OpenTelemetry SDK in its own JVM, set up by
sentry-opentelemetry-agentless-spring. The sample's tests were the same
as the Boot 3 sample's, minus Cache, so the suite is the Boot 3 one with
Boot 4's packages and no Cache test. Its Metrics tests were copies of
the servlet ones and don't depend on tracing.

The sample has no system tests left, so it comes off the system-test
runner, the backend workflow and the Spring Boot 4 matrix, which now
runs the new suite.

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

* test: Port the audit fixes to Boot 4 no-agent

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

* test(spring-boot): [Sample Tests 22] Move the Boot 2 OTel no-agent sample's tests (#6314)

* test(spring-boot): Move the Boot 2 OTel no-agent sample's tests into the module

Adds an integrationTestOtelNoAgent suite to sentry-spring-boot, the
Boot 2 counterpart of the Boot 3 one. The sample's tests were the Boot 3
sample's minus Cache and RestClient, which Boot 2 doesn't have.
GraphQL and Kafka are gated on Boot 2.7, as in the servlet suite, and
Kafka gets a context of its own.

Sentry is global, so a second live context re-initializes it with that
context's OpenTelemetry SDK, and the Sentry API spans of the first
context's tests went to the wrong one. Each test class therefore starts
its own context and closes it afterwards.

The sample has no system tests left, so it comes off the system-test
runner and the Spring Boot 2 matrix, which now runs the new suite, and
the backend workflow's base row moves to the console sample.

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

* test(spring-boot): Port the tracing and GraphQL checks to Boot 2 no-agent and restore Metrics

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

* test(spring-boot): [Sample Tests 23] Port the Boot 3 OTel agent sample's Person, tracing and Todo tests (#6315)

* test(spring-boot): Port the Boot 3 OTel agent sample's Person, tracing and Todo tests

The agent tests now start the fixture app once per test JVM and share
it, because it takes seconds to start. Which mode initializes Sentry is
a property of the test task, so the suite's task runs with the agent
initializing it and a new integrationTestOtelAgentWithoutAutoInit task
runs the same tests with the Spring Boot starter doing it. Gradle runs
the two in parallel.

The fixture gains the Person POST, distributed tracing and Todo
endpoints, and the suite ports the agent sample's Person,
DistributedTracing and Todo tests. Sentry exports the agent's spans in
batches every 5 seconds, which can't be configured, so each test waits
for the next batch and the negative tracing check waits past one.

ChildJvmApp now copies the app's output into the test's as it arrives
instead of printing it on close. The shared app is closed when the JVM
exits, where its whole log would otherwise land on the console.

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

* test: Port the audit fixes to the Boot 3 agent

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

* test(spring-boot): [Sample Tests 24] Port the rest of the Boot 3 OTel agent sample's tests (#6316)

* test(spring-boot): Port the rest of the Boot 3 OTel agent sample's tests

The agent fixture gains the Cache, Metrics, GraphQL and Kafka
endpoints, and the agent suite ports the sample's remaining tests in
both init modes. The agent traces each GraphQL operation as one span
named after it, so the queries are named. Kafka uses an in-JVM KRaft
broker that the test JVM starts next to the app.

The sample has no system tests left, so it comes off the system-test
runner, the backend workflow and the Spring Boot 3 matrix. The matrix
no longer builds the agent separately, because the suites build the
jar they attach.

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

* test(spring-boot): Check the Boot 3 agent GraphQL task query's assignee and creator ids

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

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

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@runningcode
runningcode merged commit 244b092 into main Oct 23, 2026
63 of 65 checks passed
@runningcode
runningcode deleted the no/delete-log4j2-boot-system-tests branch October 23, 2026 15:08
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.

2 participants