Merge pull request #10428 from priyawadhwa/auto-network-plugin

Fix TestNetworkPlugins/group/auto/KubeletFlags on containerd/crio
pull/10430/head^2
priyawadhwa 2021-02-10 10:36:24 -08:00 committed by GitHub
commit 859ec2a44b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 17 deletions

View File

@ -92,31 +92,16 @@ func TestNetworkPlugins(t *testing.T) {
}
if !t.Failed() {
t.Run("KubeletFlags", func(t *testing.T) {
var rr *RunResult
var err error
// none does not support 'minikube ssh'
rr, err := Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "pgrep -a kubelet"))
if NoneDriver() {
rr, err = Run(t, exec.CommandContext(ctx, "pgrep", "-a", "kubelet"))
} else {
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "pgrep -a kubelet"))
}
if err != nil {
t.Fatalf("ssh failed: %v", err)
}
out := rr.Stdout.String()
if tc.kubeletPlugin == "" {
if strings.Contains(out, "--network-plugin") {
t.Errorf("expected no network plug-in, got %s", out)
}
} else {
if !strings.Contains(out, fmt.Sprintf("--network-plugin=%s", tc.kubeletPlugin)) {
t.Errorf("expected --network-plugin=%s, got %s", tc.kubeletPlugin, out)
}
}
verifyKubeletFlagsOutput(t, tc.kubeletPlugin, out)
})
}
@ -206,3 +191,16 @@ func TestNetworkPlugins(t *testing.T) {
}
})
}
func verifyKubeletFlagsOutput(t *testing.T, kubeletPlugin, out string) {
if kubeletPlugin == "" {
if strings.Contains(out, "--network-plugin") && ContainerRuntime() == "docker" {
t.Errorf("expected no network plug-in, got %s", out)
}
if !strings.Contains(out, "--network-plugin=cni") && ContainerRuntime() != "docker" {
t.Errorf("expected cni network plugin with conatinerd/crio, got %s", out)
}
} else if !strings.Contains(out, fmt.Sprintf("--network-plugin=%s", kubeletPlugin)) {
t.Errorf("expected --network-plugin=%s, got %s", kubeletPlugin, out)
}
}