MCPcopy Create free account
hub / github.com/prometheus/procfs / TestFSBcachefsStats

Function TestFSBcachefsStats

bcachefs/get_test.go:45–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

43}
44
45func TestFSBcachefsStats(t *testing.T) {
46 uuid := "deadbeef-1234-5678-9012-abcdefabcdef"
47 fs, err := NewFS("testdata/fixtures/sys")
48 if err != nil {
49 t.Fatalf("NewFS error: %v", err)
50 }
51 stats, err := fs.Stats()
52 if err != nil {
53 t.Fatalf("Stats error: %v", err)
54 }
55 if len(stats) != 1 {
56 t.Fatalf("expected 1 filesystem, got %d", len(stats))
57 }
58
59 got := stats[0]
60 if got.UUID != uuid {
61 t.Fatalf("unexpected uuid: %q", got.UUID)
62 }
63 if got.BtreeCacheSizeBytes != 1610612736 {
64 t.Fatalf("unexpected btree cache size: %d", got.BtreeCacheSizeBytes)
65 }
66 if got.Compression["lz4"].CompressedBytes == 0 {
67 t.Fatalf("missing compression stats for lz4")
68 }
69 if got.Errors["btree_node_read_err"].Count != 5 {
70 t.Fatalf("unexpected error count: %d", got.Errors["btree_node_read_err"].Count)
71 }
72 if got.Counters["btree_node_read"].SinceFilesystemCreation != 67890 {
73 t.Fatalf("unexpected counter value: %d", got.Counters["btree_node_read"].SinceFilesystemCreation)
74 }
75 if got.BtreeWrites["initial"].Count != 19088 {
76 t.Fatalf("unexpected btree write count: %d", got.BtreeWrites["initial"].Count)
77 }
78 dev := got.Devices["1"]
79 if dev == nil {
80 t.Fatalf("missing device stats")
81 }
82 if dev.Buckets != 4096 {
83 t.Fatalf("unexpected nbuckets: %d", dev.Buckets)
84 }
85 if dev.IOErrors["read"] != 197346 {
86 t.Fatalf("unexpected io_errors read: %d", dev.IOErrors["read"])
87 }
88 if dev.IODone["read"]["btree"] != 4411097088 {
89 t.Fatalf("unexpected io_done read btree: %d", dev.IODone["read"]["btree"])
90 }
91}
92
93func TestParseCounterFileHumanReadable(t *testing.T) {
94 dir := t.TempDir()

Callers

nothing calls this directly

Calls 2

StatsMethod · 0.95
NewFSFunction · 0.70

Tested by

no test coverage detected