Repository navigation
fix(runtime): make quarantined capture replacement tests deterministic (Spec fix-1453) - #1455
Merged
Merged
Conversation
#1453) Add a read-only supervisor ReconcileQuiescent seam and settle startup actors before the capture-replacement tests swap clients. The drops- replacement test now replaces through the desired-config reconcile path.
Deploying mcpproxy-docs with
|
| Latest commit: |
45082df
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://534ef723.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-1453-quarantine-capture.mcpproxy-docs.pages.dev |
F3.1: harden TestSearchRegistryServers_CacheEntryIsStampedInternal against the shuffle-lane flake. Count only the registry list request (GET with version=latest) with an atomic counter so a stray request cannot inflate the fetch count, and reset the process-wide registry list and relaxed SSRF flag with t.Cleanup(registries.SetRegistriesFromConfig(nil)).
Contributor
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 36844593772 --repo smart-mcp-proxy/mcpproxy-go
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
12 tasks
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.
Fixes #1453
Root cause
This is a test bug, not a production ordering bug. The capture path persists only inside the manager's current-client critical section after re-checking the client pointer, the connection epoch and the supervisor discovery generation, so a response from a replaced connection can never be written.
TestCaptureQuarantinedToolDefinitions_DropsReplacementBeforePersistswapped the manager entry to server B directly and left the desired config at A. It also started the capture before startup had settled. Several startup actors still carried the initial config: the asynchronousAddServerinLoadConfiguredServers, the supervisor's delayed 500ms startup reconcile, and the capture's own inspection-exemption reconcile. When one of them ran after the test hook it correctly reconciled the manager back to the desired config, replacing B with a fresh A. The capture then retried against that genuinely current client and storedold_definition, nevercurrent_definition, which is the exact signature in #1453. Slower runners (Windows CI) widen all three windows. The two sibling tests share the same family of races.Flakes fixed
All four are test-only; no production behaviour changes.
TestCaptureQuarantinedToolDefinitions_DropsReplacementBeforePersist(Flaky on Windows: TestCaptureQuarantinedToolDefinitions_DropsReplacementBeforePersist (stale definition persisted) #1453): startup actors reconciled the manager back to the desired config after the test's direct swap.The two sibling capture-replacement tests, which share the same startup-settling race.
TestDescribeToolCheck_ReadySetPayload:stateSnapshot.IndexedGH(and the approvals slice) compared JSON in index iteration order, which is not deterministic, so an identical set intermittently differed only in order. The snapshot now sorts by name before marshalling; verified with-count=50(plain and-race).TestSearchRegistryServers_CacheEntryIsStampedInternal(internal/runtime/registry_cache_stamp_test.go, shuffle lane): the fake registry counted every request reaching its loopback port, including a stray request from another package's test binary that reused the port. It now counts onlyGET ?version=latestwith an atomic counter and restores the package-global registry list on cleanup. Production fetches once and serves the second search from cache.Changes
ReconcileQuiescent(), backed by an in-flight action counter and a "startup reconcile has run" flag. It is never consulted by production logic and follows the existingCaptureReplacementQueuedprecedent.UpdateConfigand the supervisor reconcile) instead of poking the manager.Tests
TestSupervisor_ReconcileQuiescent(false before startup reconcile, false while an action is in flight, true once everything finishes).GOMAXPROCS=1, 120 runs of each of the four capture tests: the original tests failed 10 times (1 drops-replacement, 9 serializes); the hardened tests failed 0 times.go test -race ./internal/runtime/...passes, including repeated-countruns atGOMAXPROCS=1.Follow-up
Out of scope here and to be filed separately: supervisor reconcile actions can execute plans computed from a superseded config snapshot or exemption state (a late connect with the old config landing after a newer reconnect, and a stale disconnect landing after an inspection exemption).