Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

test(daemon): keep production dsh probe timeout for answering fixtures (MUL-9143) (#10481)

Jiayuan Zhang2cf852ea9859
diff --git a/server/internal/daemon/agents_probe_dsh_test.go b/server/internal/daemon/agents_probe_dsh_test.go
index 4c51f92241..040d44aa91 100644
--- a/server/internal/daemon/agents_probe_dsh_test.go
+++ b/server/internal/daemon/agents_probe_dsh_test.go
@@ -46,6 +46,18 @@ func dshProbeFixture(t *testing.T, body string, manifest bool) string {
const dshProbeOKFrame = `printf '%s\n' '{"v":1,"type":"probe","runtime":"dsh","plugin_version":"test","protocol_version":1}'`
+// shortenDshProbeTimeoutForHang is for a fixture whose probe never answers, so
+// the test waits out a short budget instead of the production one. A fixture
+// that answers must keep the production budget: it returns as soon as it has
+// answered, and a short budget turns a slow answer on a loaded machine into a
+// timeout — a different verdict from the one under test.
+func shortenDshProbeTimeoutForHang(t *testing.T) {
+ t.Helper()
+ orig := dshProbeTimeout
+ t.Cleanup(func() { dshProbeTimeout = orig })
+ dshProbeTimeout = 300 * time.Millisecond
+}
+
// Only a profile that is genuinely absent may be installed or condemned. Every
// other failure mode is a statement about this instant, and treating them alike
// is what let a momentary failure during a DSH upgrade demote a working runtime
@@ -58,6 +70,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
name string
body string
manifest bool
+ hangs bool
want dshProbeVerdict
}{
{
@@ -79,7 +92,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
},
{
name: "manifest present but the probe times out",
- body: `exec sleep 30`, manifest: true, want: dshProbeUnavailable,
+ body: `exec sleep 30`, manifest: true, hangs: true, want: dshProbeUnavailable,
},
{
// The case the whole classification turns on. Asked for a profile
@@ -87,7 +100,7 @@ func TestProbeDshMulticaProfile(t *testing.T) {
// nothing. Calling that transient made a missing profile
// undetectable on the one host the automatic install exists for.
name: "probe hangs with no manifest",
- body: `exec sleep 30`, want: dshProbeMissingProfile,
+ body: `exec sleep 30`, hangs: true, want: dshProbeMissingProfile,
},
{
name: "exit 0 printing nothing, no manifest",
@@ -120,9 +133,6 @@ func TestProbeDshMulticaProfile(t *testing.T) {
manifest: true, want: dshProbeIncompatible,
},
}
- origTimeout := dshProbeTimeout
- t.Cleanup(func() { dshProbeTimeout = origTimeout })
- dshProbeTimeout = 2 * time.Second
// A cancelled round says nothing about the profile, whatever the manifest
// says: the probe never got to finish on its own terms.
@@ -137,6 +147,9 @@ func TestProbeDshMulticaProfile(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
+ if tc.hangs {
+ shortenDshProbeTimeoutForHang(t)
+ }
path := dshProbeFixture(t, tc.body, tc.manifest)
if got := probeDshMulticaProfile(context.Background(), path); got != tc.want {
t.Fatalf("probeDshMulticaProfile() = %v, want %v", got, tc.want)
@@ -220,24 +233,27 @@ func TestProbeBuiltinRuntime_DshFailureWithProfileInstalledIsNotCondemned(t *tes
t.Skip("shell fixture")
}
tests := []struct {
- name string
- body string
+ name string
+ body string
+ hangs bool
}{
- {name: "timeout", body: `exec sleep 30`},
+ {name: "timeout", body: `exec sleep 30`, hangs: true},
{name: "non-zero exit", body: `printf '%s\n' 'cannot boot' >&2; exit 1`},
{name: "malformed output", body: `printf '%s\n' 'not json at all'`},
{name: "future protocol", body: `printf '%s\n' '{"v":2,"type":"probe","runtime":"dsh","protocol_version":2}'`},
}
- origTimeout, origDelay, origWindow := dshProbeTimeout, runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow
+ origDelay, origWindow := runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow
t.Cleanup(func() {
- dshProbeTimeout, runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow = origTimeout, origDelay, origWindow
+ runtimeVersionProbeRetryDelay, runtimeVersionProbeRetryWindow = origDelay, origWindow
})
- dshProbeTimeout = 300 * time.Millisecond
runtimeVersionProbeRetryDelay = time.Millisecond
runtimeVersionProbeRetryWindow = 10 * time.Millisecond
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
+ if tc.hangs {
+ shortenDshProbeTimeoutForHang(t)
+ }
path := dshProbeFixture(t, tc.body, true)
record := filepath.Join(t.TempDir(), "provisioned.log")
// A bundle IS configured: the assertion is that these failures never