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: cover uninstall in e2e tests #474

Merged
merged 2 commits into from
May 2, 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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ GINGKO_VER := $(call get_go_version,github.com/onsi/ginkgo/v2)
GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINGKO_VER))
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo

HELM_VER := v3.8.1
HELM_VER := v3.14.0
HELM_BIN := helm
HELM := $(TOOLS_BIN_DIR)/$(HELM_BIN)-$(HELM_VER)

Expand Down
1 change: 1 addition & 0 deletions test/e2e/config/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ intervals:
default/wait-vsphere-delete: ["20m", "30s"]
default/wait-gitea-service: ["5m", "30s"]
default/wait-gitea-uninstall: ["10m", "30s"]
default/wait-turtles-uninstall: ["10m", "30s"]

variables:
RANCHER_VERSION: "v2.8.1"
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/suites/import-gitops/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ var _ = AfterSuite(func() {
DeleteWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-gitea-uninstall"),
})

testenv.UninstallRancherTurtles(ctx, testenv.UninstallRancherTurtlesInput{
BootstrapClusterProxy: setupClusterResult.BootstrapClusterProxy,
HelmBinaryPath: flagVals.HelmBinaryPath,
Namespace: turtlesframework.DefaultRancherTurtlesNamespace,
DeleteWaitInterval: e2eConfig.GetIntervals(setupClusterResult.BootstrapClusterProxy.GetName(), "wait-turtles-uninstall"),
})

testenv.CleanupTestCluster(ctx, testenv.CleanupTestClusterInput{
SetupTestClusterResult: *setupClusterResult,
SkipCleanup: flagVals.SkipCleanup,
Expand Down
34 changes: 34 additions & 0 deletions test/testenv/turtles.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ type DeployRancherTurtlesInput struct {
AdditionalValues map[string]string
}

type UninstallRancherTurtlesInput struct {
BootstrapClusterProxy framework.ClusterProxy
HelmBinaryPath string
Namespace string
DeleteWaitInterval []interface{}
}

func DeployRancherTurtles(ctx context.Context, input DeployRancherTurtlesInput) {
Expect(ctx).NotTo(BeNil(), "ctx is required for DeployRancherTurtles")
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "BootstrapClusterProxy is required for DeployRancherTurtles")
Expand Down Expand Up @@ -250,3 +257,30 @@ func UpgradeRancherTurtles(ctx context.Context, input UpgradeRancherTurtlesInput
Expect(fmt.Errorf("Unable to perform chart upgrade: %w\nOutput: %s, Command: %s", err, out, strings.Join(append(values, additionalValues...), " "))).ToNot(HaveOccurred())
}
}

func UninstallRancherTurtles(ctx context.Context, input UninstallRancherTurtlesInput) {
Expect(ctx).NotTo(BeNil(), "ctx is required for UninstallRancherTurtles")
Expect(input.BootstrapClusterProxy).ToNot(BeNil(), "BootstrapClusterProxy is required for UninstallRancherTurtles")
Expect(input.HelmBinaryPath).ToNot(BeEmpty(), "HelmBinaryPath is required for UninstallRancherTurtles")
Expect(input.DeleteWaitInterval).ToNot(BeNil(), "DeleteWaitInterval is required for UninstallRancherTurtles")

namespace := input.Namespace
if namespace == "" {
namespace = turtlesframework.DefaultRancherTurtlesNamespace
}

By("Removing Turtles chart")
removeChart := &opframework.HelmChart{
BinaryPath: input.HelmBinaryPath,
Name: "rancher-turtles",
Commands: opframework.HelmCommands{opframework.Uninstall},
Kubeconfig: input.BootstrapClusterProxy.GetKubeconfigPath(),
AdditionalFlags: opframework.Flags(
"-n", namespace,
"--cascade", "foreground",
"--wait"),
}

_, err := removeChart.Run(nil)
Expect(err).ToNot(HaveOccurred())
}