Skip to content

Commit

Permalink
Perform e2e test for downgrade to provv1 with automigrate enabled
Browse files Browse the repository at this point in the history
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
  • Loading branch information
Danil-Grigorev committed Jun 26, 2024
1 parent 8b28c6b commit 22eb11e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
22 changes: 21 additions & 1 deletion test/e2e/specs/migrate_gitops_provv1_mgmtv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func MigrateToV3UsingGitOpsSpec(ctx context.Context, inputGetter func() MigrateT
Image: fmt.Sprintf("ghcr.io/rancher/turtles-e2e-%s", runtime.GOARCH),
Tag: "v0.0.1",
WaitDeploymentsReadyInterval: input.E2EConfig.GetIntervals(input.BootstrapClusterProxy.GetName(), "wait-controllers"),
SkipCleanup: true,
AdditionalValues: map[string]string{},
}

Expand All @@ -387,6 +388,25 @@ func MigrateToV3UsingGitOpsSpec(ctx context.Context, inputGetter func() MigrateT

By("Rancher should be available using new cluster import")
validateRancherCluster()

By("Running downgrade on provisioningv1 cluster later")
upgradeInput.AdditionalValues["rancherTurtles.features.managementv3-cluster.enabled"] = "false"
upgradeInput.SkipCleanup = false
testenv.UpgradeRancherTurtles(ctx, upgradeInput)

By("Waiting for the new Rancher cluster record to be removed")
Eventually(komega.Get(rancherCluster), deleteClusterWait...).Should(MatchError(ContainSubstring("not found")), "Rancher cluster should be unimported (deleted)")

By("CAPI cluster should NOT have the 'imported' annotation")
Consistently(func() bool {
Eventually(komega.Get(capiCluster), input.E2EConfig.GetIntervals(input.BootstrapClusterProxy.GetName(), "wait-rancher")...).Should(Succeed())
annotations := capiCluster.GetAnnotations()
_, found := annotations["imported"]
return !found
}, 5*time.Second).Should(BeTrue(), "'imported' annotation is NOT expected on CAPI cluster")

By("Rancher should be available using old cluster import")
validateLegacyRancherCluster()
})

AfterEach(func() {
Expand All @@ -408,7 +428,7 @@ func MigrateToV3UsingGitOpsSpec(ctx context.Context, inputGetter func() MigrateT
})

By("Waiting for the rancher cluster record to be removed")
Eventually(komega.Get(rancherCluster), deleteClusterWait...).Should(MatchError(ContainSubstring("not found")), "Rancher cluster should be deleted")
Eventually(komega.Get(rancherLegacyCluster), deleteClusterWait...).Should(MatchError(ContainSubstring("not found")), "Rancher cluster should be deleted")

e2e.DumpSpecResourcesAndCleanup(ctx, specName, input.BootstrapClusterProxy, input.ArtifactFolder, namespace, cancelWatches, capiCluster, input.E2EConfig.GetIntervals, input.SkipCleanup)
})
Expand Down
27 changes: 15 additions & 12 deletions test/testenv/turtles.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ type UpgradeRancherTurtlesInput struct {
AdditionalValues map[string]string
Image string
Tag string
SkipCleanup bool
}

func UpgradeRancherTurtles(ctx context.Context, input UpgradeRancherTurtlesInput) {
Expand All @@ -211,18 +212,20 @@ func UpgradeRancherTurtles(ctx context.Context, input UpgradeRancherTurtlesInput
additionalValues = append(additionalValues, "--set", fmt.Sprintf("%s=%s", name, val))
}

defer func() {
values := []string{"repo", "remove", "rancher-turtles-local"}
cmd := exec.Command(
input.HelmBinaryPath,
values...,
)
cmd.WaitDelay = time.Minute
out, err := cmd.CombinedOutput()
if err != nil {
Expect(fmt.Errorf("Unable to perform chart removal: %w\nOutput: %s, Command: %s", err, out, strings.Join(append(values, additionalValues...), " "))).ToNot(HaveOccurred())
}
}()
if !input.SkipCleanup {
defer func() {
values := []string{"repo", "remove", "rancher-turtles-local"}
cmd := exec.Command(
input.HelmBinaryPath,
values...,
)
cmd.WaitDelay = time.Minute
out, err := cmd.CombinedOutput()
if err != nil {
Expect(fmt.Errorf("Unable to perform chart removal: %w\nOutput: %s, Command: %s", err, out, strings.Join(append(values, additionalValues...), " "))).ToNot(HaveOccurred())
}
}()
}

values := []string{"repo", "update"}
cmd := exec.Command(
Expand Down

0 comments on commit 22eb11e

Please sign in to comment.