From b3500f7aef411e6b62912e345412647501893d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Fri, 16 Oct 2026 11:47:44 +0200 Subject: [PATCH] mi: limit the CIM_DataFile cancellation test to one directory (#2752) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- internal/mi/AGENTS.md | 7 +++++++ internal/mi/callbacks_test.go | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/mi/AGENTS.md b/internal/mi/AGENTS.md index fd2f5314..c1def4cc 100644 --- a/internal/mi/AGENTS.md +++ b/internal/mi/AGENTS.md @@ -63,5 +63,12 @@ results never look complete. A context that is done after the final result (`complete`, set under `mu`) does not fail a query that has nothing left to hand over. +Tests that need a slow query must bound the work it causes. Cancelling an +operation may end it only on the client: providers such as CIMWin32 +(`CIM_DataFile`) keep enumerating in WmiPrvSE. `CIM_DataFile` for a whole drive +kept the CI runner busy for minutes after the Go tests, which slowed every +later step and made the end-to-end `/metrics` request time out. Restrict such +queries to one directory. + Run `CGO_ENABLED=1 go test -race` (gcc from w64devkit) and a `-gcflags=all=-d=checkptr` run for changes in this package. diff --git a/internal/mi/callbacks_test.go b/internal/mi/callbacks_test.go index 3943ec0c..8b2f26df 100644 --- a/internal/mi/callbacks_test.go +++ b/internal/mi/callbacks_test.go @@ -327,9 +327,11 @@ func Test_MI_QueryContext_CancelDuringQuery(t *testing.T) { }) t.Run("QueryContext", func(t *testing.T) { - // CIM_DataFile enumerates every file of the drive, which takes far - // longer than the context. - slowQuery, err := mi.NewQuery("SELECT Name FROM CIM_DataFile WHERE Drive = 'C:'") + // CIM_DataFile is slow, so the query outlives the context. Cancel + // does not stop the CIMWin32 provider in WmiPrvSE: it finishes the + // enumeration on its own. Keep the query to one directory; a whole + // drive keeps the runner busy for minutes after the test. + slowQuery, err := mi.NewQuery(`SELECT Name FROM CIM_DataFile WHERE Drive = 'C:' AND Path = '\\Windows\\System32\\'`) require.NoError(t, err) ctx, cancel := context.WithTimeout(t.Context(), 100*time.Millisecond)