Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tests): disable KIC admission webhook for TestKongPluginInstallationEssentials #656

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions test/helpers/generators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -139,6 +141,20 @@ func GenerateGatewayConfiguration(namespace string) *operatorv1beta1.GatewayConf
},
},
}
for _, opt := range opts {
opt(gwc)
}
return gwc
}

// WithControlPlaneWebhookDisabled disables the admission webhook for the control plane
func WithControlPlaneWebhookDisabled() 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
Expand Down
9 changes: 3 additions & 6 deletions test/integration/test_kongplugininstallation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down Expand Up @@ -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 which is not guaranteed.
gatewayConfig := helpers.GenerateGatewayConfiguration(namespace, helpers.WithControlPlaneWebhookDisabled())
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)
Expand Down
Loading