fix(ci): backend test suite 25-min timeout — management port TIME_WAIT regression from #576 #593

Closed
opened 2026-05-15 08:52:00 +02:00 by marcel · 0 comments
Owner

Problem

Backend tests suddenly jumped from ~5 min to ~25 min after PR #576 added management.server.port: 8081 (fixed port) to application.yaml.

Root cause

Four test classes use @DirtiesContext(AFTER_EACH_TEST_METHOD):

  • PersonServiceIntegrationTest (4 methods)
  • DocumentSearchPagedIntegrationTest (5 methods)
  • AuditServiceIntegrationTest (2 methods)
  • GeschichteServiceIntegrationTest (3 methods)

That is 14 context-restarts + 8 initial @SpringBootTest startups = ~22 management server bind/release cycles on port 8081.

The OS keeps the port in TIME_WAIT for ~45–60 s after each release. The next context startup blocks until the OS releases the port. With 22 cycles: ~17 min of pure socket-wait overhead.

Before #576 the management port was random (Spring default), so each restart picked a free port and there were no conflicts.

The Maven surefire timeout (forkedProcessTimeoutInSeconds=600) fires at 10 min even though all 1601 tests pass.

Fix

Add management.server.port: 0 to backend/src/test/resources/application-test.yaml.

0 means "let the OS pick a random free port" — each Spring context gets its own port, so no TIME_WAIT conflicts, and the suite returns to ~5 min.

Acceptance criteria

  • ./mvnw test completes in under 10 minutes on the NAS runner
  • All existing tests still pass
  • management.server.port: 0 is set in application-test.yaml
## Problem Backend tests suddenly jumped from ~5 min to ~25 min after PR #576 added `management.server.port: 8081` (fixed port) to `application.yaml`. ### Root cause Four test classes use `@DirtiesContext(AFTER_EACH_TEST_METHOD)`: - `PersonServiceIntegrationTest` (4 methods) - `DocumentSearchPagedIntegrationTest` (5 methods) - `AuditServiceIntegrationTest` (2 methods) - `GeschichteServiceIntegrationTest` (3 methods) That is 14 context-restarts + 8 initial `@SpringBootTest` startups = **~22 management server bind/release cycles on port 8081**. The OS keeps the port in `TIME_WAIT` for ~45–60 s after each release. The next context startup blocks until the OS releases the port. With 22 cycles: **~17 min of pure socket-wait overhead**. Before #576 the management port was random (Spring default), so each restart picked a free port and there were no conflicts. The Maven surefire timeout (`forkedProcessTimeoutInSeconds=600`) fires at 10 min even though all 1601 tests pass. ## Fix Add `management.server.port: 0` to `backend/src/test/resources/application-test.yaml`. `0` means "let the OS pick a random free port" — each Spring context gets its own port, so no `TIME_WAIT` conflicts, and the suite returns to ~5 min. ## Acceptance criteria - [ ] `./mvnw test` completes in under 10 minutes on the NAS runner - [ ] All existing tests still pass - [ ] `management.server.port: 0` is set in `application-test.yaml`
marcel added this to the Observability Stack — Grafana LGTM + GlitchTip milestone 2026-05-15 08:52:00 +02:00
marcel added the P1-highbugdevops labels 2026-05-15 08:52:07 +02:00
Sign in to join this conversation.
No Label P1-high bug devops
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: marcel/familienarchiv#593