MCPcopy Create free account
hub / github.com/containerd/cgroups / TestMemoryController_Stat_OptionalSwap_HasSwap

Function TestMemoryController_Stat_OptionalSwap_HasSwap

cgroup1/memory_test.go:174–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

172}
173
174func TestMemoryController_Stat_OptionalSwap_HasSwap(t *testing.T) {
175 // GIVEN a cgroups folder with all the memory metrics
176 modules := []string{"", "memsw", "kmem", "kmem.tcp"}
177 metrics := []string{"usage_in_bytes", "max_usage_in_bytes", "failcnt", "limit_in_bytes"}
178 tmpRoot := buildMemoryMetrics(t, modules, metrics)
179
180 // WHEN a memory controller that ignores swap only if it is missing reads stats
181 mc := NewMemory(tmpRoot, OptionalSwap())
182 stats := v1.Metrics{}
183 if err := mc.Stat("", &stats); err != nil {
184 t.Errorf("can't get stats: %v", err)
185 }
186
187 // THEN all the memory stats have been completely loaded in memory
188 checkMemoryStatIsComplete(t, stats.Memory)
189}
190
191func TestMemoryController_Stat_OptionalSwap_NoSwap(t *testing.T) {
192 // GIVEN a cgroups folder that accounts for all the metrics BUT swap memory

Callers

nothing calls this directly

Calls 5

buildMemoryMetricsFunction · 0.85
NewMemoryFunction · 0.85
OptionalSwapFunction · 0.85
StatMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…