diff --git a/Makefile b/Makefile index 35734381d..afea8b840 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ GINKGO_ARGS ?= SKIP_RESOURCE_CLEANUP ?= false USE_EXISTING_CLUSTER ?= false ISOLATED_MODE ?= false +CNI ?= calico # alternatively: kindnet GINKGO_NOCOLOR ?= false GINKGO_LABEL_FILTER ?= short || full GINKGO_TESTS ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/suites/... @@ -522,7 +523,8 @@ test-e2e: $(GINKGO) $(HELM) $(CLUSTERCTL) kubectl e2e-image ## Run the end-to-en -e2e.chart-path=$(ROOT_DIR)/$(CHART_RELEASE_DIR) \ -e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) \ -e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER) \ - -e2e.isolated-mode=$(ISOLATED_MODE) + -e2e.isolated-mode=$(ISOLATED_MODE) \ + -e2e.cni=$(CNI) .PHONY: e2e-image e2e-image: ## Build the image for e2e tests diff --git a/test/e2e/flags.go b/test/e2e/flags.go index 6322f0066..f3c3d4a2e 100644 --- a/test/e2e/flags.go +++ b/test/e2e/flags.go @@ -49,6 +49,9 @@ type FlagValues struct { // ClusterctlBinaryPath is the path to the clusterctl binary to use. ClusterctlBinaryPath string + + // CNI for the cluster to use. Values include calico or kindnet. + CNI string } // InitFlags is used to specify the standard flags for the e2e tests. @@ -62,4 +65,5 @@ func InitFlags(values *FlagValues) { flag.StringVar(&values.ClusterctlBinaryPath, "e2e.clusterctl-binary-path", "helm", "path to the clusterctl binary") flag.StringVar(&values.ChartPath, "e2e.chart-path", "", "path to the operator chart") flag.BoolVar(&values.IsolatedMode, "e2e.isolated-mode", false, "if true, the test will run without ngrok and exposing the cluster to the internet. This setup will only work with CAPD or other providers that run in the same network as the bootstrap cluster.") + flag.StringVar(&values.CNI, "e2e.cni", "calico", "specify CNI solution for the cluster. Allowed values: calico, kindnet") } diff --git a/test/e2e/suites/embedded-capi-disabled/embedded_capi_disabled_test.go b/test/e2e/suites/embedded-capi-disabled/embedded_capi_disabled_test.go index 77936fc59..95a28b2a0 100644 --- a/test/e2e/suites/embedded-capi-disabled/embedded_capi_disabled_test.go +++ b/test/e2e/suites/embedded-capi-disabled/embedded_capi_disabled_test.go @@ -37,6 +37,10 @@ var _ = Describe("[Docker] [Kubeadm] Create and delete CAPI cluster functionalit }) specs.CreateUsingGitOpsSpec(ctx, func() specs.CreateUsingGitOpsSpecInput { + cni := e2e.KindnetCNI + if flagVals.CNI == "calico" { + cni = e2e.CalicoCNI + } return specs.CreateUsingGitOpsSpecInput{ E2EConfig: e2eConfig, BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, @@ -45,7 +49,7 @@ var _ = Describe("[Docker] [Kubeadm] Create and delete CAPI cluster functionalit ArtifactFolder: flagVals.ArtifactFolder, ClusterTemplate: e2e.CAPIDockerKubeadm, ClusterName: "highlander-e2e-cluster1", - CNITemplate: e2e.CalicoCNI, + CNITemplate: cni, ControlPlaneMachineCount: ptr.To[int](1), WorkerMachineCount: ptr.To[int](1), GitAddr: giteaResult.GitAddress, diff --git a/test/e2e/suites/import-gitops/import_gitops_test.go b/test/e2e/suites/import-gitops/import_gitops_test.go index b9718e167..ca390c12c 100644 --- a/test/e2e/suites/import-gitops/import_gitops_test.go +++ b/test/e2e/suites/import-gitops/import_gitops_test.go @@ -39,6 +39,10 @@ var _ = Describe("[Docker] [Kubeadm] Create and delete CAPI cluster functionalit }) specs.CreateUsingGitOpsSpec(ctx, func() specs.CreateUsingGitOpsSpecInput { + cni := e2e.KindnetCNI + if flagVals.CNI == "calico" { + cni = e2e.CalicoCNI + } return specs.CreateUsingGitOpsSpecInput{ E2EConfig: e2eConfig, BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, @@ -47,7 +51,7 @@ var _ = Describe("[Docker] [Kubeadm] Create and delete CAPI cluster functionalit ArtifactFolder: flagVals.ArtifactFolder, ClusterTemplate: e2e.CAPIDockerKubeadm, ClusterName: "highlander-e2e-cluster1", - CNITemplate: e2e.CalicoCNI, + CNITemplate: cni, ControlPlaneMachineCount: ptr.To[int](1), WorkerMachineCount: ptr.To[int](1), GitAddr: giteaResult.GitAddress, diff --git a/test/e2e/suites/managementv3/managementv3_test.go b/test/e2e/suites/managementv3/managementv3_test.go index 3e148e0a5..20f21ef8a 100644 --- a/test/e2e/suites/managementv3/managementv3_test.go +++ b/test/e2e/suites/managementv3/managementv3_test.go @@ -36,6 +36,10 @@ var _ = Describe("[Docker] [Kubeadm] - [management.cattle.io/v3] Create and dele }) specs.CreateMgmtV3UsingGitOpsSpec(ctx, func() specs.CreateMgmtV3UsingGitOpsSpecInput { + cni := e2e.KindnetCNI + if flagVals.CNI == "calico" { + cni = e2e.CalicoCNI + } return specs.CreateMgmtV3UsingGitOpsSpecInput{ E2EConfig: e2eConfig, BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, @@ -44,7 +48,7 @@ var _ = Describe("[Docker] [Kubeadm] - [management.cattle.io/v3] Create and dele ArtifactFolder: flagVals.ArtifactFolder, ClusterTemplate: e2e.CAPIDockerKubeadm, ClusterName: "highlander-e2e-clusterv3-1", - CNITemplate: e2e.CalicoCNI, + CNITemplate: cni, ControlPlaneMachineCount: ptr.To[int](1), WorkerMachineCount: ptr.To[int](1), GitAddr: giteaResult.GitAddress,