Skip to content

Commit

Permalink
OCM-9602 | test: fix id: 73731 for HCP cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwang-RH committed Jul 15, 2024
1 parent 89a3643 commit dbebe33
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions tests/e2e/test_rosacli_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ var _ = Describe("Cluster Upgrade testing",
arbitraryPoliciesToClean []string
awsClient *aws_client.AWSClient
profile *profilehandler.Profile
clusterConfig *config.ClusterConfig
err error
)

BeforeEach(func() {
Expand All @@ -39,6 +41,9 @@ var _ = Describe("Cluster Upgrade testing",
arbitraryPolicyService = rosaClient.Policy
clusterService = rosaClient.Cluster

clusterConfig, err = config.ParseClusterProfile()
Expect(err).ToNot(HaveOccurred())

By("Load the profile")
profile = profilehandler.LoadProfileYamlFileByENV()
})
Expand All @@ -58,7 +63,6 @@ var _ = Describe("Cluster Upgrade testing",
})

It("to upgrade roles/operator-roles and cluster - [id:73731]", labels.Critical, labels.Runtime.Upgrade, func() {

By("Check the cluster version and compare with the profile to decide if skip this case")
jsonData, err := clusterService.GetJSONClusterDescription(clusterID)
Expect(err).To(BeNil())
Expand All @@ -67,6 +71,7 @@ var _ = Describe("Cluster Upgrade testing",
if profile.Version != "y-1" {
Skip("Skip this case as the version defined in profile is not y-1 for upgrading testing")
}

By("Prepare arbitrary policies for testing")
awsClient, err = aws_client.CreateAWSClient("", "")
Expect(err).To(BeNil())
Expand Down Expand Up @@ -207,34 +212,35 @@ var _ = Describe("Cluster Upgrade testing",
Expect(err).To(BeNil())
Expect(len(policy.Tags)).To(Equal(0))
}
if !clusterConfig.Hypershift {
By("Update the all operator policies tags to low version")
tagName := "rosa_openshift_version"
clusterMajorVersion := common.SplitMajorVersion(clusterVersion)
keysToUntag := []string{tagName}

By("Update the all operator policies tags to low version")
tagName := "rosa_openshift_version"
clusterMajorVersion := common.SplitMajorVersion(clusterVersion)
keysToUntag := []string{tagName}

for _, operatorRoleArn := range operatorRolePolicies {
err = awsClient.UntagPolicy(operatorRoleArn, keysToUntag)
Expect(err).To(BeNil())
}
tags := map[string]string{tagName: clusterMajorVersion}
for _, operatorRoleArn := range operatorRolePolicies {
err = awsClient.TagPolicy(operatorRoleArn, tags)
for _, operatorRoleArn := range operatorRolePolicies {
err = awsClient.UntagPolicy(operatorRoleArn, keysToUntag)
Expect(err).To(BeNil())
}
tags := map[string]string{tagName: clusterMajorVersion}
for _, operatorRoleArn := range operatorRolePolicies {
err = awsClient.TagPolicy(operatorRoleArn, tags)
Expect(err).To(BeNil())
}
By("Upgrade operator-roles in auto mode")
_, err = ocmResourceService.UpgradeOperatorRoles(
"-c", clusterID,
"--mode", "auto",
"-y",
)
Expect(err).To(BeNil())
}
By("Upgrade operator-roles in auto mode")
_, err = ocmResourceService.UpgradeOperatorRoles(
"-c", clusterID,
"--mode", "auto",
"-y",
)
Expect(err).To(BeNil())

By("Check th arbitrary policies has no change")
for _, policyArn := range arbitraryPoliciesToClean {
policy, err := awsClient.GetIAMPolicy(policyArn)
Expect(err).To(BeNil())
Expect(len(policy.Tags)).To(Equal(0))
By("Check th arbitrary policies has no change")
for _, policyArn := range arbitraryPoliciesToClean {
policy, err := awsClient.GetIAMPolicy(policyArn)
Expect(err).To(BeNil())
Expect(len(policy.Tags)).To(Equal(0))
}
}
By("Update cluster")
// TODO: Wait the upgrade ready. As upgrade profile can only be used for upgrade cluster one time,
Expand Down

0 comments on commit dbebe33

Please sign in to comment.