mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-13 00:16:37 +00:00
mi: Revert "replace all WMI calls with MI calls" (#1713)
This commit is contained in:
@@ -10,10 +10,10 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/pkg/collector"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/yusufpapurcu/wmi"
|
||||
)
|
||||
|
||||
func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, collectFunc collector.BuilderWithFlags[C]) {
|
||||
@@ -57,16 +57,14 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
|
||||
c := fn(conf)
|
||||
ch := make(chan prometheus.Metric, 10000)
|
||||
|
||||
miApp, err := mi.Application_Initialize()
|
||||
require.NoError(t, err)
|
||||
|
||||
miSession, err := miApp.NewSession(nil)
|
||||
wmiClient := &wmi.Client{
|
||||
AllowMissingFields: true,
|
||||
}
|
||||
wmiClient.SWbemServicesClient, err = wmi.InitializeSWbemServices(wmiClient)
|
||||
require.NoError(t, err)
|
||||
|
||||
t.Cleanup(func() {
|
||||
require.NoError(t, c.Close(logger))
|
||||
require.NoError(t, miSession.Close())
|
||||
require.NoError(t, miApp.Close())
|
||||
})
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
@@ -80,7 +78,7 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
|
||||
}
|
||||
}()
|
||||
|
||||
require.NoError(t, c.Build(logger, miSession))
|
||||
require.NoError(t, c.Build(logger, wmiClient))
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user