From 5eeab933d955645f0a6be4b301c57bbb9625c1a8 Mon Sep 17 00:00:00 2001 From: Jeff Frazier Date: Thu, 25 Jul 2024 12:51:11 -0400 Subject: [PATCH] OCM-9786 | test: automated cases id:73161,74656 OCM-9786 | test: automated cases id:73161,74656 OCM-9904 | test: automated cases id:73161,74656 OCM-9904 | test: automated cases id:73161,74656 OCM-9904 | test: automated cases id:73161,74656 OCM-9904 | test: automated cases id:73161,74656 --- tests/e2e/test_rosacli_cluster.go | 59 +++++++++++++++++++++ tests/utils/common/constants/cluster.go | 4 +- tests/utils/exec/rosacli/cluster_service.go | 1 + 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/tests/e2e/test_rosacli_cluster.go b/tests/e2e/test_rosacli_cluster.go index 94962a62ee..96c1d8b2fa 100644 --- a/tests/e2e/test_rosacli_cluster.go +++ b/tests/e2e/test_rosacli_cluster.go @@ -420,6 +420,65 @@ var _ = Describe("Edit cluster", Expect(err).To(BeNil()) Expect(CD.Private).To(Equal("Yes")) }) + + // Excluded until bug on OCP-73161 is resolved + It("can verify delete protection on a rosa cluster - [id:73161]", + labels.High, labels.Runtime.Day2, labels.Exclude, + func() { + By("Get original delete protection value") + output, err := clusterService.DescribeClusterAndReflect(clusterID) + Expect(err).ToNot(HaveOccurred()) + originalDeleteProtection := output.EnableDeleteProtection + + By("Enable delete protection on the cluster") + deleteProtection := constants.DeleteProtectionEnabled + _, err = clusterService.EditCluster(clusterID, "--enable-delete-protection=true", "-y") + Expect(err).ToNot(HaveOccurred()) + defer clusterService.EditCluster(clusterID, + fmt.Sprintf("--enable-delete-protection=%s", originalDeleteProtection), "-y") + + By("Check the enable result from cluster description") + output, err = clusterService.DescribeClusterAndReflect(clusterID) + Expect(err).ToNot(HaveOccurred()) + Expect(output.EnableDeleteProtection).To(Equal(deleteProtection)) + + By("Attempt to delete cluster with delete protection enabled") + out, err := clusterService.DeleteCluster(clusterID, "-y") + Expect(err).To(HaveOccurred()) + textData := rosaClient.Parser.TextData.Input(out).Parse().Tip() + Expect(textData).Should(ContainSubstring( + `Delete-protection has been activated on this cluster and + it cannot be deleted until delete-protection is disabled`)) + + By("Disable delete protection on the cluster") + deleteProtection = constants.DeleteProtectionDisabled + _, err = clusterService.EditCluster(clusterID, "--enable-delete-protection=false", "-y") + Expect(err).ToNot(HaveOccurred()) + + By("Check the disable result from cluster description") + output, err = clusterService.DescribeClusterAndReflect(clusterID) + Expect(err).ToNot(HaveOccurred()) + Expect(output.EnableDeleteProtection).To(Equal(deleteProtection)) + }) + + // Excluded until bug on OCP-74656 is resolved + It("can verify delete protection on a rosa cluster negative - [id:74656]", + labels.Medium, labels.Runtime.Day2, labels.Exclude, + func() { + By("Enable delete protection with invalid values") + resp, err := clusterService.EditCluster(clusterID, + "--enable-delete-protection=aaa", + "-y", + ) + Expect(err).To(HaveOccurred()) + textData := rosaClient.Parser.TextData.Input(resp).Parse().Tip() + Expect(textData).Should(ContainSubstring(`Error: invalid argument "aaa" for "--enable-delete-protection"`)) + + resp, err = clusterService.EditCluster(clusterID, "--enable-delete-protection=", "-y") + Expect(err).To(HaveOccurred()) + textData = rosaClient.Parser.TextData.Input(resp).Parse().Tip() + Expect(textData).Should(ContainSubstring(`Error: invalid argument "" for "--enable-delete-protection"`)) + }) }) var _ = Describe("Classic cluster creation validation", diff --git a/tests/utils/common/constants/cluster.go b/tests/utils/common/constants/cluster.go index 1c939e6b53..df074e48c8 100644 --- a/tests/utils/common/constants/cluster.go +++ b/tests/utils/common/constants/cluster.go @@ -23,7 +23,9 @@ const ( // cluster configuration const ( - DefaultVPCCIDRValue = "10.0.0.0/16" + DefaultVPCCIDRValue = "10.0.0.0/16" + DeleteProtectionEnabled = "Enabled" + DeleteProtectionDisabled = "Disabled" ) // cluster status diff --git a/tests/utils/exec/rosacli/cluster_service.go b/tests/utils/exec/rosacli/cluster_service.go index 6f65711d2c..cd8a8cd5e1 100644 --- a/tests/utils/exec/rosacli/cluster_service.go +++ b/tests/utils/exec/rosacli/cluster_service.go @@ -125,6 +125,7 @@ type ClusterDescription struct { AuditLogRoleARN string `yaml:"Audit Log Role ARN,omitempty"` FailedInflightChecks string `yaml:"Failed Inflight Checks,omitempty"` ExternalAuthentication string `yaml:"External Authentication,omitempty"` + EnableDeleteProtection string `yaml:"Delete Protection,omitempty"` } // Pasrse the result of 'rosa list cluster' to the ClusterList struct