Skip to content

Commit 6be24af

Browse files
committed
OCM-14389 | test: fix ids: 64620,75256,72899
1 parent f97b1a4 commit 6be24af

File tree

4 files changed

+42
-21
lines changed

4 files changed

+42
-21
lines changed

tests/e2e/hcp_external_auth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ var _ = Describe("External auth provider", labels.Feature.ExternalAuthProvider,
148148
"revoked",
149149
userName,
150150
),
151-
time.Minute*4,
152-
time.Second*10,
151+
time.Minute*8,
152+
time.Second*20,
153153
).Should(BeTrue())
154154
}
155155
})

tests/e2e/test_rosacli_cluster_post.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,15 @@ var _ = Describe("Post-Check testing for cluster deletion",
749749
It("to verify the sts cluster is deleted successfully - [id:75256]",
750750
labels.High, labels.Runtime.DestroyPost, labels.FedRAMP,
751751
func() {
752+
clusterID = config.GetClusterID()
753+
By("Skip if the cluster is non-sts")
754+
isHostedCP, err := clusterService.IsHostedCPCluster(clusterID)
755+
Expect(err).To(BeNil())
756+
IsSTS, err := clusterService.IsSTSCluster(clusterID)
757+
Expect(err).To(BeNil())
758+
if !(isHostedCP || IsSTS) {
759+
Skip("Skip this case as it doesn't supports on not-sts clusters")
760+
}
752761
By("Check the operator-roles is deleted")
753762
clusterDetail, err := handler.ParseClusterDetail()
754763
Expect(err).To(BeNil())
@@ -767,7 +776,6 @@ var _ = Describe("Post-Check testing for cluster deletion",
767776
}
768777

769778
By("Check the cluster is deleted")
770-
clusterID = config.GetClusterID()
771779
rosaClient.Runner.UnsetArgs()
772780
clusterListout, err := clusterService.List()
773781
Expect(err).To(BeNil())

tests/e2e/test_rosacli_oidc_config.go

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package e2e
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"os"
6-
"regexp"
77
"strings"
88
"time"
99

@@ -288,31 +288,34 @@ var _ = Describe("Register ummanaged oidc config testing",
288288
continue
289289
}
290290
if strings.Contains(command, "aws s3api create-bucket") {
291+
type S3BucketOutPut struct {
292+
Location string `json:"Location"`
293+
}
294+
var s3cmdOutput S3BucketOutPut
291295
commandArgs = helper.ParseCommandToArgs(command)
292296
// Add '--output json' to the commandArgs
293297
jsonOutputArgs := []string{"--output", "json"}
294298
commandArgs = append(commandArgs, jsonOutputArgs...)
295299

296300
stdout, err := rosaClient.Runner.RunCMD(commandArgs)
297301
Expect(err).To(BeNil())
298-
re := regexp.MustCompile(`"Location":\s*"([^"]+)"`)
299-
matches := re.FindStringSubmatch(stdout.String())
300-
if len(matches) > 1 {
301-
if strings.HasPrefix(matches[1], "http://") || strings.HasPrefix(matches[1], "https://") {
302-
issuerUrl = strings.Replace(matches[1], "http://", "https://", 1)
303-
} else if strings.HasPrefix(matches[1], "/") {
304-
issuerUrl = strings.Replace(matches[1], "/", "https://", 1)
305-
region := ""
306-
for i, arg := range commandArgs {
307-
if arg == "--region" && i+1 < len(commandArgs) {
308-
region = commandArgs[i+1]
309-
break
310-
}
311-
}
312-
Expect(region).ToNot(BeEmpty(), "extracted region from %s is empty which will block next step", commandArgs)
313-
issuerUrl = issuerUrl + ".s3." + region + ".amazonaws.com/"
314-
}
302+
303+
err = json.Unmarshal(stdout.Bytes(), &s3cmdOutput)
304+
Expect(err).To(BeNil())
305+
306+
//Get region from `rosa whoami`
307+
whoamiOutput, err := ocmResourceService.Whoami()
308+
Expect(err).To(BeNil())
309+
rosaClient.Runner.UnsetFormat()
310+
whoamiData := ocmResourceService.ReflectAccountsInfo(whoamiOutput)
311+
awsRegion := whoamiData.AWSDefaultRegion
312+
313+
if awsRegion == "us-east-1" {
314+
issuerUrl = fmt.Sprintf("https:/%s.s3.amazonaws.com", s3cmdOutput.Location)
315+
} else {
316+
issuerUrl = strings.Replace(s3cmdOutput.Location, "http://", "https://", 1)
315317
}
318+
316319
Expect(issuerUrl).ToNot(BeEmpty(),
317320
"extracted issuerUrl from %s is empty which will block coming steps.",
318321
stdout.String(),

tests/utils/helper/oidc.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,25 @@ func ExtractOIDCProviderIDFromARN(arn string) string {
5656
func ExtractCommandsFromOIDCRegister(bf bytes.Buffer) []string {
5757
var commands []string
5858
commands = strings.Split(bf.String(), "\n\n")
59+
// When the rosacli is not the latest version, there will be warning message
60+
// This will remove the warning message from the topest command
61+
if strings.Contains(commands[0], "WARN") && strings.Contains(commands[0], "aws") {
62+
splitCommands := strings.Split(commands[0], "\naws")
63+
commands[0] = fmt.Sprintf("aws %s", splitCommands[1])
64+
}
5965
for k, command := range commands {
6066
if strings.Contains(command, "\naws") {
6167
splitCommands := strings.Split(command, "\naws")
6268
commands[k] = splitCommands[0]
6369
commands = append(commands, fmt.Sprintf("aws %s", splitCommands[1]))
6470
}
6571
}
72+
6673
var newCommands []string
6774
for _, command := range commands {
75+
if strings.Contains(command, "WARN") {
76+
continue
77+
}
6878
command = strings.ReplaceAll(command, "\\", "")
6979
command = strings.ReplaceAll(command, "\n", " ")
7080
spaceRegex := regexp.MustCompile(`\s+`)

0 commit comments

Comments
 (0)