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

Function checkMemoryStatHasNoSwap

cgroup1/memory_test.go:234–258  ·  view source on GitHub ↗
(t *testing.T, mem *v1.MemoryStat)

Source from the content-addressed store, hash-verified

232}
233
234func checkMemoryStatHasNoSwap(t *testing.T, mem *v1.MemoryStat) {
235 if mem.Swap.Usage != 0 || mem.Swap.Limit != 0 ||
236 mem.Swap.Max != 0 || mem.Swap.Failcnt != 0 {
237 t.Errorf("swap memory should have been ignored. Got: %+v", mem.Swap)
238 }
239 index := []uint64{
240 mem.Usage.Usage,
241 mem.Usage.Max,
242 mem.Usage.Failcnt,
243 mem.Usage.Limit,
244 mem.Kernel.Usage,
245 mem.Kernel.Max,
246 mem.Kernel.Failcnt,
247 mem.Kernel.Limit,
248 mem.KernelTCP.Usage,
249 mem.KernelTCP.Max,
250 mem.KernelTCP.Failcnt,
251 mem.KernelTCP.Limit,
252 }
253 for i, v := range index {
254 if v != uint64(i) {
255 t.Errorf("expected value at index %d to be %d but received %d", i, i, v)
256 }
257 }
258}
259
260// buildMemoryMetrics creates fake cgroups memory entries in a temporary dir. Returns the fake cgroups root
261func buildMemoryMetrics(t *testing.T, modules []string, metrics []string) string {

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…