From f13e5ee14fe6725269f2ca78d7f4c5b19c07eaa3 Mon Sep 17 00:00:00 2001 From: Varun Deep Saini Date: Wed, 7 Jan 2026 18:30:54 +0530 Subject: [PATCH 1/2] fix flaky kill process tests: removed sending response Signed-off-by: Varun Deep Saini --- acceptance/internal/prepare_server.go | 4 +++- acceptance/internal/process_unix.go | 19 ++++++++++++++++++ acceptance/internal/process_windows.go | 27 ++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 acceptance/internal/process_unix.go create mode 100644 acceptance/internal/process_windows.go diff --git a/acceptance/internal/prepare_server.go b/acceptance/internal/prepare_server.go index 84c6cac891..c484dd59a7 100644 --- a/acceptance/internal/prepare_server.go +++ b/acceptance/internal/prepare_server.go @@ -221,7 +221,6 @@ func startLocalServer(t *testing.T, if shouldKillCaller(stub, killCounters, killCountersMu) { killCaller(t, stub.Pattern, req.Headers) - return testserver.Response{StatusCode: http.StatusOK} } return stub.Response @@ -266,6 +265,9 @@ func killCaller(t *testing.T, pattern string, headers http.Header) { return } + if !waitForProcessExit(pid, 2*time.Second) { + t.Logf("KillCaller: timed out waiting for PID %d to exit (pattern: %s)", pid, pattern) + } t.Logf("KillCaller: killed PID %d (pattern: %s)", pid, pattern) } diff --git a/acceptance/internal/process_unix.go b/acceptance/internal/process_unix.go new file mode 100644 index 0000000000..1e0b0ead3e --- /dev/null +++ b/acceptance/internal/process_unix.go @@ -0,0 +1,19 @@ +//go:build linux || darwin + +package internal + +import ( + "syscall" + "time" +) + +func waitForProcessExit(pid int, timeout time.Duration) bool { + deadline := time.Now().Add(timeout) + for time.Now().Before(deadline) { + if syscall.Kill(pid, 0) != nil { + return true + } + time.Sleep(10 * time.Millisecond) + } + return false +} diff --git a/acceptance/internal/process_windows.go b/acceptance/internal/process_windows.go new file mode 100644 index 0000000000..fdad8b4f5e --- /dev/null +++ b/acceptance/internal/process_windows.go @@ -0,0 +1,27 @@ +//go:build windows + +package internal + +import ( + "time" + + "golang.org/x/sys/windows" +) + +func waitForProcessExit(pid int, timeout time.Duration) bool { + deadline := time.Now().Add(timeout) + for time.Now().Before(deadline) { + handle, err := windows.OpenProcess(windows.PROCESS_QUERY_LIMITED_INFORMATION, false, uint32(pid)) + if err != nil { + return true + } + var exitCode uint32 + err = windows.GetExitCodeProcess(handle, &exitCode) + windows.CloseHandle(handle) + if err != nil || exitCode != uint32(windows.STATUS_PENDING) { + return true + } + time.Sleep(10 * time.Millisecond) + } + return false +} From 87baa2d718f3235ffcc00d62af5146b24955945a Mon Sep 17 00:00:00 2001 From: Denis Bilenko Date: Thu, 8 Jan 2026 11:02:05 +0100 Subject: [PATCH 2/2] go mod tidy --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 86870ba346..0f9647a6f5 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( golang.org/x/mod v0.31.0 golang.org/x/oauth2 v0.34.0 golang.org/x/sync v0.19.0 - golang.org/x/sys v0.39.0 // indirect + golang.org/x/sys v0.39.0 golang.org/x/term v0.38.0 golang.org/x/text v0.32.0 gopkg.in/ini.v1 v1.67.0 // Apache 2.0