mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-17 01:59:04 +02:00
mi: limit the CIM_DataFile cancellation test to one directory (#2752)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user