Repository navigation
Make the macmon backoff test deterministic - #46
Merged
Merged
Conversation
Process-start gaps include scheduler latency, so narrow upper bounds made the macmon backoff test flaky on loaded macOS runners. Inject a private backoff wait function with the existing context-aware timer as its production default and assert exact delays around real child output instead. Cover repeated capped waits and doubling again after a good line resets the delay. Retain the existing unreleased node-info 1.4.0 bump relative to v0.8.0. Independent cap and reset mutations fail the revised test. Signed-off-by: Jared Ping <13906915+JaredP94@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Make
TestMacmonSupervisorBackoffDoublesCapsAndResetsdeterministic on loaded macOS runners. Runs 41643032848 and 41586628573 failed because process-start gaps included scheduler latency and exceeded narrow wall-clock upper bounds, not because the scheduled backoff exceeded its cap.Record the actual backoff waits and assert the exact sequence 50, 100, 150, 150, 50, 100 ms. Six real shell children still exercise execution and parsing; only the fifth emits a good line. This proves the initial minimum, doubling, first and repeated capped waits, reset after good output, and doubling again after reset. The only real-time bound is a loose 10-second context deadline.
No user-facing runtime behavior changes. The unexported
waitBackoffconfig seam defaults to the existingwaitMacmoncontext-aware timer. The compiled output changes, but node-info already has an unreleased minor bump to 1.4.0 versus 1.3.0 at v0.8.0; retain that sufficient bump per fork practice.Scope
Only
services/nvpair-node-info/macmon_supervisor.goand its test change. No wire contracts, dependencies, packaging, or documentation behavior changes.Timing assertion audit (grep of node-info tests for
time.Since,time.Now,time.After, elapsed/gap/deadline):macmon_supervisor_test.go:205,TestMacmonSupervisorRestartsOnIntervalChange, restart must take at most 500 ms. It covers policy-restart latency, not backoff values, so it is unchanged.stats_darwin_test.go:79(TestDarwinCollectorPublishesAndStops, 250 ms);stats_darwin_test.go:219,234(TestDarwinCollectorPublishesSystemStatsWhileGPUBlocks, 250 ms publication and shutdown); sharedwaitFor/supervisor cleanup (2 s), sensor collector shutdown (3 s). All unchanged.Validation
On macOS arm64, in
services/nvpair-node-info, all passed:go test -race -count=20 -run TestMacmonSupervisor ./...go test -race ./...go test -count=1 ./...gofmt -l macmon_supervisor.go macmon_supervisor_test.go(empty)GOOS=darwin go vet ./...GOOS=linux go vet ./...GOOS=windows go vet ./...At repository root:
node scripts/spdx-headers.mjs(0 missing) andgit diff --checkpassed.Mutation checks, each run with
go test -race -count=1 -run '^TestMacmonSupervisorBackoffDoublesCapsAndResets$' ./..., failed as required and were then restored before the passing verification above:BackoffMaxinstead ofBackoffMin: waits 5/6 became 150/150 ms, expected 50/100 ms.Independent inline code review reported no findings.
CI run 41660517582, attempt 2: all six jobs passed (desktop, SPDX, Go modules on Linux/macOS, cross-process tests on Linux/macOS). Attempt 1's macOS Go job never acquired a hosted runner and had no executed steps; GitHub reported runner capacity constraints. Rerunning only that job succeeded without code changes.
Risk
Low: the default timer, cancellation, child lifecycle, and backoff arithmetic are unchanged. The injection is private and configured before running the supervisor. Linux/Windows are cross-vetted, not runtime-tested locally.
Checklist
git commit -s), certifying the Developer Certificate of Origin.