Skip to content

test(mecatequi): observe telemetry shutdown cancellation - #2634

Merged
jbeda merged 1 commit into
mainfrom
test/telemetry-shutdown-barriers
Oct 31, 2026
Merged

jbeda merged 1 commit into
mainfrom
test/telemetry-shutdown-barriers

Conversation

@jbeda

@jbeda jbeda commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Summary

Harden the telemetry shutdown regression test tracked in #2327 without changing production behavior.

  • Replace the 600 ms stopwatch around all of realMain with explicit observations: the exit flush reaches a blocked OTLP collector, cancels that request, reports the deadline failure on stderr, and returns successfully before cleanup releases the collector.
  • Keep exporter/reader fallback timeouts beyond the diagnostic watchdog so they cannot substitute for the command's shutdown bound.
  • Test the exact configured shutdown deadline separately with testing/synctest, avoiding wall-clock scheduling assumptions.
  • Release the collector and join the command during cleanup, including assertion failures; remove the unused sleep-based collector fixture.

The old assertion charged startup, Git operations, and shutdown against the same 600 ms budget. This change preserves coverage through the actual exit defer without treating command execution speed as the shutdown contract.

Verification

Passed locally:

  • go test -race -count=20 -cpu=1,2 -run 'TestTelemetry|TestFlushTelemetry' ./cmd/mecatequi — 40 repetitions of each selected test.
  • task lint
  • task test:race — complete offline suite.
  • go run ./cmd/mecademo — tool call, permission ask/approval, and result observed.
  • Focused independent synchronization/cleanup audit — no findings.

Negative controls (temporary production mutations, both reverted):

  • Doubling the shutdown timeout made TestFlushTelemetryShutdownDeadline fail immediately.
  • Passing zero timeout from realMain's exit defer made TestTelemetryShutdownTimeoutBounded fail on missing cancellation; cleanup released the collector and joined the command.

task test did not pass: the telemetry package passed, but two unchanged tests failed and were independently reproduced:

  • internal/app.TestBuiltSchedulerBorrowsNativeOriginAndPublishesEachFire: immediate manual fire can precede asynchronous scheduler leadership acquisition (ErrScheduleNotLeader); 14 failures in 100 focused repetitions.
  • mcp/oauthlogin.TestUnauthenticatedProbeFloodDoesNotAbortValidCallback: /probe connection reset in the suite, EOF in focused repetitions. Sequential fresh connections can race server-side connection-slot release. A bounded focused run reproduced the same failure location after approximately seven seconds; the proposed limiter-slot schedule is code-supported, not an instrumented execution trace.

Those follow-ups are deliberately excluded from this test-only PR. This addresses the telemetry watch-list entry, not the entire #2327 tracker.

API compatibility

No API, wire behavior, stored-data, dependency, or production-code changes. No major or feature identifier changes; no upgrade implications.

Replace the whole-command timing ceiling with blocked-export cancellation and verify the exact flush deadline with a fake clock.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda enabled auto-merge (squash) October 31, 2026 21:02
@jbeda
jbeda merged commit 9da8975 into main Oct 31, 2026
38 checks passed
@jbeda
jbeda deleted the test/telemetry-shutdown-barriers branch October 31, 2026 21:06
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Nov 18, 2026
2 tasks
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