From 5364222fc8103a9357a0c54672d3c684a8dfa4e2 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 9 Feb 2021 14:05:17 -0800 Subject: [PATCH 1/2] We set the network plugin to cni with containerd runtime --- test/integration/net_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/integration/net_test.go b/test/integration/net_test.go index 9fff54dc56..081ecc5c49 100644 --- a/test/integration/net_test.go +++ b/test/integration/net_test.go @@ -108,9 +108,12 @@ func TestNetworkPlugins(t *testing.T) { out := rr.Stdout.String() if tc.kubeletPlugin == "" { - if strings.Contains(out, "--network-plugin") { + 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", tc.kubeletPlugin)) { t.Errorf("expected --network-plugin=%s, got %s", tc.kubeletPlugin, out) From 840b3a2bf0f60d564aa10d02e9c63ccb232b8314 Mon Sep 17 00:00:00 2001 From: Priya Wadhwa Date: Tue, 9 Feb 2021 14:20:25 -0800 Subject: [PATCH 2/2] Fix cyclomatic complexity lint error --- test/integration/net_test.go | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/test/integration/net_test.go b/test/integration/net_test.go index 081ecc5c49..cb6b082b70 100644 --- a/test/integration/net_test.go +++ b/test/integration/net_test.go @@ -92,34 +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") && 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", tc.kubeletPlugin)) { - t.Errorf("expected --network-plugin=%s, got %s", tc.kubeletPlugin, out) - } - } - + verifyKubeletFlagsOutput(t, tc.kubeletPlugin, out) }) } @@ -209,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) + } +}