Skip to content

Commit

Permalink
Merge pull request #474 from salasberryfin/e2e-cover-uninstall
Browse files Browse the repository at this point in the history
🌱 chore: cover uninstall in e2e tests
  • Loading branch information
alexander-demicev authored May 2, 2024
2 parents 6eb7e3b + 0387e89 commit 79f15fa
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
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())
}

0 comments on commit 79f15fa

Please sign in to comment.