Repository navigation
feat(keploytest): a test binary keploy's Go launcher started joins on the launcher's claim - #207
Merged
Merged
Conversation
… the launcher's claim keploy mock record and replay run each go test binary through keploy's Go launcher (keploy-go-exec, -exec in GOFLAGS), which claims keploy's run for the binary before it starts, so the calls an init or TestMain makes land in the binary's key, and freezes its clock. keploytest's own claim, in its init, becomes the fallback for a binary started without it. - KEPLOY_TEST_CLAIMED names the pid keploy's agent took the claim from: the launcher sets it to its own pid, which exec keeps, and keploytest after its own claim. A binary whose pid it names claims nothing more, so an image that a claimed binary execs in place keeps the claim, and a refused binary's claims again and is refused again. - KEPLOY_TEST_PID is set before the claim, as before: the processes a binary starts are its members whether its claim was taken or refused. - -test.parallel is set on both paths. - A claim answered with a frozen clock (timeFile), which only the launcher can apply, is refused as clock_not_frozen with the fix, and the refusal is told to keploy's agent, so keploy's verdict names it. Signed-off-by: slayerjain <shubhamkjain@outlook.com>
slayerjain
marked this pull request as ready for review
October 13, 2026 23:55
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.
keploy's T2 release 1 (release1-cut §1.3, row 9s-L):
keploy mock recordandkeploy mock replayrun each go test binary through keploy's Go launcher,keploy-go-exec(-execinGOFLAGS). The launcher freezes the binary's clock (a patched copy), refuses the go test keploy cannot judge (-pabove 1, no-v/-json,-shuffle,-fuzz), sets-test.parallel, and claims keploy's run for the binary before it starts, so a dependency call that aninitorTestMainmakes lands in the binary's own key. That includes theinitof a package Go initializes before keploytest's.keploytest (#206) claims in its own
init. This PR makes that claim a fallback, used only when no claim was inherited.What changes
KEPLOY_TEST_CLAIMED, a new variable, to its own pid, and exec keeps that pid. A binary whose pid it names claims nothing, refuses nothing, and makes its checks at the first test as before. keploytest also sets it after its own claim succeeds. A binary that execs itself again (same pid) therefore keeps its claim, while one refused the run claims again and is refused again.KEPLOY_TEST_PIDis set before the claim, as in feat(keploytest): join go test to keploy's Universal Mocker (release 1, one test process) #206. The processes a binary starts are members of its run (inert) whether its claim was taken or refused.-test.parallelis set on both paths. The launcher passes its own value on the command line, which the flag parse applies afterwards. An exec'd image has only this one.clock_not_frozen, POST/agent/refusal), so keploy's verdict names it.timeFile: keploy froze the run, and only the launcher can freeze a test binary. The tests would otherwise run on the real clock against recordings made on another.-exec, or aGOFLAGSset by the test command itself, replaces keploy's), or start it in its package directory askeploy-go-exec <test binary> -test.v.Without the launcher (switch off, and every user today)
There are only two differences from #206:
Tests
TestALauncherStartedBinaryJoinsOnItsClaimis end to end.shsets both markers to its own pid and execs this package's test binary, as the launcher does. The fake agent's claim answer carries atimeFile, which would be refused if claimed. Checks: no claim is made; T and TP tests begin and end;-test.parallel=1048576.TestABinaryThatExecsItselfAgainKeepsItsClaim: TestMain execs the binary in place. A claimed binary keeps one claim and its-test.parallel; a refused one claims twice and fails with the agent's words.TestTheMarkersOfAClaimedAndOfARefusedBinary:KEPLOY_TEST_PIDis set either way, andKEPLOY_TEST_CLAIMEDonly on a claim the agent took. A frozen-clock claim is refused and told to the agent with codeclock_not_frozen.TestAnInheritedClaimIsNotMadeAgain: no agent call, even undergo test -p 2with a frozen run.go test -race ./...passes, andgo vetis clean on linux, windows, darwin and plan9.The enterprise launcher sets both markers (keploy/enterprise 9s-L PR, which pins this change). Lane 2's Go suite (
mock-local-loop-go-e2e) runs on it, including aninit()that Go runs before keploytest's and aTestMaincall, both recorded under their own package's key.