Skip to content

Make updater startup, migration and recovery tests wait for observed events - #1197

Merged
jatmn merged 2 commits into
mainfrom
fix/queue-666-updater-startup-fixtures
Dec 5, 2026
Merged

jatmn merged 2 commits into
mainfrom
fix/queue-666-updater-startup-fixtures

Conversation

@jatmn

@jatmn jatmn commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Part of #666. Fourteen updater tests used 29 real-clock reads and 27 fixed sleeps while waiting for children, recovery receipts or migration. The fixtures now observe child exit and readiness publication, issue real loopback requests, and advance the retry deadlines established by the supervisor.

The paired recovery test previously accepted the error left by a refused cold restore as evidence that a later child had exited. It now proves both launchers stopped, performs owner recovery, and checks the fresh exit-7 failure and readiness timeout independently. The launcher-clear tests verify that the first application read succeeds before writer activation and that the launcher hash and cleared selection are persisted.

Verification

  • All 14 cases passed 20 serial and 12 contended runs each, totaling 448 executions. A separate controller run passed all 14 again.
  • All 187 updater package tests passed. Sixteen deliberate regressions failed at their expected assertions.
  • Formatting, all-target updater Clippy, pinned Dylint and the flake contracts passed. The 56 assigned findings are gone. The other 84 inherited updater findings match the original compiler output.
  • The suite exercises real Linux child processes, TCP and SQLite. A fixture executable represents the application, and the paired test simulates a future schema migration. Local package validation used nextest 0.9.148. The repeated tests ran the pinned launcher binary directly.

Follow-up commit 9486390 records the child’s ready event before publishing the marker. The migration test uses one HTTP request under its five-second deadline. A forced preemption reproduced the old event order. A 600 ms response failed the old health probe and passed the new one, while a 503 and a response held past the deadline still failed. All 187 package tests and 64 focused repetitions passed on the follow-up.

Summary by Sourcery

Make updater tests wait for observable lifecycle events and verify recovery and launcher-clear outcomes explicitly.

Enhancements:

  • Replace fixed sleeps and wall-clock polling in updater startup, migration, and recovery tests with waits for observed child, readiness, and publication events, plus explicit advancement of retry deadlines.
  • Strengthen paired recovery assertions to verify both launchers stop and distinguish child exit failures from readiness timeouts.
  • Verify application reads succeed before launcher activation and that launcher-clear state is persisted.

Tests:

  • Improve updater integration-test synchronization and assertions across startup, migration, recovery, and launcher-clear scenarios.

@jatmn
jatmn marked this pull request as ready for review December 5, 2026 22:58

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: crates/updater/src/controller_tests.rs:416


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread crates/updater/src/controller_tests.rs Resolved
pullfrog[bot]
pullfrog Bot previously approved these changes Dec 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ℹ️ Two non-blocking timing issues remain.

Approach The supervisor tests can drive state changes from child exits, readiness markers, and saved receipts, which directly observe the transitions these tests exercise.

Reviewed changes I reviewed the updater controller fixtures and traced their waits through the supervisor.

  • Startup and launcher clears. The tests make a real loopback request after the fixture publishes its port, advance scheduled receipt retries, and verify the saved launcher hash and cleared selection.
  • Paired recovery. The test recovers from a refused cold restore before inducing and checking exit status 7 and a separate readiness timeout.
  • Core migration. The maintenance child publishes its ephemeral address so the test can probe it during the migration wait.

cargo fmt --check -p jmodguard-updater passed. I reviewed the timing paths statically and did not rerun the updater tests.

Non-blocking

  • The paired readiness log can appear after the API start log. tick_pair_member resumes when the bot's ready file appears, but CHILD appends new-bot.ready in a separate write afterward. If the child is descheduled between those operations, the supervisor can correctly accept readiness and start the API, which can log new-api.start before the bot's log entry. Record the fixture's readiness event before creating the marker so observing the marker guarantees the log entry is already present. Fixture publication · Ordering assertion
  • The migration health check can fail after 200 ms. The bound-address marker is published before the child accepts requests. A delay in scheduling the child after publication can therefore trip the single probe's 200 ms timeout even though the maintenance child would answer within the test's five-second deadline. Let the single HTTP exchange use the enclosing timeout. Migration probe · Probe timeout

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn

jatmn commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed both findings in 9486390. The ready event is visible before the child publishes its readiness marker. Forcing the bot to pause immediately after that publication reproduced the old event-order failure and confirmed the new order. The migration case now makes one health request under its five-second deadline. Delaying the real maintenance child’s response by 600 ms failed on the previous commit and passed on this one. A 503 still failed the assertion, and a held response failed at the outer deadline. All 187 updater tests and 64 focused repetitions passed.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes I reviewed 9486390 against the prior Pullfrog review at 3bd3792. It addresses both timing findings.

  • Recorded readiness before publishing the marker. The paired recovery test can observe the bot's marker and start the API only after the bot's readiness event is in the log.
  • Used the full migration deadline for the health probe. The single loopback request uses the enclosing five-second timeout. The shared reader handles short reads, and the existing polling callers retain their 200 ms per-attempt timeout.

cargo +1.100.0 fmt --check -p jmodguard-updater passed locally. Updater test execution results are from the author's PR report.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn merged commit b6432b6 into main Dec 5, 2026
21 checks passed
@jatmn
jatmn deleted the fix/queue-666-updater-startup-fixtures branch December 5, 2026 23:19
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