MCPcopy
hub / github.com/NVIDIA/aistore / TestMemoryStats

Function TestMemoryStats

sys/sys_test.go:51–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestMemoryStats(t *testing.T) {
52 var mem MemStat
53 err := mem.Get()
54 tassert.CheckFatal(t, err)
55
56 tassert.Errorf(t, mem.Total > 0 && mem.Free > 0 && mem.ActualFree > 0 && mem.ActualUsed > 0,
57 "All items must be greater than zero: %+v", mem)
58 tassert.Errorf(t, mem.Total > mem.Free, "Free is greater than Total memory: %+v", mem)
59 tassert.Errorf(t, mem.Total > mem.Used, "Used is greater than Total memory: %+v", mem)
60 tassert.Errorf(t, mem.Total > mem.ActualUsed, "ActualUsed is greater than Total memory: %+v", mem)
61 tassert.Errorf(t, mem.Total > mem.ActualFree, "ActualFree is greater than Total memory: %+v", mem)
62 tassert.Errorf(t, mem.Total == mem.Free+mem.Used, "Total must be = Free + Used: %+v", mem)
63 t.Logf("Memory stats: %+v", mem)
64
65 checkSkipOS(t, "darwin")
66
67 var memHost, memCont MemStat
68 err = memHost.host()
69 tassert.CheckFatal(t, err)
70 err = memCont.container()
71 tassert.CheckFatal(t, err)
72 tassert.Errorf(t, memHost.Total >= memCont.Total,
73 "Container's memory total is greater than the host one.\nOS: %+v\nContainer: %+v", memHost, memCont)
74 if memHost.SwapTotal == 0 && memHost.SwapFree == 0 {
75 // Not an error(e.g, Jenkins VM has swap off) - just a warning
76 t.Logf("Either swap is off or failed to read its stats")
77 }
78}
79
80func TestProc(t *testing.T) {
81 if testing.Short() {

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
hostMethod · 0.95
containerMethod · 0.95
CheckFatalFunction · 0.92
ErrorfFunction · 0.92
checkSkipOSFunction · 0.85

Tested by

no test coverage detected