Skip to content

test(oauthlogin): reuse probe callback connection - #2636

Merged
jbeda merged 1 commit into
mainfrom
test/oauth-probe-connection-reuse
Oct 31, 2026
Merged

jbeda merged 1 commit into
mainfrom
test/oauth-probe-connection-reuse

Conversation

@jbeda

@jbeda jbeda commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Give TestUnauthenticatedProbeFloodDoesNotAbortValidCallback one test-owned keepalive loopback client for its sequential wrong-path probes, forged-Host probes, and final valid callback.
  • Retain response-body draining/closing and close idle connections during test cleanup. Keep other tests' existing non-keepalive behavior through a small request-helper split.
  • Leave the production callback listener, four-connection limit, attempt accounting, and dedicated connection-shedding test unchanged.

Reading/closing a non-keepalive response does not synchronize with server-side connection closure and limiter-slot release. Opening a fresh connection for every sequential probe can therefore test connection shedding accidentally instead of the intended route/Host attempt-budget invariant. Reusing a connection removes that unrelated lifecycle race without retries, sleeps, or relaxed limits.

Refs #2327 (OAuth probe connection-lifecycle item; umbrella remains open).

Verification

  • Focused race stress: probe-flood test, -count=500 -cpu=1,8 (1,000 executions): passed.
  • Neighboring attempt-budget and listener-shedding tests, -race -count=100 -cpu=1,8: passed.
  • Negative control: temporarily count rejected route/Host probes against the attempt budget; the final valid callback fails with HTTP 429, as expected. Mutation reverted before full checks.
  • Independent focused review: no findings.
  • task test: passed.
  • task lint: passed, zero issues across all modules.
  • task test:race: passed.
  • go run ./cmd/mecademo: passed; observed real tool calls/results, permission ask/approval, and final result.

Stress-run caveat

The original non-keepalive test passed 500 repetitions; a subsequent 5,000-repetition baseline attempt saturated the host's 262,144-entry conntrack table. Failures during that saturation are not evidence of the callback-limiter race. The table drained naturally; no host settings or entries were changed. A bounded comparison after recovery measured +799 entries for 800 fresh connections versus +50 entries for 3,250 probe-test requests over 50 keepalive connections. Further stress was bounded to avoid repeating the host-wide resource exhaustion.

API compatibility

Test-only change. No production behavior, wire contract, API major, feature identifiers, Go public API, or stored-data format changes; no upgrade implications.

Keep sequential unauthenticated probes and the valid callback on one test-owned keepalive client so server-side connection-close ordering does not accidentally exercise the listener concurrency cap. Preserve the request budget and connection-shedding tests.

Refs #2327

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda enabled auto-merge (squash) October 31, 2026 22:44
@jbeda
jbeda merged commit 0c28cdf into main Oct 31, 2026
38 checks passed
@jbeda
jbeda deleted the test/oauth-probe-connection-reuse branch October 31, 2026 22:48
@jbeda jbeda mentioned this pull request Nov 1, 2026
10 of 14 tasks
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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