From deac3c0c1533bf794d6916b89c980d0f1d8958c8 Mon Sep 17 00:00:00 2001 From: yuwan Date: Mon, 5 Aug 2024 15:24:07 +0800 Subject: [PATCH] OCM-10143 | test: fix ids:60688,59530,74761 --- tests/e2e/test_rosacli_cluster.go | 27 +++++++++++++++++------- tests/e2e/test_rosacli_cluster_post.go | 5 +++++ tests/e2e/test_rosacli_operator_roles.go | 8 +++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/tests/e2e/test_rosacli_cluster.go b/tests/e2e/test_rosacli_cluster.go index d69ad63371..08dd07f3e7 100644 --- a/tests/e2e/test_rosacli_cluster.go +++ b/tests/e2e/test_rosacli_cluster.go @@ -1853,13 +1853,17 @@ var _ = Describe("Reusing opeartor prefix and oidc config to create clsuter", la }) AfterEach(func() { - By("Recover the operator role policy version") - keysToUntag := []string{versionTagName} - err = awsClient.UntagPolicy(operatorPolicyArn, keysToUntag) - Expect(err).To(BeNil()) - tags := map[string]string{versionTagName: originalMajorMinorVerson} - err = awsClient.TagPolicy(operatorPolicyArn, tags) - Expect(err).To(BeNil()) + hostedCluster, err := clusterService.IsHostedCPCluster(clusterID) + Expect(err).ToNot(HaveOccurred()) + if !hostedCluster { + By("Recover the operator role policy version") + keysToUntag := []string{versionTagName} + err = awsClient.UntagPolicy(operatorPolicyArn, keysToUntag) + Expect(err).To(BeNil()) + tags := map[string]string{versionTagName: originalMajorMinorVerson} + err = awsClient.TagPolicy(operatorPolicyArn, tags) + Expect(err).To(BeNil()) + } By("Delete resources for testing") output, err := ocmResourceService.DeleteOIDCConfig( @@ -1895,6 +1899,11 @@ var _ = Describe("Reusing opeartor prefix and oidc config to create clsuter", la rosalCommand.ReplaceFlagValue(map[string]string{ "-c": testClusterName, }) + if profile.ClusterConfig.DomainPrefixEnabled { + rosalCommand.ReplaceFlagValue(map[string]string{ + "--domain-prefix": "dp60688", + }) + } By("Reuse the oidc config and operator-roles") stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " ")) @@ -1923,7 +1932,9 @@ var _ = Describe("Reusing opeartor prefix and oidc config to create clsuter", la Expect(err).To(BeNil()) operatorRolesArns := clusterDetail.OperatorIAMRoles - clusterVersion := clusterDetail.OpenshiftVersion + versionOutput, err := clusterService.GetClusterVersion(clusterID) + Expect(err).To(BeNil()) + clusterVersion := versionOutput.RawID major, minor, _, err := common.ParseVersion(clusterVersion) Expect(err).To(BeNil()) originalMajorMinorVerson = fmt.Sprintf("%d.%d", major, minor) diff --git a/tests/e2e/test_rosacli_cluster_post.go b/tests/e2e/test_rosacli_cluster_post.go index 625da5d34a..e1d3310a22 100644 --- a/tests/e2e/test_rosacli_cluster_post.go +++ b/tests/e2e/test_rosacli_cluster_post.go @@ -584,6 +584,11 @@ var _ = Describe("Post-Check testing for cluster creation", profile := profilehandler.LoadProfileYamlFileByENV() Expect(err).ToNot(HaveOccurred()) + By("Check if it is using oidc config") + if profile.ClusterConfig.OIDCConfig == "" { + Skip("Skip this case as it is only for byo oidc cluster") + } + By("Retrieve oidc config from cluster config") clusterID = config.GetClusterID() oidcConfigC = clusterConfig.Aws.Sts.OidcConfigID diff --git a/tests/e2e/test_rosacli_operator_roles.go b/tests/e2e/test_rosacli_operator_roles.go index 7e647371d4..5e067d5f80 100644 --- a/tests/e2e/test_rosacli_operator_roles.go +++ b/tests/e2e/test_rosacli_operator_roles.go @@ -30,6 +30,8 @@ var _ = Describe("Edit operator roles", labels.Feature.OperatorRoles, func() { rosaClient *rosacli.Client ocmResourceService rosacli.OCMResourceService permissionsBoundaryArn string = "arn:aws:iam::aws:policy/AdministratorAccess" + clusterConfig *config.ClusterConfig + err error ) BeforeEach(func() { By("Init the client") @@ -50,6 +52,10 @@ var _ = Describe("Edit operator roles", labels.Feature.OperatorRoles, func() { By("Get the default dir") defaultDir = rosaClient.Runner.GetDir() + + By("Get cluster config") + clusterConfig, err = config.ParseClusterProfile() + Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { @@ -105,6 +111,7 @@ var _ = Describe("Edit operator roles", labels.Feature.OperatorRoles, func() { output, err = ocmResourceService.DeleteOIDCConfig( "--oidc-config-id", oidcConfigID, "--mode", "auto", + "--region", clusterConfig.Region, "-y", ) Expect(err).To(HaveOccurred()) @@ -114,6 +121,7 @@ var _ = Describe("Edit operator roles", labels.Feature.OperatorRoles, func() { output, err = ocmResourceService.DeleteOIDCConfig( "--oidc-config-id", oidcConfigID, "--mode", "manual", + "--region", clusterConfig.Region, "-y", ) Expect(err).To(HaveOccurred())