Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/agentsview/serve_background.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var errServeStartupInProgress = errors.New(
"agentsview serve startup is already in progress",
)

var waitForDaemonStartupForEnsure = WaitForDaemonStartupContext
var startServeBackgroundProcessForEnsure = startServeBackgroundProcess
var startServeBackgroundProcessForRun = startServeBackgroundProcess

Expand Down Expand Up @@ -552,7 +553,7 @@ probeDaemon:
}
}
if IsLocalDaemonActive(cfg.DataDir, cfg.AuthToken) {
WaitForDaemonStartupContext(
waitForDaemonStartupForEnsure(
ctx, cfg.DataDir, waitTimeout, cfg.AuthToken,
)
if err := ctx.Err(); err != nil {
Expand Down
26 changes: 24 additions & 2 deletions cmd/agentsview/serve_background_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,26 @@ func TestEnsureBackgroundServeChecksTooNewDatabaseAfterStartupWait(

unlockStart := holdExternalDaemonStartLock(t, dir)
oldHost, oldPort := testPingServer(t)
waitStarted := make(chan struct{})
oldWaitForDaemonStartup := waitForDaemonStartupForEnsure
waitForDaemonStartupForEnsure = func(
ctx context.Context,
dataDir string,
timeout time.Duration,
authToken ...string,
) bool {
close(waitStarted)
return oldWaitForDaemonStartup(
ctx, dataDir, timeout, authToken...,
)
}
t.Cleanup(func() {
waitForDaemonStartupForEnsure = oldWaitForDaemonStartup
})

errCh := make(chan error, 1)
go func() {
time.Sleep(2 * startProbeTick())
<-waitStarted
_, err := writeRuntimeRecordForTest(dir, daemonRuntimeRecord(
oldHost, oldPort,
withRuntimeVersion("1.0.0"),
Expand All @@ -1406,7 +1423,12 @@ func TestEnsureBackgroundServeChecksTooNewDatabaseAfterStartupWait(

require.NoError(t, <-errCh)
require.Error(t, err)
assert.True(t, db.IsDataVersionTooNew(err))
assert.True(
t,
db.IsDataVersionTooNew(err),
"expected data-version-too-new error, got %v",
err,
)
assert.Nil(t, rt)
assert.False(t, stopped)
found, compatErr := FindIncompatibleDaemonRuntime(dir)
Expand Down