diff --git a/test/e2e/features_test.go b/test/e2e/features_test.go index d326f1caff..45f4a2778a 100644 --- a/test/e2e/features_test.go +++ b/test/e2e/features_test.go @@ -250,7 +250,7 @@ func TestDeployAllInOneDBLESSGateway(t *testing.T) { for i, container := range controllerDeployment.Spec.Template.Spec.Containers { if container.Name == controllerContainerName { controllerDeployment.Spec.Template.Spec.Containers[i].Env = append(controllerDeployment.Spec.Template.Spec.Containers[i].Env, - corev1.EnvVar{Name: "CONTROLLER_FEATURE_GATES", Value: consts.DefaultFeatureGates}) + corev1.EnvVar{Name: "CONTROLLER_FEATURE_GATES", Value: testenv.GetFeatureGates()}) } } diff --git a/test/internal/testenv/feature_gates.go b/test/internal/testenv/feature_gates.go index 3d54fc2d6c..0f1338cc23 100644 --- a/test/internal/testenv/feature_gates.go +++ b/test/internal/testenv/feature_gates.go @@ -1,7 +1,32 @@ package testenv -import "github.com/kong/kubernetes-ingress-controller/v3/test/consts" +import ( + "github.com/blang/semver/v4" -func getFeatureGates() string { + "github.com/kong/kubernetes-ingress-controller/v3/test/consts" +) + +func GetFeatureGates() string { + // Due to the possibility of running tests between different versions, + // it is necessary to adjust feature gates according to different KIC versions. + // + // Versions below 3.1.x cannot recognize the KongServiceFacade feature gate. + // We only need to set `GatewayAlpha=true`. + // + // https://github.com/Kong/kubernetes-ingress-controller/issues/5373 + tag := ControllerTag() + if tag != "" { + // Currently, the latest version is 3.0.x, once 3.1.x is released, + // we can remove this logic. + if tag == "latest" { + return "GatewayAlpha=true" + } + if v, err := semver.Make(tag); err == nil { + minVersion, _ := semver.ParseRange("<3.1.x") + if minVersion(v) { + return "GatewayAlpha=true" + } + } + } return consts.DefaultFeatureGates } diff --git a/test/internal/testenv/testenv.go b/test/internal/testenv/testenv.go index 812c5f31f4..c3ed29e539 100644 --- a/test/internal/testenv/testenv.go +++ b/test/internal/testenv/testenv.go @@ -104,7 +104,6 @@ func ControllerImageTag() string { return "" } -// KongEffectiveVersion is the effective semver of kong gateway. // KongEffectiveVersion is the effective semver of kong gateway. // When testing against "nightly" image of kong gateway, we need to set the effective version for parsing semver in chart templates. func KongEffectiveVersion() string { @@ -205,7 +204,7 @@ func GithubRunID() string { func ControllerFeatureGates() string { featureGates := os.Getenv("KONG_CONTROLLER_FEATURE_GATES") if featureGates == "" { - featureGates = getFeatureGates() + featureGates = GetFeatureGates() } return featureGates }