Skip to content

Commit

Permalink
OCM-10543 | test: fix ids: 75210,73731,57408,38770,74661,60688 some f…
Browse files Browse the repository at this point in the history
…ailures of rosacli ci
  • Loading branch information
yuwang-RH committed Aug 22, 2024
1 parent a5bc231 commit fc78872
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 32 deletions.
21 changes: 21 additions & 0 deletions tests/e2e/test_rosacli_account_roles.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package e2e

import (
"context"
"fmt"
"os"
"strings"
"time"

"k8s.io/apimachinery/pkg/util/wait"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -545,6 +549,23 @@ var _ = Describe("Edit account roles", labels.Feature.AccountRoles, func() {
Expect(err).To(BeNil())
policiesArn = append(policiesArn, pArn)
}
err = wait.PollUntilContextTimeout(
context.Background(),
20*time.Second,
200*time.Second,
false,
func(context.Context) (bool, error) {
hasPoliciWaitSync := false
for _, arn := range policiesArn {
policy, err := awsClient.GetIAMPolicy(arn)
if err != nil || policy == nil {
hasPoliciWaitSync = true
break
}
}
return !hasPoliciWaitSync, err
})
common.AssertWaitPollNoErr(err, "Network verification result are not ready after 200")

By("Prepare verson for testing")
versionService := rosaClient.Version
Expand Down
60 changes: 34 additions & 26 deletions tests/e2e/test_rosacli_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,36 +584,39 @@ var _ = Describe("Classic cluster creation validation",
Expect(stdout.String()).To(ContainSubstring(v))
}
if rosalCommand.CheckFlagExist("--multi-az") {
invalidReplicasErrorMapMultiAZ := map[string]string{
"2": "Multi AZ cluster requires at least 3 compute nodes",
"0": "Multi AZ cluster requires at least 3 compute nodes",
"-3": "must be non-negative",
"5": "Multi AZ clusters require that the number of compute nodes be a multiple of 3",
}
for k, v := range invalidReplicasErrorMapMultiAZ {
rosalCommand.ReplaceFlagValue(map[string]string{
"--replicas": k,
})
stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).NotTo(BeNil())
Expect(stdout.String()).To(ContainSubstring(v))
if !profile.ClusterConfig.AutoscalerEnabled {
invalidReplicasErrorMapMultiAZ := map[string]string{
"2": "Multi AZ cluster requires at least 3 compute nodes",
"0": "Multi AZ cluster requires at least 3 compute nodes",
"-3": "must be non-negative",
"5": "Multi AZ clusters require that the number of compute nodes be a multiple of 3",
}
for k, v := range invalidReplicasErrorMapMultiAZ {
rosalCommand.ReplaceFlagValue(map[string]string{
"--replicas": k,
})
stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).NotTo(BeNil())
Expect(stdout.String()).To(ContainSubstring(v))
}
}
} else {
invalidReplicasErrorMapSingeAZ := map[string]string{
"1": "requires at least 2 compute nodes",
"0": "requires at least 2 compute nodes",
"-1": "must be non-negative",
}
for k, v := range invalidReplicasErrorMapSingeAZ {
rosalCommand.ReplaceFlagValue(map[string]string{
"--replicas": k,
})
stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).NotTo(BeNil())
Expect(stdout.String()).To(ContainSubstring(v))
if !profile.ClusterConfig.AutoscalerEnabled {
invalidReplicasErrorMapSingeAZ := map[string]string{
"1": "requires at least 2 compute nodes",
"0": "requires at least 2 compute nodes",
"-1": "must be non-negative",
}
for k, v := range invalidReplicasErrorMapSingeAZ {
rosalCommand.ReplaceFlagValue(map[string]string{
"--replicas": k,
})
stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
Expect(err).NotTo(BeNil())
Expect(stdout.String()).To(ContainSubstring(v))
}
}
}

By("Check the validation for region")
invalidRegion := "not-exist-region"
rosalCommand.ReplaceFlagValue(map[string]string{
Expand Down Expand Up @@ -2151,6 +2154,11 @@ var _ = Describe("Reusing opeartor prefix and oidc config to create clsuter", la
if profile.ClusterConfig.OIDCConfig == "" {
Skip("Skip this case as it is only for byo oidc cluster")
}

By("Skip if the cluster is shared vpc cluster")
if profile.ClusterConfig.SharedVPC {
Skip("Skip this case as it is not supported for byo oidc cluster")
}
By("Prepare creation command")
var originalOidcConfigID string
var rosalCommand config.Command
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_rosacli_operator_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ var _ = Describe("create operator-roles forcely testing",
By("Detach and Delete one operator-role policy,openshift-cluster-csi-drivers-ebs")
var deletingPolicyRoleName string
for roleName := range rolePolicyMap {
if strings.Contains(roleName, "openshift-cluster-csi-drivers-ebs") {
if strings.Contains(roleName, "openshift-cluster-csi-driver") {
deletingPolicyRoleName = roleName
break
}
Expand Down
14 changes: 13 additions & 1 deletion tests/e2e/test_rosacli_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ var _ = Describe("Cluster Upgrade testing",
})

It("to upgrade roles/operator-roles and cluster - [id:73731]", labels.Critical, labels.Runtime.Upgrade, func() {
By("Skip if the cluster is non-sts")
isHostedCP, err := clusterService.IsHostedCPCluster(clusterID)
Expect(err).To(BeNil())
IsSTS, err := clusterService.IsSTSCluster(clusterID)
Expect(err).To(BeNil())
if !(isHostedCP || IsSTS) {
Skip("Skip this case as it doesn't supports on not-sts clusters")
}
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 Down Expand Up @@ -269,9 +277,13 @@ var _ = Describe("Cluster Upgrade testing",
)
}
Expect(err).To(BeNil())
Expect(output.String()).To(ContainSubstring("are already up-to-date"))
Expect(output.String()).To(ContainSubstring("are compatible with upgrade"))
Expect(output.String()).To(ContainSubstring("Upgrade successfully scheduled for cluster"))
if isHosted {
Expect(output.String()).To(ContainSubstring("have attached managed policies. An upgrade isn't needed"))
} else {
Expect(output.String()).To(ContainSubstring("are already up-to-date"))
}
})

It("to upgrade NON-STS rosa cluster across Y stream - [id:37499]", labels.Critical, labels.Runtime.Upgrade, func() {
Expand Down
10 changes: 6 additions & 4 deletions tests/utils/common/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,17 @@ func ParseIssuerURLFromCommand(command string) string {

// Extract oidc provider from the 'OIDC Endpoint URL' field of `rosa describe cluster`
func ExtractOIDCProviderFromOidcUrl(urlString string) (string, error) {
var oidcProvider string
urlString = strings.TrimSpace(strings.Split(urlString, " ")[0])
parsedURL, err := url.Parse(urlString)
if err != nil {
return "", err
}
host := parsedURL.Host
path := strings.TrimPrefix(parsedURL.Path, "/")
fmt.Printf("The past host and path is %s and %s\n", host, path)
oidcProvider := fmt.Sprintf("%s/%s", host, path)
oidcProvider = strings.Split(oidcProvider, " ")[0]

oidcProvider = host
if path != "" {
oidcProvider = fmt.Sprintf("%s/%s", host, path)
}
return oidcProvider, nil
}

0 comments on commit fc78872

Please sign in to comment.