MCPcopy
hub / github.com/prometheus/node_exporter / TestVdevCacheStatsParsing

Function TestVdevCacheStatsParsing

collector/zfs_linux_test.go:133–167  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestVdevCacheStatsParsing(t *testing.T) {
134 vdevCacheStatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/vdev_cache_stats")
135 if err != nil {
136 t.Fatal(err)
137 }
138 defer vdevCacheStatsFile.Close()
139
140 c := zfsCollector{}
141 if err != nil {
142 t.Fatal(err)
143 }
144
145 handlerCalled := false
146 err = c.parseProcfsFile(vdevCacheStatsFile, "vdev_cache_stats", func(s zfsSysctl, v any) {
147
148 if s != zfsSysctl("kstat.zfs.misc.vdev_cache_stats.delegations") {
149 return
150 }
151
152 handlerCalled = true
153
154 if v.(uint64) != 40 {
155 t.Fatalf("Incorrect value parsed from procfs data")
156 }
157
158 })
159
160 if err != nil {
161 t.Fatal(err)
162 }
163
164 if !handlerCalled {
165 t.Fatal("VdevCacheStats parsing handler was not called for some expected sysctls")
166 }
167}
168
169func TestXuioStatsParsing(t *testing.T) {
170 xuioStatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/xuio_stats")

Callers

nothing calls this directly

Calls 3

parseProcfsFileMethod · 0.95
zfsSysctlTypeAlias · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected