Skip to content

Stabilize daemon release tests#147

Merged
glittercowboy merged 2 commits into
mainfrom
codex/pi-rust-release-test-fix
May 8, 2026
Merged

Stabilize daemon release tests#147
glittercowboy merged 2 commits into
mainfrom
codex/pi-rust-release-test-fix

Conversation

@glittercowboy
Copy link
Copy Markdown
Contributor

@glittercowboy glittercowboy commented May 8, 2026

Summary

Stabilizes release-sensitive daemon tests that rely on fake Pi subprocess timing.

Behavior

  • Fake control subprocesses read stdin before emitting response frames so RunControl writes against a live reader.
  • The duplicate-task loop test waits for task completion through the relay sink instead of relying on a fixed sleep.

Validation

  • go test ./internal/pi -count=20
  • go test ./internal/loop -run TestHandleTaskIgnoresDuplicateTaskID -count=10
  • go test ./...
  • go build -o /tmp/gsd-cloud-release-test-fix .
  • git diff --check

Release Context

The daemon/v0.3.73 release workflow failed in TestRunControlParsesNullStatsContextUsage with a broken pipe while writing the control command. This PR removes that fake-process race before a replacement release tag is cut.

Summary by CodeRabbit

  • Tests
    • Improved test stability by replacing long fixed sleeps with deterministic completion checks to reliably detect and assert single task completions.
    • Stabilized subprocess-based tests by ensuring fake subprocesses consume stdin, preventing premature progression and flakiness.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2093e714-a078-4959-993d-ca6991653f46

📥 Commits

Reviewing files that changed from the base of the PR and between 30a8fc1 and fd4f76a.

📒 Files selected for processing (1)
  • internal/loop/daemon_test.go

📝 Walkthrough

Walkthrough

This PR improves test reliability with two independent changes: a polling-based helper for task completion assertions in the loop daemon test, and stdin-consumption adjustments in four pi control tests to ensure subprocess stdin is drained before output is emitted.

Changes

Task Completion Polling Helper

Layer / File(s) Summary
Polling Helper Definition
internal/loop/daemon_test.go
Adds waitForTaskCompletes method to loopFakeRelay to poll for TaskComplete frames matching a task ID with a configurable count threshold and timeout.
Helper Usage
internal/loop/daemon_test.go
Duplicate-task test now uses waitForTaskCompletes for explicit completion assertion instead of fixed sleep, attempting a 1-count wait then a 2-count wait (expected to time out) and asserting a single completion remains.

Subprocess Stdin Consumption

Layer / File(s) Summary
Stdin-Consuming Scripts
internal/pi/control_test.go
Four RunControl tests (TestRunControlExcludesUnrelatedHostSecrets, TestRunControlDoesNotUseStatsTokenAccountingAsContextUsage, TestRunControlParsesNullStatsContextUsage, TestRunControlRequiresTerminalResultFrame) now drain stdin via cat >/dev/null before subprocess output generation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through test-time flows,
With helpers to poll where waiting goes,
And stdin drains like morning dew,
Test scripts now consume what's due. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. 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 'Stabilize daemon release tests' directly corresponds to the main objective: stabilizing release-sensitive daemon tests that were failing due to timing issues.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/pi-rust-release-test-fix

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/loop/daemon_test.go`:
- Around line 1189-1193: Replace the unconditional time.Sleep with a bounded
negative wait to deterministically assert no second completion: after the
successful waitForTaskCompletes(t, 6*time.Second, "dup-task-1", 1) call, remove
the Sleep and call relaySink.waitForTaskCompletes(t, 1500*time.Millisecond,
"dup-task-1", 2) (or a similar short timeout) and assert it returns false, so
the test fails if a delayed duplicate completion appears instead of relying on
wall-clock sleep.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f1c0bd94-73fe-4f1c-bb33-29ba2a3d201c

📥 Commits

Reviewing files that changed from the base of the PR and between 8cf8951 and 30a8fc1.

📒 Files selected for processing (2)
  • internal/loop/daemon_test.go
  • internal/pi/control_test.go

Comment thread internal/loop/daemon_test.go
@glittercowboy glittercowboy merged commit 1d32ed5 into main May 8, 2026
3 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