From 839d32c7d5c00252a839e9c0e8d3cb4002af68f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Sat, 10 Oct 2026 20:58:55 +0200 Subject: [PATCH] ci: wait for the collector close bound in TestRun (#2665) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Claude Opus 5.5 Signed-off-by: Jan-Otto Kröpke --- cmd/windows_exporter/main_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/windows_exporter/main_test.go b/cmd/windows_exporter/main_test.go index 0fcd9b75..a9ffc5b7 100644 --- a/cmd/windows_exporter/main_test.go +++ b/cmd/windows_exporter/main_test.go @@ -102,10 +102,13 @@ func TestRun(t *testing.T) { }() t.Cleanup(func() { + // run closes the collectors before it returns. That takes milliseconds, + // but native teardown (PDH, MI) can stall on a loaded CI runner, so + // wait for the bound closeCollection enforces. select { case exitCode := <-exitCodeCh: require.Equal(t, tc.exitCode, exitCode) - case <-time.After(2 * time.Second): + case <-time.After(collectionCloseTimeout + 5*time.Second): t.Fatalf("timed out waiting for exit code, want %d", tc.exitCode) } })