diff --git a/test/helpers/generators.go b/test/helpers/generators.go index 0827cb814..941d3623b 100644 --- a/test/helpers/generators.go +++ b/test/helpers/generators.go @@ -65,9 +65,11 @@ func GenerateGateway(gatewayNSN types.NamespacedName, gatewayClass *gatewayv1.Ga return gateway } +type gatewayConfigurationOption func(*operatorv1beta1.GatewayConfiguration) + // GenerateGatewayConfiguration generates a GatewayConfiguration to be used in tests -func GenerateGatewayConfiguration(namespace string) *operatorv1beta1.GatewayConfiguration { - return &operatorv1beta1.GatewayConfiguration{ +func GenerateGatewayConfiguration(namespace string, opts ...gatewayConfigurationOption) *operatorv1beta1.GatewayConfiguration { + gwc := &operatorv1beta1.GatewayConfiguration{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: uuid.NewString(), @@ -139,6 +141,20 @@ func GenerateGatewayConfiguration(namespace string) *operatorv1beta1.GatewayConf }, }, } + for _, opt := range opts { + opt(gwc) + } + return gwc +} + +// WithWebhookDisabled disables the admission webhook for the control plane +func WithWebhookDisabled() func(*operatorv1beta1.GatewayConfiguration) { + return func(gc *operatorv1beta1.GatewayConfiguration) { + gc.Spec.ControlPlaneOptions.Deployment.PodTemplateSpec.Spec.Containers[0].Env = append(gc.Spec.ControlPlaneOptions.Deployment.PodTemplateSpec.Spec.Containers[0].Env, corev1.EnvVar{ + Name: "CONTROLLER_ADMISSION_WEBHOOK_LISTEN", + Value: "off", + }) + } } // GenerateHTTPRoute generates an HTTPRoute to be used in tests diff --git a/test/integration/test_kongplugininstallation.go b/test/integration/test_kongplugininstallation.go index b40ba7dba..148536c23 100644 --- a/test/integration/test_kongplugininstallation.go +++ b/test/integration/test_kongplugininstallation.go @@ -31,11 +31,6 @@ import ( ) func TestKongPluginInstallationEssentials(t *testing.T) { - if webhookEnabled { - // It can't be tested with webhook, because it rejects resources immediately, that would - // be accepted by the controller taking into account the eventual consistency nature of K8s. - t.Skip("webhook is enabled, skipping the test (due to webhook validation limitations)") - } namespace, cleaner := helpers.SetupTestEnv(t, GetCtx(), GetEnv()) const registryUrl = "northamerica-northeast1-docker.pkg.dev/k8s-team-playground/" @@ -212,7 +207,9 @@ func TestKongPluginInstallationEssentials(t *testing.T) { func deployGatewayWithKPI( t *testing.T, cleaner *clusters.Cleaner, namespace string, ) (gatewayIPAddress string, gatewayConfigNN, httpRouteNN k8stypes.NamespacedName) { - gatewayConfig := helpers.GenerateGatewayConfiguration(namespace) + // NOTE: Disable webhook for KIC, because it checks for the plugin in Kong Gateway and rejects, + // thus it requires strict order of deployment. + gatewayConfig := helpers.GenerateGatewayConfiguration(namespace, helpers.WithWebhookDisabled()) t.Logf("deploying GatewayConfiguration %s/%s", gatewayConfig.Namespace, gatewayConfig.Name) gatewayConfig, err := GetClients().OperatorClient.ApisV1beta1().GatewayConfigurations(namespace).Create(GetCtx(), gatewayConfig, metav1.CreateOptions{}) require.NoError(t, err)