Skip to content

Commit

Permalink
OCM-9786 | test: automated cases id:73161,74656
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jfrazierRH committed Jul 30, 2024
1 parent 22f38bd commit 5eeab93
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
59 changes: 59 additions & 0 deletions tests/e2e/test_rosacli_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion tests/utils/common/constants/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/utils/exec/rosacli/cluster_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eeab93

Please sign in to comment.