@@ -53,8 +53,8 @@ func TestNetworkPlugins(t *testing.T) {
53
53
podLabel string
54
54
hairpin bool
55
55
}{
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 () },
58
58
{"kubenet" , []string {"--network-plugin=kubenet" }, "kubenet" , "" , true },
59
59
{"bridge" , []string {"--cni=bridge" }, "cni" , "" , true },
60
60
{"enable-default-cni" , []string {"--enable-default-cni=true" }, "cni" , "" , true },
@@ -79,15 +79,14 @@ func TestNetworkPlugins(t *testing.T) {
79
79
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" )
80
80
}
81
81
82
- if ContainerRuntime () != "docker" && tc .name == "false" {
82
+ if usingCNI () && tc .name == "false" {
83
83
// CNI is required for current container runtime
84
84
validateFalseCNI (ctx , t , profile )
85
85
return
86
86
}
87
87
88
- if ContainerRuntime () != "docker" && tc .name == "kubenet" {
88
+ if usingCNI () && tc .name == "kubenet" {
89
89
// CNI is disabled when --network-plugin=kubenet option is passed. See cni.New(..) function
90
- // But for containerd/crio CNI has to be configured
91
90
t .Skipf ("Skipping the test as %s container runtimes requires CNI" , ContainerRuntime ())
92
91
}
93
92
@@ -207,6 +206,21 @@ func TestNetworkPlugins(t *testing.T) {
207
206
})
208
207
}
209
208
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
+
210
224
// validateFalseCNI checks that minikube returns and error
211
225
// if container runtime is "containerd" or "crio"
212
226
// and --cni=false
0 commit comments