Skip to content

Commit baa1f97

Browse files
committed
Replace hardcoded docker check with cni check
1 parent 4a69a37 commit baa1f97

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

Diff for: test/integration/net_test.go

+20-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/blang/semver/v4"
3232
"k8s.io/minikube/pkg/kapi"
3333
"k8s.io/minikube/pkg/minikube/config"
34+
"k8s.io/minikube/pkg/minikube/constants"
3435
"k8s.io/minikube/pkg/minikube/reason"
3536
"k8s.io/minikube/pkg/util"
3637
"k8s.io/minikube/pkg/util/retry"
@@ -57,7 +58,8 @@ func TestNetworkPlugins(t *testing.T) {
5758
namespace string
5859
hairpin bool
5960
}{
60-
{"auto", []string{}, "", "", "", true},
61+
// kindnet CNI is used by default and hairpin is enabled
62+
{"auto", []string{}, "", "", "", usingCNI()},
6163
{"kubenet", []string{"--network-plugin=kubenet"}, "kubenet", "", "", true},
6264
{"bridge", []string{"--cni=bridge"}, "cni", "", "", true},
6365
{"enable-default-cni", []string{"--enable-default-cni=true"}, "cni", "", "", true},
@@ -80,15 +82,14 @@ func TestNetworkPlugins(t *testing.T) {
8082
// collect debug logs
8183
defer debugLogs(t, profile)
8284

83-
if ContainerRuntime() != "docker" && tc.name == "false" {
85+
if usingCNI() && tc.name == "false" {
8486
// CNI is required for current container runtime
8587
validateFalseCNI(ctx, t, profile)
8688
return
8789
}
8890

89-
if ContainerRuntime() != "docker" && tc.name == "kubenet" {
91+
if usingCNI() && tc.name == "kubenet" {
9092
// CNI is disabled when --network-plugin=kubenet option is passed. See cni.New(..) function
91-
// But for containerd/crio CNI has to be configured
9293
t.Skipf("Skipping the test as %s container runtimes requires CNI", ContainerRuntime())
9394
}
9495

@@ -212,6 +213,21 @@ func TestNetworkPlugins(t *testing.T) {
212213
})
213214
}
214215

216+
// usingCNI checks if not using dockershim
217+
func usingCNI() bool {
218+
if ContainerRuntime() != "docker" {
219+
return true
220+
}
221+
version, err := util.ParseKubernetesVersion(constants.DefaultKubernetesVersion)
222+
if err != nil {
223+
return false
224+
}
225+
if version.GTE(semver.MustParse("1.24.0-alpha.2")) {
226+
return true
227+
}
228+
return false
229+
}
230+
215231
// validateFalseCNI checks that minikube returns and error
216232
// if container runtime is "containerd" or "crio"
217233
// and --cni=false

0 commit comments

Comments
 (0)