Skip to content

test(examples): wait for the refused session's release before disconnecting - #72

Merged
sunib merged 1 commit into
mainfrom
fix/comparison-test-connection-race
Oct 6, 2026
Merged

sunib merged 1 commit into
mainfrom
fix/comparison-test-connection-race

Conversation

@sunib

@sunib sunib commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Why

The release PR #71 is blocked by a flaky kube adapter (go) check:

--- FAIL: TestGatewayRouteRefusesAndDisconnects
    comparison_test.go:251: closed 2 gateway connections, want 1

The refused session's handler flushes its terminal FORBIDDEN frame and only then runs its deferred release(), which removes it from the connection registry. The test reads the frame, closes the body and immediately forces a disconnect, so on a slow runner the refused connection can still be registered and gets counted.

What

Test-only change: after closing the refused session, wait (up to 5s) until no gateway connection is registered before forcing the disconnect. A small openConnections helper counts registered connections by kind.

Verification

  • Injecting a 50ms delay before release() in gateway.go reproduces the exact CI failure with the old test; the new test passes under the same delay (delay not committed).
  • go test -race ./... in gateway/kube passes; the comparison package passes 300 runs under -race.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Updated gateway route test coverage to account for delayed connection cleanup after a refused session. The test now waits up to five seconds for the connection to be released before continuing and resets its cleanup deadline after a forced disconnect. These changes affect test behavior only; no user-facing functionality changes are included.

…ecting

TestGatewayRouteRefusesAndDisconnects flaked in CI with "closed 2 gateway
connections, want 1". The refused session's handler flushes its terminal
frame before its deferred release removes it from the connection registry,
so on a slow runner the forced disconnect could still count it. Wait for
the registry to drop it first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75d0bc0a-f9ba-45ca-85ff-c1c1c2584324
📥 Commits

Reviewing files that changed from the base of the PR and between 14d4ff4 and a1f60dd.

📒 Files selected for processing (1)
  • gateway/kube/examples/comparison/comparison_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The gateway comparison test now waits for refused-session connections to close, adds a connection-count helper, and resets the forced-disconnect cleanup deadline.

Changes

Gateway connection cleanup

Layer / File(s) Summary
Connection cleanup checks
gateway/kube/examples/comparison/comparison_test.go
The test polls for registered gateway connections after closing a refused session, with a five-second timeout and 10-millisecond intervals. A helper counts connections by kind under the connection mutex. The forced-disconnect cleanup deadline is reset.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to a1f60

The test waits for the refused session to be released before starting the viewer request. The reviewed change presents no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: the test waits for the refused session to release before disconnecting.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sunib
sunib merged commit bae6c0f into main Oct 6, 2026
13 checks passed
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