test(mcpgateway): wait for the background session close before the recovery check

SA
3d ago
+6-0

Description

TestHostEndsASessionItCannotRecheckForLong failed intermittently in CI with expected: 404, actual: 200 on its last request (for example on #1621, which does not touch internal/mcpgateway).

When the host ends a session it could not recheck, it unbinds it and closes the SDK session in the background (closeSessions). The test's next request finds no binding and no shared record, so it is passed to the SDK handler; if the background close has not finished yet, the SDK still knows the session and answers 200.

The test now waits for the hosted session to close before that request, as TestLongCallDoesNotReviveADeletedSession already does. Test-only change.

Delaying the background close by 30 ms reproduces the failure on every run; with the fix the whole package passes under the same delay.

Summary by CodeRabbit

  • Tests
    • Expanded coverage for long outages to verify that a hosted session is closed after its host reaches the unverified limit, rather than only being unbound. No user-facing behavior changes are included in this update.