mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #41275 from apprenda/kubeadm_init_test-cmds
Automatic merge from submit-queue (batch tested with PRs 41216, 41362, 41275, 41277, 41412) kubeadm: test-cmd: init{config, version, api-port} **What this PR does / why we need it**: Adding test-cmds for kubeadm init {config, version, api-port}. Will followup with more test-cmds for other flags as soon as validation for the flags works. Adding tests is a WIP from #34136 **Special notes for your reviewer**: /cc @luxas @pires **Release note**: ```release-note NONE ```
This commit is contained in:
commit
528868f105
@ -52,3 +52,88 @@ func TestCmdInitToken(t *testing.T) {
|
||||
kubeadmReset()
|
||||
}
|
||||
}
|
||||
|
||||
func TestCmdInitKubernetesVersion(t *testing.T) {
|
||||
if *kubeadmCmdSkip {
|
||||
t.Log("kubeadm cmd tests being skipped")
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
var initTest = []struct {
|
||||
args string
|
||||
expected bool
|
||||
}{
|
||||
{"--use-kubernetes-version=foobar", false},
|
||||
}
|
||||
|
||||
for _, rt := range initTest {
|
||||
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
|
||||
if (actual == nil) != rt.expected {
|
||||
t.Errorf(
|
||||
"failed CmdInitKubernetesVersion running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
|
||||
rt.args,
|
||||
actual,
|
||||
rt.expected,
|
||||
(actual == nil),
|
||||
)
|
||||
}
|
||||
kubeadmReset()
|
||||
}
|
||||
}
|
||||
|
||||
func TestCmdInitConfig(t *testing.T) {
|
||||
if *kubeadmCmdSkip {
|
||||
t.Log("kubeadm cmd tests being skipped")
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
var initTest = []struct {
|
||||
args string
|
||||
expected bool
|
||||
}{
|
||||
{"--config=foobar", false},
|
||||
{"--config=/does/not/exist/foo/bar", false},
|
||||
}
|
||||
|
||||
for _, rt := range initTest {
|
||||
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
|
||||
if (actual == nil) != rt.expected {
|
||||
t.Errorf(
|
||||
"failed CmdInitConfig running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
|
||||
rt.args,
|
||||
actual,
|
||||
rt.expected,
|
||||
(actual == nil),
|
||||
)
|
||||
}
|
||||
kubeadmReset()
|
||||
}
|
||||
}
|
||||
|
||||
func TestCmdInitAPIPort(t *testing.T) {
|
||||
if *kubeadmCmdSkip {
|
||||
t.Log("kubeadm cmd tests being skipped")
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
var initTest = []struct {
|
||||
args string
|
||||
expected bool
|
||||
}{
|
||||
{"--api-port=foobar", false},
|
||||
}
|
||||
|
||||
for _, rt := range initTest {
|
||||
_, _, actual := RunCmd(*kubeadmPath, "init", rt.args, "--skip-preflight-checks")
|
||||
if (actual == nil) != rt.expected {
|
||||
t.Errorf(
|
||||
"failed CmdInitAPIPort running 'kubeadm init %s' with an error: %v\n\texpected: %t\n\t actual: %t",
|
||||
rt.args,
|
||||
actual,
|
||||
rt.expected,
|
||||
(actual == nil),
|
||||
)
|
||||
}
|
||||
kubeadmReset()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user