From e9ba8205797808bb6c2dc3119ab2b89dd8f2a806 Mon Sep 17 00:00:00 2001 From: Alexander Demicev Date: Wed, 27 Nov 2024 15:14:54 +0100 Subject: [PATCH] Add etcd snapshot restore e2e setup (#854) * Configure helm chart for etcd snapshot restore manifests Signed-off-by: Alexandr Demicev * Add etcd snapshot restore e2e setup Signed-off-by: Alexandr Demicev --------- Signed-off-by: Alexandr Demicev --- .github/workflows/e2e-long.yaml | 9 + Makefile | 13 +- ...er-turtles-exp-etcdrestore-components.yaml | 47 ++-- charts/rancher-turtles/values.yaml | 3 + scripts/process-exp-etcdrestore-manifests.sh | 27 +++ test/e2e/config/operator.yaml | 4 +- .../etcd_snapshot_restore_test.go | 39 +++ .../etcd-snapshot-restore/suite_test.go | 228 ++++++++++++++++++ 8 files changed, 347 insertions(+), 23 deletions(-) create mode 100644 test/e2e/suites/etcd-snapshot-restore/etcd_snapshot_restore_test.go create mode 100644 test/e2e/suites/etcd-snapshot-restore/suite_test.go diff --git a/.github/workflows/e2e-long.yaml b/.github/workflows/e2e-long.yaml index 65e8158d..115503d1 100644 --- a/.github/workflows/e2e-long.yaml +++ b/.github/workflows/e2e-long.yaml @@ -62,3 +62,12 @@ jobs: artifact_name: artifacts_embedded_capi_v3 MANAGEMENT_CLUSTER_ENVIRONMENT: eks secrets: inherit + e2e_etcd_snapshot_restore: + uses: ./.github/workflows/run-e2e-suite.yaml + with: + test_suite: test/e2e/suites/etcd-snapshot-restore + test_name: Etcd snapshot restore + run_azure_janitor: false + artifact_name: artifacts_etcd_snapshot_restore + MANAGEMENT_CLUSTER_ENVIRONMENT: eks + secrets: inherit diff --git a/Makefile b/Makefile index e31644a3..8d1a9a14 100644 --- a/Makefile +++ b/Makefile @@ -585,9 +585,15 @@ build-chart: $(HELM) $(KUSTOMIZE) $(RELEASE_DIR) $(CHART_RELEASE_DIR) $(CHART_PA $(KUSTOMIZE) build ./exp/etcdrestore/config/default > $(CHART_DIR)/templates/rancher-turtles-exp-etcdrestore-components.yaml ./scripts/process-exp-etcdrestore-manifests.sh $(CHART_DIR)/templates/rancher-turtles-exp-etcdrestore-components.yaml cp -rf $(CHART_DIR)/* $(CHART_RELEASE_DIR) + sed -i'' -e 's@image: .*@image: '"$(CONTROLLER_IMG)"'@' $(CHART_RELEASE_DIR)/values.yaml sed -i'' -e 's@imageVersion: .*@imageVersion: '"$(RELEASE_TAG)"'@' $(CHART_RELEASE_DIR)/values.yaml sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(CHART_RELEASE_DIR)/values.yaml + + sed -i'' -e '/etcd-snapshot-restore:/,/image:/ s@image: .*@image: '"$(ETCDRESTORE_IMG)"'@' $(CHART_RELEASE_DIR)/values.yaml + sed -i'' -e '/etcd-snapshot-restore:/,/imageVersion:/ s@imageVersion: .*@imageVersion: '"$(RELEASE_TAG)"'@' $(CHART_RELEASE_DIR)/values.yaml + sed -i'' -e '/etcd-snapshot-restore:/,/imagePullPolicy:/ s@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(CHART_RELEASE_DIR)/values.yaml + cd $(CHART_RELEASE_DIR) && $(HELM) dependency update $(HELM) package $(CHART_RELEASE_DIR) --app-version=$(HELM_CHART_TAG) --version=$(HELM_CHART_TAG) --destination=$(CHART_PACKAGE_DIR) @@ -621,12 +627,17 @@ test-e2e-push-image: $(GINKGO) $(HELM) $(CLUSTERCTL) kubectl e2e-image-push .PHONY: e2e-image e2e-image: $(CACHE_DIR) ## Build the image for e2e tests ADDITIONAL_COMMANDS=$(CACHE_COMMANDS) TAG=v0.0.1 CONTROLLER_IMAGE_NAME=turtles-e2e $(MAKE) docker-build - RELEASE_TAG=v0.0.1 CONTROLLER_IMG=$(REGISTRY)/$(ORG)/turtles-e2e CONTROLLER_IMAGE_VERSION=v0.0.1 $(MAKE) build-chart + ADDITIONAL_COMMANDS=$(CACHE_COMMANDS) TAG=v0.0.1 ETCDRESTORE_IMAGE_NAME=turtles-etcd-snapshot-restore-e2e $(MAKE) docker-build-etcdrestore + RELEASE_TAG=v0.0.1 CONTROLLER_IMG=$(REGISTRY)/$(ORG)/turtles-e2e ETCDRESTORE_IMG=$(REGISTRY)/$(ORG)/turtles-etcd-snapshot-restore-e2e \ + CONTROLLER_IMAGE_VERSION=v0.0.1 \ + $(MAKE) build-chart .PHONY: e2e-image-push e2e-image-push: $(CACHE_DIR) ## Push the image for e2e tests TARGET_PLATFORMS=$(ARCH) TAG=v0.0.1 CONTROLLER_IMAGE_NAME=turtles-e2e \ ADDITIONAL_COMMANDS=$(CACHE_COMMANDS) $(MAKE) docker-build-and-push + TARGET_PLATFORMS=$(ARCH) TAG=v0.0.1 ETCDRESTORE_IMAGE_NAME=turtles-etcd-snapshot-restore-e2e \ + ADDITIONAL_COMMANDS=$(CACHE_COMMANDS) $(MAKE) docker-build-and-push-etcdrestore .PHONY: compile-e2e e2e-compile: ## Test e2e compilation diff --git a/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml b/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml index 726b133f..dd759941 100644 --- a/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml +++ b/charts/rancher-turtles/templates/rancher-turtles-exp-etcdrestore-components.yaml @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert + cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert controller-gen.kubebuilder.io/version: v0.14.0 labels: turtles-capi.cattle.io: etcd-restore @@ -101,7 +101,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert + cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert controller-gen.kubebuilder.io/version: v0.14.0 labels: turtles-capi.cattle.io: etcd-restore @@ -220,7 +220,7 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: annotations: - cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert + cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert controller-gen.kubebuilder.io/version: v0.14.0 labels: turtles-capi.cattle.io: etcd-restore @@ -309,7 +309,7 @@ metadata: app.kubernetes.io/part-of: rancher-turtles turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-manager - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: Role @@ -323,7 +323,7 @@ metadata: app.kubernetes.io/part-of: rancher-turtles turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-leader-election-role - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} rules: - apiGroups: - "" @@ -572,7 +572,7 @@ metadata: app.kubernetes.io/part-of: rancher-turtles turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-leader-election-rolebinding - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} roleRef: apiGroup: rbac.authorization.k8s.io kind: Role @@ -580,7 +580,7 @@ roleRef: subjects: - kind: ServiceAccount name: rancher-turtles-etcdsnapshotrestore-manager - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding @@ -601,7 +601,7 @@ roleRef: subjects: - kind: ServiceAccount name: rancher-turtles-etcdsnapshotrestore-manager - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} --- apiVersion: v1 kind: Service @@ -609,7 +609,7 @@ metadata: labels: turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-webhook-service - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} spec: ports: - port: 443 @@ -624,7 +624,7 @@ metadata: control-plane: controller-manager turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-controller-manager - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} spec: replicas: 1 selector: @@ -657,8 +657,13 @@ spec: valueFrom: fieldRef: fieldPath: metadata.uid - image: ghcr.io/rancher/turtles-etcd-snapshot-restore:dev - imagePullPolicy: IfNotPresent + {{- $imageVersion := index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" -}} + {{- if contains "sha256:" $imageVersion }} + image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}@{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }} + {{- else }} + image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}:{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }} + {{- end }} + imagePullPolicy: '{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imagePullPolicy" }}' livenessProbe: httpGet: path: /healthz @@ -705,11 +710,11 @@ metadata: labels: turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-serving-cert - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} spec: dnsNames: - - rancher-turtles-etcdsnapshotrestore-webhook-service.rancher-turtles-system.svc - - rancher-turtles-etcdsnapshotrestore-webhook-service.rancher-turtles-system.svc.cluster.local + - rancher-turtles-etcdsnapshotrestore-webhook-service.{{ index .Values "rancherTurtles" "namespace" }}.svc + - rancher-turtles-etcdsnapshotrestore-webhook-service.{{ index .Values "rancherTurtles" "namespace" }}.svc.cluster.local issuerRef: kind: Issuer name: rancher-turtles-etcdsnapshotrestore-selfsigned-issuer @@ -721,7 +726,7 @@ metadata: labels: turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-selfsigned-issuer - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} spec: selfSigned: {} --- @@ -729,7 +734,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: MutatingWebhookConfiguration metadata: annotations: - cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert + cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert labels: turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-mutating-webhook-configuration @@ -739,7 +744,7 @@ webhooks: clientConfig: service: name: rancher-turtles-etcdsnapshotrestore-webhook-service - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} path: /mutate-bootstrap-cluster-x-k8s-io-v1beta1-rke2config failurePolicy: Fail name: systemagentrke2config.kb.io @@ -759,7 +764,7 @@ apiVersion: admissionregistration.k8s.io/v1 kind: ValidatingWebhookConfiguration metadata: annotations: - cert-manager.io/inject-ca-from: rancher-turtles-system/rancher-turtles-etcdsnapshotrestore-serving-cert + cert-manager.io/inject-ca-from: {{ index .Values "rancherTurtles" "namespace" }}/rancher-turtles-etcdsnapshotrestore-serving-cert labels: turtles-capi.cattle.io: etcd-restore name: rancher-turtles-etcdsnapshotrestore-validating-webhook-configuration @@ -769,7 +774,7 @@ webhooks: clientConfig: service: name: rancher-turtles-etcdsnapshotrestore-webhook-service - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} path: /validate-turtles-capi-cattle-io-v1alpha1-etcdmachinesnapshot failurePolicy: Fail matchPolicy: Equivalent @@ -790,7 +795,7 @@ webhooks: clientConfig: service: name: rancher-turtles-etcdsnapshotrestore-webhook-service - namespace: rancher-turtles-system + namespace: {{ index .Values "rancherTurtles" "namespace" }} path: /validate-turtles-capi-cattle-io-v1alpha1-etcdsnapshotrestore failurePolicy: Fail matchPolicy: Equivalent diff --git a/charts/rancher-turtles/values.yaml b/charts/rancher-turtles/values.yaml index 5d3ed294..4a122d1d 100644 --- a/charts/rancher-turtles/values.yaml +++ b/charts/rancher-turtles/values.yaml @@ -25,6 +25,9 @@ rancherTurtles: enabled: false etcd-snapshot-restore: enabled: false + image: controller + imageVersion: v0.0.0 + imagePullPolicy: IfNotPresent addon-provider-fleet: enabled: false cluster-api-operator: diff --git a/scripts/process-exp-etcdrestore-manifests.sh b/scripts/process-exp-etcdrestore-manifests.sh index e21ee9d7..b527e1c0 100755 --- a/scripts/process-exp-etcdrestore-manifests.sh +++ b/scripts/process-exp-etcdrestore-manifests.sh @@ -8,6 +8,13 @@ fi filename=$1 +# Determine the appropriate sed command +if [[ "$OSTYPE" == "darwin"* ]]; then + sed_cmd="gsed" +else + sed_cmd="sed" +fi + # Define the content to append at the beginning and end of the file start_content="{{- if index .Values \"rancherTurtles\" \"features\" \"etcd-snapshot-restore\" \"enabled\" }}" end_content="{{- end }}" @@ -18,3 +25,23 @@ echo "$start_content" | cat - "$filename" > temp && mv temp "$filename" # Append content at the end of the file echo "$end_content" >> "$filename" +# 1. Replace "rancher-turtles-system" with the templated namespace +$sed_cmd -i "s|rancher-turtles-system|{{ index .Values \"rancherTurtles\" \"namespace\" }}|g" "$filename" + +# 2. Replace "rancher-turtles-system" with the templated image +$sed_cmd -i "s|rancher-turtles-system|{{ index .Values \"rancherTurtles\" \"features\" \"etcd-snapshot-restore\" \"image\" }}|g" "$filename" + +# 3. Update the "image:" section dynamically based on conditions +$sed_cmd -i '/image: ghcr.io\/rancher\/turtles-etcd-snapshot-restore:dev/c\ + {{- $imageVersion := index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" -}}\ + {{- if contains "sha256:" $imageVersion }}\ + image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}@{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }}\ + {{- else }}\ + image: {{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "image" }}:{{ index .Values "rancherTurtles" "features" "etcd-snapshot-restore" "imageVersion" }}\ + {{- end }}' "$filename" + +# 4. Replace the "imagePullPolicy" dynamically +$sed_cmd -i "s|imagePullPolicy: IfNotPresent|imagePullPolicy: '{{ index .Values \"rancherTurtles\" \"features\" \"etcd-snapshot-restore\" \"imagePullPolicy\" }}'|g" "$filename" + +# Confirmation message +echo "All replacements applied successfully to $filename" diff --git a/test/e2e/config/operator.yaml b/test/e2e/config/operator.yaml index 20fdf318..dec37975 100644 --- a/test/e2e/config/operator.yaml +++ b/test/e2e/config/operator.yaml @@ -2,7 +2,9 @@ managementClusterName: rancher-turtles-e2e images: # Use local dev images built source tree; -- name: ghcr.io/rancher/turtles-e2e:v0.0.1 # This should be substituted with operator image +- name: ghcr.io/rancher/turtles-e2e:v0.0.1 + loadBehavior: tryLoad +- name: ghcr.io/rancher/turtles-etcd-snapshot-restore-e2e:v0.0.1 loadBehavior: tryLoad intervals: diff --git a/test/e2e/suites/etcd-snapshot-restore/etcd_snapshot_restore_test.go b/test/e2e/suites/etcd-snapshot-restore/etcd_snapshot_restore_test.go new file mode 100644 index 00000000..dcf905b4 --- /dev/null +++ b/test/e2e/suites/etcd-snapshot-restore/etcd_snapshot_restore_test.go @@ -0,0 +1,39 @@ +//go:build e2e +// +build e2e + +/* +Copyright © 2023 - 2024 SUSE LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package etcd_snapshot_restore + +import ( + _ "embed" + + . "github.com/onsi/ginkgo/v2" + . "sigs.k8s.io/controller-runtime/pkg/envtest/komega" + + "github.com/rancher/turtles/test/e2e" +) + +var _ = Describe("[Docker] [RKE2] Perform an ETCD backup and restore of the cluster", Label(e2e.ShortTestLabel), func() { + BeforeEach(func() { + SetClient(setupClusterResult.BootstrapClusterProxy.GetClient()) + SetContext(ctx) + }) + + It("should perform an ETCD backup and restore of the cluster", func() { + }) +}) diff --git a/test/e2e/suites/etcd-snapshot-restore/suite_test.go b/test/e2e/suites/etcd-snapshot-restore/suite_test.go new file mode 100644 index 00000000..f1b88fe1 --- /dev/null +++ b/test/e2e/suites/etcd-snapshot-restore/suite_test.go @@ -0,0 +1,228 @@ +//go:build e2e +// +build e2e + +/* +Copyright © 2023 - 2024 SUSE LLC + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package etcd_snapshot_restore + +import ( + "context" + "fmt" + "path/filepath" + "strconv" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/rancher/turtles/test/e2e" + "github.com/rancher/turtles/test/framework" + "github.com/rancher/turtles/test/testenv" + "k8s.io/klog/v2" + "sigs.k8s.io/cluster-api/test/framework/clusterctl" + ctrl "sigs.k8s.io/controller-runtime" +) + +// Test suite flags. +var ( + flagVals *e2e.FlagValues +) + +// Test suite global vars. +var ( + // e2eConfig to be used for this test, read from configPath. + e2eConfig *clusterctl.E2EConfig + + // clusterctlConfigPath to be used for this test, created by generating a clusterctl local repository + // with the providers specified in the configPath. + clusterctlConfigPath string + + // hostName is the host name for the Rancher Manager server. + hostName string + + artifactsFolder string + + ctx = context.Background() + + setupClusterResult *testenv.SetupTestClusterResult + giteaResult *testenv.DeployGiteaResult +) + +func init() { + flagVals = &e2e.FlagValues{} + e2e.InitFlags(flagVals) +} + +func TestE2E(t *testing.T) { + RegisterFailHandler(Fail) + + ctrl.SetLogger(klog.Background()) + + RunSpecs(t, "rancher-turtles-e2e-import-gitops") +} + +var _ = BeforeSuite(func() { + By(fmt.Sprintf("Loading the e2e test configuration from %q", flagVals.ConfigPath)) + Expect(flagVals.ConfigPath).To(BeAnExistingFile(), "Invalid test suite argument. e2e.config should be an existing file.") + e2eConfig = e2e.LoadE2EConfig(flagVals.ConfigPath) + e2e.ValidateE2EConfig(e2eConfig) + + artifactsFolder = e2eConfig.GetVariable(e2e.ArtifactsFolderVar) + + preSetupOutput := testenv.PreManagementClusterSetupHook(e2eConfig) + + By(fmt.Sprintf("Creating a clusterctl config into %q", artifactsFolder)) + clusterctlConfigPath = e2e.CreateClusterctlLocalRepository(ctx, e2eConfig, filepath.Join(artifactsFolder, "repository")) + + useExistingCluter, err := strconv.ParseBool(e2eConfig.GetVariable(e2e.UseExistingClusterVar)) + Expect(err).ToNot(HaveOccurred(), "Failed to parse the USE_EXISTING_CLUSTER variable") + + setupClusterResult = testenv.SetupTestCluster(ctx, testenv.SetupTestClusterInput{ + UseExistingCluster: useExistingCluter, + E2EConfig: e2eConfig, + ClusterctlConfigPath: clusterctlConfigPath, + Scheme: e2e.InitScheme(), + ArtifactFolder: artifactsFolder, + KubernetesVersion: e2eConfig.GetVariable(e2e.KubernetesManagementVersionVar), + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + CustomClusterProvider: preSetupOutput.CustomClusterProvider, + }) + + testenv.RancherDeployIngress(ctx, testenv.RancherDeployIngressInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + HelmExtraValuesPath: filepath.Join(e2eConfig.GetVariable(e2e.HelmExtraValuesFolderVar), "deploy-rancher-ingress.yaml"), + IngressType: preSetupOutput.IngressType, + CustomIngress: e2e.NginxIngress, + CustomIngressNamespace: e2e.NginxIngressNamespace, + CustomIngressDeployment: e2e.NginxIngressDeployment, + IngressWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-rancher"), + NgrokApiKey: e2eConfig.GetVariable(e2e.NgrokApiKeyVar), + NgrokAuthToken: e2eConfig.GetVariable(e2e.NgrokAuthTokenVar), + NgrokPath: e2eConfig.GetVariable(e2e.NgrokPathVar), + NgrokRepoName: e2eConfig.GetVariable(e2e.NgrokRepoNameVar), + NgrokRepoURL: e2eConfig.GetVariable(e2e.NgrokUrlVar), + DefaultIngressClassPatch: e2e.IngressClassPatch, + }) + + rancherInput := testenv.DeployRancherInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + HelmExtraValuesPath: filepath.Join(e2eConfig.GetVariable(e2e.HelmExtraValuesFolderVar), "deploy-rancher.yaml"), + InstallCertManager: true, + CertManagerChartPath: e2eConfig.GetVariable(e2e.CertManagerPathVar), + CertManagerUrl: e2eConfig.GetVariable(e2e.CertManagerUrlVar), + CertManagerRepoName: e2eConfig.GetVariable(e2e.CertManagerRepoNameVar), + RancherChartRepoName: e2eConfig.GetVariable(e2e.RancherAlphaRepoNameVar), + RancherChartURL: e2eConfig.GetVariable(e2e.RancherAlphaUrlVar), + RancherChartPath: e2eConfig.GetVariable(e2e.RancherAlphaPathVar), + RancherVersion: e2eConfig.GetVariable(e2e.RancherAlphaVersionVar), + RancherNamespace: e2e.RancherNamespace, + RancherPassword: e2eConfig.GetVariable(e2e.RancherPasswordVar), + RancherPatches: [][]byte{e2e.RancherSettingPatch}, + RancherWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-rancher"), + ControllerWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"), + Variables: e2eConfig.Variables, + } + + rancherHookResult := testenv.PreRancherInstallHook( + &testenv.PreRancherInstallHookInput{ + Ctx: ctx, + RancherInput: &rancherInput, + E2EConfig: e2eConfig, + SetupClusterResult: setupClusterResult, + PreSetupOutput: preSetupOutput, + }) + + hostName = rancherHookResult.HostName + + testenv.DeployRancher(ctx, rancherInput) + + rtInput := testenv.DeployRancherTurtlesInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + TurtlesChartPath: e2eConfig.GetVariable(e2e.TurtlesPathVar), + CAPIProvidersYAML: e2e.CapiProviders, + Namespace: framework.DefaultRancherTurtlesNamespace, + Image: "ghcr.io/rancher/turtles-e2e", + Tag: e2eConfig.GetVariable(e2e.TurtlesVersionVar), + WaitDeploymentsReadyInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-controllers"), + AdditionalValues: map[string]string{ + "rancherTurtles.features.etcd-snapshot-restore.enabled": "true", // enable etcd-snapshot-restore feature + }, + } + + testenv.PreRancherTurtlesInstallHook(&rtInput, e2eConfig) + + testenv.DeployRancherTurtles(ctx, rtInput) + + giteaInput := testenv.DeployGiteaInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + ChartRepoName: e2eConfig.GetVariable(e2e.GiteaRepoNameVar), + ChartRepoURL: e2eConfig.GetVariable(e2e.GiteaRepoURLVar), + ChartName: e2eConfig.GetVariable(e2e.GiteaChartNameVar), + ChartVersion: e2eConfig.GetVariable(e2e.GiteaChartVersionVar), + ValuesFilePath: "../../data/gitea/values.yaml", + Values: map[string]string{ + "gitea.admin.username": e2eConfig.GetVariable(e2e.GiteaUserNameVar), + "gitea.admin.password": e2eConfig.GetVariable(e2e.GiteaUserPasswordVar), + }, + RolloutWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-gitea"), + ServiceWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-gitea-service"), + AuthSecretName: e2e.AuthSecretName, + Username: e2eConfig.GetVariable(e2e.GiteaUserNameVar), + Password: e2eConfig.GetVariable(e2e.GiteaUserPasswordVar), + CustomIngressConfig: e2e.GiteaIngress, + Variables: e2eConfig.Variables, + } + + testenv.PreGiteaInstallHook(&giteaInput, e2eConfig) + + giteaResult = testenv.DeployGitea(ctx, giteaInput) +}) + +var _ = AfterSuite(func() { + testenv.UninstallGitea(ctx, testenv.UninstallGiteaInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + DeleteWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-gitea-uninstall"), + }) + + testenv.UninstallRancherTurtles(ctx, testenv.UninstallRancherTurtlesInput{ + BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy, + HelmBinaryPath: e2eConfig.GetVariable(e2e.HelmBinaryPathVar), + Namespace: framework.DefaultRancherTurtlesNamespace, + DeleteWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-turtles-uninstall"), + }) + + skipCleanup, err := strconv.ParseBool(e2eConfig.GetVariable(e2e.SkipResourceCleanupVar)) + Expect(err).ToNot(HaveOccurred(), "Failed to parse the SKIP_RESOURCE_CLEANUP variable") + + testenv.CleanupTestCluster(ctx, testenv.CleanupTestClusterInput{ + SetupTestClusterResult: *setupClusterResult, + SkipCleanup: skipCleanup, + ArtifactFolder: artifactsFolder, + }) +}) + +func shortTestOnly() bool { + return GinkgoLabelFilter() == e2e.ShortTestLabel +} + +func localTestOnly() bool { + return GinkgoLabelFilter() == e2e.LocalTestLabel +}