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

Function TestArcstatsParsing

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

Source from the content-addressed store, hash-verified

22)
23
24func TestArcstatsParsing(t *testing.T) {
25 arcstatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/arcstats")
26 if err != nil {
27 t.Fatal(err)
28 }
29 defer arcstatsFile.Close()
30
31 c := zfsCollector{}
32 if err != nil {
33 t.Fatal(err)
34 }
35
36 handlerCalled := false
37 err = c.parseProcfsFile(arcstatsFile, "arcstats", func(s zfsSysctl, v any) {
38
39 if s == zfsSysctl("kstat.zfs.misc.arcstats.hits") {
40 if v.(uint64) != 8772612 {
41 t.Fatalf("Incorrect value parsed from procfs data")
42 }
43 } else if s == zfsSysctl("kstat.zfs.misc.arcstats.memory_available_bytes") {
44 if v.(int64) != -922337203685477580 {
45 t.Fatalf("Incorrect value parsed from procfs data")
46 }
47 } else {
48 return
49 }
50
51 handlerCalled = true
52 })
53 if err != nil {
54 t.Fatal(err)
55 }
56 if !handlerCalled {
57 t.Fatal("Arcstats parsing handler was not called for some expected sysctls")
58 }
59}
60
61func TestZfetchstatsParsing(t *testing.T) {
62 zfetchstatsFile, err := os.Open("fixtures/proc/spl/kstat/zfs/zfetchstats")

Callers

nothing calls this directly

Calls 3

parseProcfsFileMethod · 0.95
zfsSysctlTypeAlias · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected