From ea2b9d1c1f31b2943c7b0c3d33b9ea76a026dc71 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Mon, 28 Sep 2026 09:17:25 +0100 Subject: [PATCH] Keep the non-procfs agent recovery test off the host's /proc TestInstallSHRecoversV5ProcessArgsWithoutProcfs stubs the running agent as pid 4242 and stubs ps, but running_agent_arg_stream reads /proc//cmdline whenever it exists and only falls back to ps when it does not. On a Linux runner where pid 4242 happened to belong to another process, recovery parsed that process's arguments and the test failed with NOT_READY (seen in Backend tests rest-1). It never failed on macOS, which has no /proc. Wrap the real function so this test always resolves against an empty proc root, which is the no-procfs host it describes. Also extract the env-stream helper it was calling without, and fail on NOT_READY directly since "READY" is a substring of it and never caught a failed recovery. --- scripts/installtests/install_sh_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go index 128a240a6f..0251e9bddc 100644 --- a/scripts/installtests/install_sh_test.go +++ b/scripts/installtests/install_sh_test.go @@ -1185,6 +1185,11 @@ ARGS } func TestInstallSHRecoversV5ProcessArgsWithoutProcfs(t *testing.T) { + // running_agent_arg_stream prefers //cmdline and only falls + // back to ps when that entry is missing. Point it at an empty proc root so + // the stubbed pid never resolves to an unrelated live process on a Linux + // host, which made this test fail whenever pid 4242 happened to exist. + emptyProcRoot := t.TempDir() script := ` PULSE_URL="" PULSE_TOKEN="" @@ -1221,9 +1226,12 @@ func TestInstallSHRecoversV5ProcessArgsWithoutProcfs(t *testing.T) { ` + extractInstallShellFunction(t, "recovered_connection_state_ready") + ` ` + extractTokenRecoveryShellFunctions(t) + ` ` + extractInstallShellFunction(t, "recover_connection_state_from_arg_stream") + ` +` + extractInstallShellFunction(t, "recover_connection_state_from_env_stream") + ` ` + extractInstallShellFunction(t, "split_recovered_shell_words") + ` ` + extractInstallShellFunction(t, "running_agent_arg_stream") + ` ` + extractInstallShellFunction(t, "recover_connection_state_from_running_agent") + ` + eval "installed_running_agent_arg_stream() $(declare -f running_agent_arg_stream | tail -n +2)" + running_agent_arg_stream() { installed_running_agent_arg_stream "$1" "` + emptyProcRoot + `"; } ` + extractInstallShellFunction(t, "build_exec_arg_items") + ` ` + extractInstallShellFunction(t, "join_exec_arg_items") + ` ` + extractInstallShellFunction(t, "build_exec_args") + ` @@ -1248,8 +1256,11 @@ func TestInstallSHRecoversV5ProcessArgsWithoutProcfs(t *testing.T) { t.Fatalf("bash: %v\n%s", err, out) } got := string(out) + // "READY" is a substring of "NOT_READY", so check the failure marker. + if strings.Contains(got, "NOT_READY") || strings.Contains(got, "command not found") { + t.Fatalf("non-procfs process recovery did not recover the running agent:\n%s", got) + } for _, needle := range []string{ - "READY", "URL=http://192.168.2.96:7655", "TOKEN=deadbeef", "DOCKER=true",