Skip to content

Commit 6551a00

Browse files
committed
OCM-13543 | test: fix 77159,77829,52419,54469,75534,64187,73814
1 parent 95d2b50 commit 6551a00

File tree

5 files changed

+86
-107
lines changed

5 files changed

+86
-107
lines changed

tests/e2e/test_rosacli_account_roles.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,14 @@ var _ = Describe("Create account roles", labels.Feature.AccountRoles, func() {
10101010
It("to create/Upgrade account-roles by setting version and channel-group via rosacli - [id:54469]",
10111011
labels.High, labels.Runtime.OCMResources,
10121012
func() {
1013+
var defaultDir string
1014+
By("Get the default dir")
1015+
defaultDir = rosaClient.Runner.GetDir()
1016+
defer func() {
1017+
By("Go back original by setting runner dir")
1018+
rosaClient.Runner.SetDir(defaultDir)
1019+
}()
1020+
10131021
By("Prepare y-1 version for testing")
10141022
versionService := rosaClient.Version
10151023
// get stable channel version
@@ -1293,6 +1301,7 @@ var _ = Describe("Create account roles for hosted-cp shared vpc", labels.Feature
12931301
"--path", path,
12941302
"--route53-role-arn", route53RoleArn,
12951303
"--vpc-endpoint-role-arn", invalidVpcEndpointRoleArn,
1304+
"--hosted-cp",
12961305
"-y")
12971306
Expect(err).NotTo(BeNil())
12981307
Expect(output.String()).To(ContainSubstring("Expected a valid policy ARN for vpc-endpoint-role-arn"))
@@ -1307,7 +1316,7 @@ var _ = Describe("Create account roles for hosted-cp shared vpc", labels.Feature
13071316
"-y")
13081317
Expect(err).NotTo(BeNil())
13091318
Expect(output.String()).To(ContainSubstring(
1310-
"Setting the `route53-role-arn` flag is only supported for hosted clusters"))
1319+
"Setting the `route53-role-arn` flag is only supported for Hosted Control Plane clusters"))
13111320

13121321
By("Validate two share vpc flags are not used together")
13131322
output, err = ocmResourceService.CreateAccountRole("--mode", "auto",

tests/e2e/test_rosacli_cluster.go

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -546,19 +546,11 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
546546
SkipNotHosted()
547547
}
548548

549-
By("Upgrade cluster without --control-plane flag")
550-
output, err := upgradeService.Upgrade("-c", clusterID)
551-
Expect(err).To(HaveOccurred())
552-
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
553-
Expect(textData).
554-
To(ContainSubstring(
555-
"ERR: The '--control-plane' option is currently mandatory for Hosted Control Planes"))
556-
557549
By("Upgrade cluster with invalid cluster id")
558550
invalidClusterID := helper.GenerateRandomString(30)
559-
output, err = upgradeService.Upgrade("-c", invalidClusterID)
551+
output, err := upgradeService.Upgrade("-c", invalidClusterID)
560552
Expect(err).To(HaveOccurred())
561-
textData = rosaClient.Parser.TextData.Input(output).Parse().Tip()
553+
textData := rosaClient.Parser.TextData.Input(output).Parse().Tip()
562554
Expect(textData).
563555
To(ContainSubstring(
564556
"ERR: Failed to get cluster '%s': There is no cluster with identifier or name '%s'",
@@ -568,7 +560,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
568560
By("Upgrade cluster with incorrect format of the date and time")
569561
output, err = upgradeService.Upgrade(
570562
"-c", clusterID,
571-
"--control-plane",
572563
"--mode=auto",
573564
"--schedule-date=\"2024-06\"",
574565
"--schedule-time=\"09:00:12\"",
@@ -580,7 +571,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
580571
By("Upgrade cluster using --schedule, --schedule-date and --schedule-time flags at the same time")
581572
output, err = upgradeService.Upgrade(
582573
"-c", clusterID,
583-
"--control-plane",
584574
"--mode=auto",
585575
"--schedule-date=\"2024-06-24\"",
586576
"--schedule-time=\"09:00\"",
@@ -595,7 +585,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
595585
By("Upgrade cluster using --schedule and --version flags at the same time")
596586
output, err = upgradeService.Upgrade(
597587
"-c", clusterID,
598-
"--control-plane",
599588
"--mode=auto",
600589
"--schedule=\"5 5 * * *\"",
601590
"--version=4.15.10",
@@ -609,7 +598,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
609598
By("Upgrade cluster with value not match the cron epression")
610599
output, err = upgradeService.Upgrade(
611600
"-c", clusterID,
612-
"--control-plane",
613601
"--mode=auto",
614602
"--schedule=\"5 5\"",
615603
"-y")
@@ -622,7 +610,6 @@ var _ = Describe("Edit cluster validation should", labels.Feature.Cluster, func(
622610
By("Upgrade cluster with node_drain_grace_period")
623611
output, err = upgradeService.Upgrade(
624612
"-c", clusterID,
625-
"--control-plane",
626613
"--mode=auto",
627614
"--schedule", "20 20 * * *",
628615
"--node-drain-grace-period", "60",
@@ -3597,6 +3584,10 @@ var _ = Describe("HCP cluster creation supplemental testing",
35973584
customProfile.NamePrefix = constants.DefaultNamePrefix
35983585
clusterHandler, err = handler.NewTempClusterHandler(rosaClient, customProfile)
35993586
Expect(err).To(BeNil())
3587+
3588+
By("Init the cluster id and testing cluster name")
3589+
clusterID = ""
3590+
testingClusterName = ""
36003591
})
36013592

36023593
AfterEach(func() {
@@ -3665,52 +3656,54 @@ var _ = Describe("HCP cluster creation supplemental testing",
36653656
labels.Critical,
36663657
labels.Runtime.Day1Supplemental,
36673658
func() {
3668-
clusterName := helper.GenerateRandomName("ocp-75534", 2)
3659+
testingClusterName = helper.GenerateRandomName("ocp-75534", 2)
36693660
flags, err := clusterHandler.GenerateClusterCreateFlags()
36703661
Expect(err).ToNot(HaveOccurred())
36713662

36723663
command := "rosa create cluster --cluster-name " +
3673-
clusterName + " " + strings.Join(flags, " ") + " " + "--mode auto -y"
3664+
testingClusterName + " " + strings.Join(flags, " ") + " " + "--mode auto -y"
36743665
rosalCommand := config.GenerateCommand(command)
3675-
3666+
fmt.Println("debug command is: ", rosalCommand.GetFullCommand())
36763667
stdout, err := rosaClient.Runner.RunCMD(strings.Split(rosalCommand.GetFullCommand(), " "))
3668+
36773669
Expect(err).To(BeNil())
3678-
Expect(stdout.String()).To(ContainSubstring(fmt.Sprintf("Cluster '%s' has been created", clusterName)))
3670+
Expect(stdout.String()).To(ContainSubstring(fmt.Sprintf("Cluster '%s' has been created", testingClusterName)))
36793671

36803672
By("Check the install logs of the hypershift cluster")
36813673
Eventually(func() (string, error) {
3682-
output, err := clusterService.InstallLog(clusterName)
3674+
output, err := clusterService.InstallLog(testingClusterName)
36833675
return output.String(), err
36843676
}, time.Minute*10, time.Second*30).Should(And(
3685-
ContainSubstring("hostedclusters %s Version", clusterName),
3686-
ContainSubstring("hostedclusters %s Release image is valid", clusterName)))
3677+
ContainSubstring("hostedclusters %s Version", testingClusterName),
3678+
ContainSubstring("hostedclusters %s Release image is valid", testingClusterName)))
36873679

36883680
By("Check the install logs of the hypershift cluster with flag --watch")
3689-
output, err := clusterService.InstallLog(clusterName, "--watch")
3681+
output, err := clusterService.InstallLog(testingClusterName, "--watch")
36903682
Expect(err).ToNot(HaveOccurred())
3691-
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", clusterName))
3692-
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", clusterName))
3693-
Expect(output.String()).Should(ContainSubstring("Cluster '%s' is now ready", clusterName))
3683+
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Version", testingClusterName))
3684+
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Release image is valid", testingClusterName))
3685+
Expect(output.String()).Should(ContainSubstring("Cluster '%s' is now ready", testingClusterName))
36943686

36953687
By("Delete the Hypershift cluster")
3696-
output, err = clusterService.DeleteCluster(clusterName, "-y")
3688+
output, err = clusterService.DeleteCluster(testingClusterName, "-y")
36973689
Expect(err).ToNot(HaveOccurred())
3698-
Expect(output.String()).Should(ContainSubstring("Cluster '%s' will start uninstalling now", clusterName))
3690+
Expect(output.String()).Should(ContainSubstring("Cluster '%s' will start uninstalling now", testingClusterName))
36993691

37003692
By("Check the uninstall logs of the hypershift cluster")
37013693
Eventually(func() (string, error) {
3702-
output, err := clusterService.UnInstallLog(clusterName)
3694+
output, err := clusterService.UnInstallLog(testingClusterName)
37033695
return output.String(), err
37043696
}, time.Minute*20, time.Second*30).
37053697
Should(
3706-
ContainSubstring("hostedclusters %s Reconciliation completed successfully", clusterName))
3698+
ContainSubstring("hostedclusters %s Reconciliation completed successfully", testingClusterName))
37073699

37083700
By("Check the uninstall log of the hosted cluster with flag --watch")
3709-
output, err = clusterService.UnInstallLog(clusterName, "--watch")
3701+
output, err = clusterService.UnInstallLog(testingClusterName, "--watch")
37103702
Expect(err).ToNot(HaveOccurred())
37113703
Expect(output.String()).Should(ContainSubstring("hostedclusters %s Reconciliation completed successfully",
3712-
clusterName))
3713-
Expect(output.String()).Should(ContainSubstring("Cluster '%s' completed uninstallation", clusterName))
3704+
testingClusterName))
3705+
Expect(output.String()).Should(ContainSubstring("Cluster '%s' completed uninstallation", testingClusterName))
3706+
testingClusterName = ""
37143707
})
37153708

37163709
It("Check single AZ hosted cluster can be created - [id:54413]",

tests/e2e/test_rosacli_network_resources.go

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ var _ = Describe("Network Resources",
210210
By("Create template dir for template file missing Region Param")
211211
templateContent := helper.TemplateWithoutRegionParam()
212212
templatePath_1, err := helper.CreateTemplateDirForNetworkResources("without-region", templateContent)
213+
214+
templateDir := filepath.Dir(templatePath_1)
215+
tdpWithoutReion := filepath.Dir(templateDir)
216+
tdnWithoutReion := filepath.Base(templateDir)
217+
Expect(err).ToNot(HaveOccurred())
213218
defer func() {
214219
os.Remove(templatePath_1)
215220
Eventually(func() (bool, error) {
@@ -243,6 +248,9 @@ var _ = Describe("Network Resources",
243248
By("Create template dir for template file missing Name Param")
244249
templateContent = helper.TemplateWithoutNameParam()
245250
templatePath_2, err := helper.CreateTemplateDirForNetworkResources("without-name", templateContent)
251+
templateDir = filepath.Dir(templatePath_2)
252+
tdpWithoutName := filepath.Dir(templateDir)
253+
tdnWithoutName := filepath.Base(templateDir)
246254
defer func() {
247255
os.Remove(templatePath_2)
248256
Eventually(func() (bool, error) {
@@ -276,6 +284,9 @@ var _ = Describe("Network Resources",
276284
By("Create template dir for template file missing VpcCidr value")
277285
templateContent = helper.TemplateWithoutCidrValueForVPC()
278286
templatePath_3, err := helper.CreateTemplateDirForNetworkResources("without-vpccidr", templateContent)
287+
templateDir = filepath.Dir(templatePath_3)
288+
tdpWithoutVPCCIDR := filepath.Dir(templateDir)
289+
tdnWithoutVPCCIDR := filepath.Base(templateDir)
279290
defer func() {
280291
os.Remove(templatePath_3)
281292
Eventually(func() (bool, error) {
@@ -309,6 +320,9 @@ var _ = Describe("Network Resources",
309320
By("Create template dir for template file creating single vpc")
310321
templateContent = helper.TemplateForSingleVPC()
311322
templatePath_4, err := helper.CreateTemplateDirForNetworkResources("single-vpc", templateContent)
323+
templateDir = filepath.Dir(templatePath_4)
324+
tdpSingleVPC := filepath.Dir(templateDir)
325+
tdnSingleVPC := filepath.Base(templateDir)
312326
defer func() {
313327
os.Remove(templatePath_4)
314328
Eventually(func() (bool, error) {
@@ -340,18 +354,10 @@ var _ = Describe("Network Resources",
340354
Expect(err).ToNot(HaveOccurred())
341355

342356
By("Get current working directory as template dir path")
343-
templateDirPath, err := helper.GetCurrentWorkingDir()
344-
Expect(err).ToNot(HaveOccurred())
345-
346357
invalidTemplateDir := "/ss"
347358
nonExistentTemplate := "non-existent"
348-
invalidTemplateDirErrorMessage := fmt.Sprintf(
349-
"ERR: failed to read template file: open %s/ss/cloudformation.yaml: no such file or directory",
350-
invalidTemplateDir)
351-
nonExistentTemplateErrorMessage := fmt.Sprintf(
352-
"ERR: failed to read template file: open "+
353-
"cmd/create/network/templates/%s/cloudformation.yaml: no such file or directory",
354-
nonExistentTemplate)
359+
invalidTemplateDirErrorMessage := "ERR: failed to read template file"
360+
nonExistentTemplateErrorMessage := "ERR: failed to read template file"
355361
rollBackInProgress := "ROLLBACK_IN_PROGRESS"
356362
rollBackRequested := "Rollback requested by user"
357363
withoutCidrErrorMessage := "Either CIDR Block or IPv4 IPAM Pool and IPv4 Netmask Length must be provided"
@@ -369,22 +375,25 @@ var _ = Describe("Network Resources",
369375
"Error: unknown flag: --invalid": {"--invalid"},
370376
"ERR: duplicate tag key Key1": {"--param=Tags=Key1=Value1,Key1=Value2",
371377
"--param=Name=duplicate-key"},
372-
nonExistentTemplateErrorMessage: {nonExistentTemplate},
373-
"Parameters: [Region] do not exist in the template": {"without-region",
374-
"--template-dir", templateDirPath, "--param=Name=without-region"},
375-
"Parameters: [Name] do not exist in the template": {"without-name",
376-
"--template-dir", templateDirPath, "--param=Name=without-name"},
377-
withoutCidrErrorMessage: {"without-vpccidr",
378-
"--template-dir", templateDirPath, "--param=Name=withoutcidr", "--param=Region=us-west-2"},
378+
nonExistentTemplateErrorMessage: {nonExistentTemplate,
379+
"--template-dir", invalidTemplateDir, "--param=Name=invalid-dir"},
380+
"Parameters: [Region] do not exist in the template": {tdnWithoutReion,
381+
"--template-dir", tdpWithoutReion, fmt.Sprintf("--param=Name=%s", tdnWithoutReion)},
382+
"Parameters: [Name] do not exist in the template": {tdnWithoutName,
383+
"--template-dir", tdpWithoutName, fmt.Sprintf("--param=Name=%s", tdnWithoutName)},
384+
withoutCidrErrorMessage: {tdnWithoutVPCCIDR,
385+
"--template-dir", tdpWithoutVPCCIDR, fmt.Sprintf(
386+
"--param=Name=%s", tdnWithoutVPCCIDR), "--param=Region=us-west-2",
387+
},
379388
"Parameter 'AvailabilityZoneCount' must be a number not greater than 3": {
380389
"--param=AvailabilityZoneCount=10", "--param=Name=invalid-az"},
381390
"Parameter 'AvailabilityZoneCount' must be a number not less than 1": {
382391
"--param=AvailabilityZoneCount=0", "--param=Name=invalid-az"},
383392
"request send failed, Post \"https://cloudformation.ind-west-2.amazonaws.com/\"": {
384393
"--param=Region=ind-west-2", "--param=Name=invalid-region"},
385394
incorrectStackNameErrorMessage: {"--param=Name=$#aaraj"},
386-
incorrectCidrErrorMessage: {"single-vpc",
387-
"--template-dir", templateDirPath,
395+
incorrectCidrErrorMessage: {tdnSingleVPC,
396+
"--template-dir", tdpSingleVPC,
388397
"--param=VpcCidr=10.0.", "--param=Name=incorrectcidr", "--param=Region=us-west-2"},
389398
}
390399

0 commit comments

Comments
 (0)