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

Function TestMemoryController_Stat_OptionalSwap_NoSwap

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

Source from the content-addressed store, hash-verified

189}
190
191func TestMemoryController_Stat_OptionalSwap_NoSwap(t *testing.T) {
192 // GIVEN a cgroups folder that accounts for all the metrics BUT swap memory
193 modules := []string{"", "kmem", "kmem.tcp"}
194 metrics := []string{"usage_in_bytes", "max_usage_in_bytes", "failcnt", "limit_in_bytes"}
195 tmpRoot := buildMemoryMetrics(t, modules, metrics)
196
197 // WHEN a memory controller that ignores swap only if it is missing reads stats
198 mc := NewMemory(tmpRoot, OptionalSwap())
199 stats := v1.Metrics{}
200 if err := mc.Stat("", &stats); err != nil {
201 t.Errorf("can't get stats: %v", err)
202 }
203
204 // THEN the swap memory stats are not loaded but all the other memory metrics are
205 checkMemoryStatHasNoSwap(t, stats.Memory)
206}
207
208func checkMemoryStatIsComplete(t *testing.T, mem *v1.MemoryStat) {
209 index := []uint64{

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…