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

Function TestMemoryController_Stat_IgnoreModules

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

Source from the content-addressed store, hash-verified

155}
156
157func TestMemoryController_Stat_IgnoreModules(t *testing.T) {
158 // GIVEN a cgroups folder that accounts for all the metrics BUT swap memory
159 modules := []string{"", "kmem", "kmem.tcp"}
160 metrics := []string{"usage_in_bytes", "max_usage_in_bytes", "failcnt", "limit_in_bytes"}
161 tmpRoot := buildMemoryMetrics(t, modules, metrics)
162
163 // WHEN the memory controller explicitly ignores memsw module and reads the data
164 mc := NewMemory(tmpRoot, IgnoreModules("memsw"))
165 stats := v1.Metrics{}
166 if err := mc.Stat("", &stats); err != nil {
167 t.Errorf("can't get stats: %v", err)
168 }
169
170 // THEN the swap memory stats are not loaded but all the other memory metrics are
171 checkMemoryStatHasNoSwap(t, stats.Memory)
172}
173
174func TestMemoryController_Stat_OptionalSwap_HasSwap(t *testing.T) {
175 // GIVEN a cgroups folder with all the memory metrics

Callers

nothing calls this directly

Calls 5

buildMemoryMetricsFunction · 0.85
NewMemoryFunction · 0.85
IgnoreModulesFunction · 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…