diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 3bef6b0a3..a625bb0fb 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -251,6 +251,7 @@ jobs: - name: run integration tests run: make test.integration env: + KONG_TEST_DISABLE_CERTMANAGER: "true" WEBHOOK_ENABLED: ${{ matrix.webhook-enabled }} KONG_CONTROLLER_OUT: stdout GOTESTSUM_JUNITFILE: integration-tests-webhook-enabled-${{ matrix.webhook-enabled }}.xml @@ -302,6 +303,7 @@ jobs: - name: run integration tests run: make test.integration_bluegreen env: + KONG_TEST_DISABLE_CERTMANAGER: "true" WEBHOOK_ENABLED: ${{ matrix.webhook-enabled }} KONG_CONTROLLER_OUT: stdout GOTESTSUM_JUNITFILE: integration-tests-bluegreen-webhook-enabled-${{ matrix.webhook-enabled }}.xml @@ -338,8 +340,6 @@ jobs: steps: - name: checkout repository uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: setup golang uses: actions/setup-go@v5 @@ -353,6 +353,7 @@ jobs: - name: run integration tests run: make test.integration_provision_dataplane_fail env: + KONG_TEST_DISABLE_CERTMANAGER: "true" KONG_CONTROLLER_OUT: stdout GOTESTSUM_JUNITFILE: integration-tests-provision-dataplane-fail.xml GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/test/conformance/suite_test.go b/test/conformance/suite_test.go index 8dffb1953..25c071780 100644 --- a/test/conformance/suite_test.go +++ b/test/conformance/suite_test.go @@ -24,6 +24,7 @@ import ( "github.com/kong/gateway-operator/modules/manager" "github.com/kong/gateway-operator/modules/manager/scheme" testutils "github.com/kong/gateway-operator/pkg/utils/test" + "github.com/kong/gateway-operator/test" ) // ----------------------------------------------------------------------------- @@ -80,7 +81,9 @@ func TestMain(m *testing.M) { // that would allow e.g. cross namespace traffic. // Related upstream discussion: https://github.com/kubernetes-sigs/gateway-api/discussions/2137 env, err = testutils.BuildEnvironment(ctx, existingCluster, func(b *environments.Builder, t clusters.Type) { - b.WithAddons(metallb.New()) + if !test.DisableMetalLB { + b.WithAddons(metallb.New()) + } }) exitOnErr(err) diff --git a/test/e2e/environment.go b/test/e2e/environment.go index 898b13f3d..09daf58d8 100644 --- a/test/e2e/environment.go +++ b/test/e2e/environment.go @@ -37,6 +37,7 @@ import ( "github.com/kong/gateway-operator/internal/versions" "github.com/kong/gateway-operator/pkg/clientset" testutils "github.com/kong/gateway-operator/pkg/utils/test" + "github.com/kong/gateway-operator/test" "github.com/kong/gateway-operator/test/helpers" ) @@ -147,27 +148,37 @@ func CreateEnvironment(t *testing.T, ctx context.Context, opts ...TestEnvOption) cluster, err := kind.NewFromExisting(clusterName) require.NoError(t, err) builder.WithExistingCluster(cluster) - builder.WithAddons(metallb.New()) - builder.WithAddons(certmanager.New()) + + if !test.DisableCertManager { + builder.WithAddons(certmanager.New()) + } + if !test.DisableMetalLB { + builder.WithAddons(metallb.New()) + } case string(gke.GKEClusterType): cluster, err := gke.NewFromExistingWithEnv(ctx, clusterName) require.NoError(t, err) builder.WithExistingCluster(cluster) - builder.WithAddons(certmanager.New()) + if !test.DisableCertManager { + builder.WithAddons(certmanager.New()) + } default: t.Fatal(fmt.Errorf("unknown cluster type: %s", clusterType)) } } else { t.Log("no existing cluster found, deploying using Kubernetes In Docker (KIND)") - builder.WithAddons(metallb.New()) - builder.WithAddons(certmanager.New()) + if !test.DisableCertManager { + builder.WithAddons(certmanager.New()) + } + if !test.DisableMetalLB { + builder.WithAddons(metallb.New()) + } } if imageLoad != "" { imageLoader, err := loadimage.NewBuilder().WithImage(imageLoad) require.NoError(t, err) t.Logf("loading image: %s", imageLoad) builder.WithAddons(imageLoader.Build()) - builder.WithAddons(certmanager.New()) } if len(opt.Image) == 0 { diff --git a/test/envvars.go b/test/envvars.go new file mode 100644 index 000000000..bf70a5d05 --- /dev/null +++ b/test/envvars.go @@ -0,0 +1,15 @@ +package test + +import ( + "os" + "strings" +) + +var ( + // DisableCalicoCNI is a flag to disable the Calico CNI plugin in the test environment. + DisableCalicoCNI = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CALICO")) == "true" + // DisableCertManager is a flag to disable the CertManager in the test environment. + DisableCertManager = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CERTMANAGER")) == "true" + // DisableMetalLB is a flag to disable the MetalLB in the test environment. + DisableMetalLB = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_METALLB")) == "true" +) diff --git a/test/integration/suite.go b/test/integration/suite.go index 1a3b55ae7..d03e8c675 100644 --- a/test/integration/suite.go +++ b/test/integration/suite.go @@ -24,6 +24,7 @@ import ( "github.com/kong/gateway-operator/config" "github.com/kong/gateway-operator/modules/manager" testutils "github.com/kong/gateway-operator/pkg/utils/test" + "github.com/kong/gateway-operator/test" "github.com/kong/gateway-operator/test/helpers" "github.com/kong/gateway-operator/test/helpers/certificate" ) @@ -40,9 +41,6 @@ var ( webhookServerIP = os.Getenv("GATEWAY_OPERATOR_WEBHOOK_IP") bluegreenController = strings.ToLower(os.Getenv("GATEWAY_OPERATOR_BLUEGREEN_CONTROLLER")) == "true" webhookServerPort = 9443 - disableCalicoCNI = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CALICO")) == "true" - disableCertManager = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_CERTMANAGER")) == "true" - disableMetalLB = strings.ToLower(os.Getenv("KONG_TEST_DISABLE_METALLB")) == "true" ) // ----------------------------------------------------------------------------- @@ -124,13 +122,13 @@ func TestMain( fmt.Println("INFO: configuring cluster for testing environment") env, err = testutils.BuildEnvironment(GetCtx(), existingCluster, func(b *environments.Builder, ct clusters.Type) { - if !disableCalicoCNI { + if !test.DisableCalicoCNI { b.WithCalicoCNI() } - if !disableCertManager { + if !test.DisableCertManager { b.WithAddons(certmanager.New()) } - if !disableMetalLB && ct == kind.KindClusterType { + if !test.DisableMetalLB && ct == kind.KindClusterType { b.WithAddons(metallb.New()) } },