Skip to content

Commit b054490

Browse files
committed
Replace hardcoded docker check with cni check
1 parent 0d07c72 commit b054490

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Diff for: test/integration/net_test.go

+19-5
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func TestNetworkPlugins(t *testing.T) {
5353
podLabel string
5454
hairpin bool
5555
}{
56-
// for containerd and crio runtimes kindnet CNI is used by default and hairpin is enabled
57-
{"auto", []string{}, "", "", ContainerRuntime() != "docker"},
56+
// kindnet CNI is used by default and hairpin is enabled
57+
{"auto", []string{}, "", "", usingCNI()},
5858
{"kubenet", []string{"--network-plugin=kubenet"}, "kubenet", "", true},
5959
{"bridge", []string{"--cni=bridge"}, "cni", "", true},
6060
{"enable-default-cni", []string{"--enable-default-cni=true"}, "cni", "", true},
@@ -79,15 +79,14 @@ func TestNetworkPlugins(t *testing.T) {
7979
t.Skipf("flannel is not yet compatible with Docker driver: iptables v1.8.3 (legacy): Couldn't load target `CNI-x': No such file or directory")
8080
}
8181

82-
if ContainerRuntime() != "docker" && tc.name == "false" {
82+
if usingCNI() && tc.name == "false" {
8383
// CNI is required for current container runtime
8484
validateFalseCNI(ctx, t, profile)
8585
return
8686
}
8787

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

@@ -207,6 +206,21 @@ func TestNetworkPlugins(t *testing.T) {
207206
})
208207
}
209208

209+
// usingCNI checks if not using dockershim
210+
func usingCNI() bool {
211+
if ContainerRuntime() != "docker" {
212+
return true
213+
}
214+
version, err := util.ParseKubernetesVersion(constants.DefaultKubernetesVersion)
215+
if err != nil {
216+
return false
217+
}
218+
if version.GTE(semver.MustParse("1.24.0-alpha.2")) {
219+
return true
220+
}
221+
return false
222+
}
223+
210224
// validateFalseCNI checks that minikube returns and error
211225
// if container runtime is "containerd" or "crio"
212226
// and --cni=false

0 commit comments

Comments
 (0)