Merge pull request #93275 from xlgao-zju/check-mem

kubeadm: Add a preflight check that the control-plane node has at least 1700MB of RAM
This commit is contained in:
Kubernetes Prow Robot
2020-09-03 08:17:40 -07:00
committed by GitHub
6 changed files with 74 additions and 0 deletions

View File

@@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"io/ioutil"
"runtime"
"strings"
"testing"
@@ -856,3 +857,29 @@ func TestNumCPUCheck(t *testing.T) {
})
}
}
func TestMemCheck(t *testing.T) {
// skip this test, if OS in not Linux, since it will ONLY pass on Linux.
if runtime.GOOS != "linux" {
t.Skip("unsupported OS for memory check test ")
}
var tests = []struct {
minimum uint64
expectedErrors int
}{
{0, 0},
{9999999999999999, 1},
}
for _, rt := range tests {
t.Run(fmt.Sprintf("MemoryCheck{%d}", rt.minimum), func(t *testing.T) {
warnings, errors := MemCheck{Mem: rt.minimum}.Check()
if len(warnings) > 0 {
t.Errorf("expected 0 warnings but got %d: %q", len(warnings), warnings)
} else if len(errors) != rt.expectedErrors {
t.Errorf("expected %d error(s) but got %d: %q", rt.expectedErrors, len(errors), errors)
}
})
}
}