Skip to content

test(e2e): arm the console-pty session before firing Terraria path A - #572

Merged
ValgulNecron merged 1 commit into
masterfrom
fix/e2e-terraria-attach-race
Oct 5, 2026
Merged

ValgulNecron merged 1 commit into
masterfrom
fix/e2e-terraria-attach-race

Conversation

@ValgulNecron

Copy link
Copy Markdown
Collaborator

Summary

Fixes the flaky TestGameServer_TerrariaBot_Joined failure: "pod attach unreachable: console-pty WS read failed before <gs>-pathA appeared: … context deadline exceeded". It failed three times on 2026-10-05, on #561, #565 and #571, and passed each time on re-run.

Root cause (triage, about 75% confidence): runControlActionStdinPTY fired the action POST as soon as the console-pty WebSocket upgrade completed. The API starts its pod-attach session to the kubelet only after websocket.Accept. The action writes through a second, separate attach, and attach output is live-tail only. A write that landed before the console-pty reader was attached was therefore lost, and the test waited out its 30-second read. Failing runs took about 329 s, against 313 s for a passing run.

Fix (test only, in test/e2e/gamebot_helpers_e2e_test.go):

  • Arming: after dialAuthedWS, the helper arms the session. It sends a probe stdin frame (<gs>-arm, in the same {"kind":"stdin","body":base64} format that api/internal/ws/attach.go expects). It re-sends the probe every 2 s for up to 60 s, until the echo comes back on this same session. The action POST is fired only after that.
  • One reader: a single reader goroutine (startPTYReader) serves both phases. There are no per-Read timeouts, because coder/websocket closes the connection when a Read context expires. Cancellation closes the connection, so no goroutine or connection leaks.
  • Assertion unchanged: same <gs>-pathA marker, and the same 30 s deadline starting after the POST. Matching now uses a rolling tail, so a marker split across frames still matches.
  • Comments: updated to say what Path A proves. The e2e template has no console wrapper, so the stream carries the TTY echo of the written line, not the game's chat reply.

Changing this existing e2e helper was approved by the maintainer.

Follow-up (not in this PR): make the e2e Terraria spec use the module's console bridge, so Path A asserts the game's own output. terraria_bot_e2e_test.go:106-114 still describes the old expectation.

Test plan

  • lint (test/e2e) (golangci-lint with --build-tags=e2e)
  • e2e game bot (kind) green; re-run a few times to confirm the flake is gone

Nothing was built or run locally, at the maintainer's request; CI is the verification. Triaged and briefed at sonnet, implemented at haiku, reviewed at opus.

🤖 Generated with Claude Code

https://claude.ai/code/session_018MnGTGHzHhFQCa22wRknUS

Verify pod-attach stdout reader is live before the action's separate attach fires by sending a probe line and waiting for its TTY echo. Adds startPTYReader and awaitPTYMarker helpers to handle the unified frame channel across arming and marker wait phases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018MnGTGHzHhFQCa22wRknUS
Signed-off-by: valgulnecron <39313199+ValgulNecron@users.noreply.github.com>
@ValgulNecron ValgulNecron added area: e2e kind-based end-to-end suite type: test Test additions or changes labels Oct 5, 2026
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: ValgulNecron/Gameplane/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 975bbd60-208e-479f-8352-53416ae05553
📥 Commits

Reviewing files that changed from the base of the PR and between 14521d7 and 3c26739.

📒 Files selected for processing (1)
  • test/e2e/gamebot_helpers_e2e_test.go
  • 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.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

CI Report - 3c26739

run 37343673804 - attempt 1

0 failed - 14 passed - 6 skipped - 30m42s elapsed

Coverage

no coverage/* commit statuses found on 3c26739

Changed

Area Files +/-
test/ 1 +166/-42

Slowest jobs

Job Duration
e2e game bot (kind) 18m49s
e2e multicluster / amd64 (kind x2) 9m15s
e2e multicluster / arm64 (kind x2) 7m39s
e2e web live / amd64 (kind) 6m49s
build e2e images 6m30s

e2e buckets run

api-agent, api-auth, api-mods, api-rbac, api-roles, bot-fast, multicluster, operator, ratelimit, upgrade

@ValgulNecron
ValgulNecron merged commit d2cc795 into master Oct 5, 2026
82 checks passed
@ValgulNecron
ValgulNecron deleted the fix/e2e-terraria-attach-race branch October 5, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e kind-based end-to-end suite type: test Test additions or changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant