provider: TestGrokPluginSignInInstallsCLI sees the install under way before letting it finish
Red once on ubuntu CI (909d76747's run, about 1 in 60): StartPluginSignIn
returned State "waiting" with the plugin's URL, not "installing". The
fake installer finished at once, so the goroutine StartPluginSignIn
starts could install, ask the plugin to authorize (which only answers
once FAKE_GROK exists) and move the state on before StartPluginSignIn
read its own state back. The product is right: the state is whatever the
sign-in has reached. The test now holds the fake installer until it has
seen "installing", as the Devin siblings (install_test.go,
plugin_moved_test.go) already do; the hold is let go in a cleanup too, so
an early failure leaves no installer waiting. The uv_cwd error in the
same log is the plugin host outliving the test's removed TempDir, after
the failure, not its cause.
Ran: a 2s sleep injected before StartPluginSignIn's return: the old test
red ("started {... State:done ...}"), the new one green; plain -count=20
and -race -count=5 green; go test ./internal/provider; go vet and
GOOS=linux go vet; gofmt -l clean.
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -261,8 +262,15 @@ export const P = async () => ({
|
||||
}
|
||||
t.Cleanup(func() { GrokExecutable = oldExe })
|
||||
var ran string
|
||||
// the install waits for the test to see it under way: a fake that
|
||||
// finished at once let the sign-in reach "waiting" before
|
||||
// StartPluginSignIn read its own state back
|
||||
seen := make(chan struct{})
|
||||
release := sync.OnceFunc(func() { close(seen) })
|
||||
t.Cleanup(release)
|
||||
oldRun := runInstaller
|
||||
runInstaller = func(ctx context.Context, c agentCLI) ([]byte, error) {
|
||||
<-seen
|
||||
ran = c.Name
|
||||
os.MkdirAll(filepath.Dir(exe), 0o755)
|
||||
return nil, testenv.WriteProgram(exe, "#!/bin/sh\n")
|
||||
@@ -276,6 +284,7 @@ export const P = async () => ({
|
||||
if st.State != "installing" || st.Installing != "Grok Build" {
|
||||
t.Fatalf("started %+v", st)
|
||||
}
|
||||
release()
|
||||
st = waitPast(t, st.ID, "installing")
|
||||
if st.State == "waiting" {
|
||||
st = waitPast(t, st.ID, "waiting")
|
||||
|
||||
Reference in New Issue
Block a user