mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-23 21:26:36 +00:00
chore: release 0.29.0.rc0 (#1600)
This commit is contained in:
86
pkg/perfdata/collector_test.go
Normal file
86
pkg/perfdata/collector_test.go
Normal file
@@ -0,0 +1,86 @@
|
||||
//go:build windows
|
||||
|
||||
package perfdata_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/pkg/perfdata"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, tc := range []struct {
|
||||
object string
|
||||
instances []string
|
||||
counters []string
|
||||
}{
|
||||
{
|
||||
object: "Memory",
|
||||
counters: []string{
|
||||
"Available Bytes",
|
||||
"Available KBytes",
|
||||
"Available MBytes",
|
||||
"Cache Bytes",
|
||||
"Cache Bytes Peak",
|
||||
"Cache Faults/sec",
|
||||
"Commit Limit",
|
||||
"Committed Bytes",
|
||||
"Demand Zero Faults/sec",
|
||||
"Free & Zero Page List Bytes",
|
||||
"Free System Page Table Entries",
|
||||
"Modified Page List Bytes",
|
||||
"Page Reads/sec",
|
||||
},
|
||||
}, {
|
||||
object: "TCPv4",
|
||||
counters: []string{
|
||||
"Connection Failures",
|
||||
"Connections Active",
|
||||
"Connections Established",
|
||||
"Connections Passive",
|
||||
"Connections Reset",
|
||||
"Segments/sec",
|
||||
"Segments Received/sec",
|
||||
"Segments Retransmitted/sec",
|
||||
"Segments Sent/sec",
|
||||
},
|
||||
}, {
|
||||
object: "Process",
|
||||
instances: []string{"*"},
|
||||
counters: []string{
|
||||
"Thread Count",
|
||||
"ID Process",
|
||||
},
|
||||
},
|
||||
} {
|
||||
t.Run(tc.object, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
performanceData, err := perfdata.NewCollector(tc.object, tc.instances, tc.counters)
|
||||
require.NoError(t, err)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
data, err := performanceData.Collect()
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, data)
|
||||
|
||||
for instance, d := range data {
|
||||
require.NotEmpty(t, d)
|
||||
|
||||
if instance == "Idle" || instance == "Secure System" {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, c := range tc.counters {
|
||||
assert.NotZerof(t, d[c].FirstValue, "object: %s, instance: %s, counter: %s", tc.object, instance, c)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user