mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
Benchmarks will allow for easier identification of slow collectors. Additionally, they increase test coverage of the collectors, with some collectors now reaching 80-95% coverage with this change. Collector benchmarks have been structed so that common functionality is present in `collector/collector_test.go` as is done with non-test functionality in `collector/collector.go`. Test logic that is specific to individual collectors is present in the collector test file (E.G. `collector/process_test.go` for the Process collector). Signed-off-by: Ben Reedy <breed808@breed808.com>
27 lines
623 B
Go
27 lines
623 B
Go
// +build windows
|
|
|
|
package collector
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestNetworkToInstanceName(t *testing.T) {
|
|
data := map[string]string{
|
|
"Intel[R] Dual Band Wireless-AC 8260": "Intel_R__Dual_Band_Wireless_AC_8260",
|
|
}
|
|
for in, out := range data {
|
|
got := mangleNetworkName(in)
|
|
if got != out {
|
|
t.Error("expected", out, "got", got)
|
|
}
|
|
}
|
|
}
|
|
|
|
func BenchmarkNetCollector(b *testing.B) {
|
|
// Whitelist is not set in testing context (kingpin flags not parsed), causing the collector to skip all interfaces.
|
|
localNicWhitelist := ".+"
|
|
nicWhitelist = &localNicWhitelist
|
|
benchmarkCollector(b, "net", NewNetworkCollector)
|
|
}
|