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

Function TestZilParsing

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

Source from the content-addressed store, hash-verified

95}
96
97func TestZilParsing(t *testing.T) {
98 zilFile, err := os.Open("fixtures/proc/spl/kstat/zfs/zil")
99 if err != nil {
100 t.Fatal(err)
101 }
102 defer zilFile.Close()
103
104 c := zfsCollector{}
105 if err != nil {
106 t.Fatal(err)
107 }
108
109 handlerCalled := false
110 err = c.parseProcfsFile(zilFile, "zil", func(s zfsSysctl, v any) {
111
112 if s != zfsSysctl("kstat.zfs.misc.zil.zil_commit_count") {
113 return
114 }
115
116 handlerCalled = true
117
118 if v.(uint64) != 10 {
119 t.Fatalf("Incorrect value parsed from procfs data")
120 }
121
122 })
123
124 if err != nil {
125 t.Fatal(err)
126 }
127
128 if !handlerCalled {
129 t.Fatal("Zil parsing handler was not called for some expected sysctls")
130 }
131}
132
133func TestVdevCacheStatsParsing(t *testing.T) {
134 vdevCacheStatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/vdev_cache_stats")

Callers

nothing calls this directly

Calls 3

parseProcfsFileMethod · 0.95
zfsSysctlTypeAlias · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected