Skip to content

Commit

Permalink
OCM-10331 | ci: fix id:72174,75527
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraj7 committed Aug 12, 2024
1 parent ac85896 commit 2e1aea4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 53 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/test_rosacli_cluster_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ var _ = Describe("Healthy check",
if isAutoscale {
Expect(jsonData.DigString("nodes", "autoscale_compute")).ToNot(BeNil())
} else {
Expect(jsonData.DigString("nodes", "autoscale_compute")).To(BeNil())
Expect(jsonData.DigString("nodes", "autoscale_compute")).To(BeEmpty())
}
})

Expand Down
56 changes: 6 additions & 50 deletions tests/e2e/test_rosacli_machine_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"strconv"
"strings"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand All @@ -26,13 +25,12 @@ var _ = Describe("Create machinepool",
func() {
defer GinkgoRecover()
var (
clusterID string
rosaClient *rosacli.Client
machinePoolService rosacli.MachinePoolService
ocmResourceService rosacli.OCMResourceService
clusterConfig *config.ClusterConfig
profile *ph.Profile
permissionsBoundaryArn string = "arn:aws:iam::aws:policy/AdministratorAccess"
clusterID string
rosaClient *rosacli.Client
machinePoolService rosacli.MachinePoolService
ocmResourceService rosacli.OCMResourceService
clusterConfig *config.ClusterConfig
profile *ph.Profile
)

BeforeEach(func() {
Expand Down Expand Up @@ -243,48 +241,6 @@ var _ = Describe("Create machinepool",
}
})

It("List instance-types with region flag - [id:72174]",
labels.Low, labels.Runtime.OCMResources,
func() {
By("List the available instance-types with the region flag")
typesList := []string{"dl1.24xlarge", "g4ad.16xlarge", "c5.xlarge"}
region := "us-west-2"
accountRolePrefix := fmt.Sprintf("QEAuto-accr72174-%s", time.Now().UTC().Format("20060102"))
_, err := ocmResourceService.CreateAccountRole("--mode", "auto",
"--prefix", accountRolePrefix,
"--permissions-boundary", permissionsBoundaryArn,
"-y")
Expect(err).To(BeNil())
defer ocmResourceService.DeleteAccountRole("--mode", "auto", "--prefix", accountRolePrefix, "-y")

accountRoleList, _, err := ocmResourceService.ListAccountRole()
Expect(err).To(BeNil())
classicInstallerRoleArn := accountRoleList.InstallerRole(accountRolePrefix, false).RoleArn
availableMachineTypes, _, err := ocmResourceService.ListInstanceTypes(
"--region", region, "--role-arn", classicInstallerRoleArn)
Expect(err).To(BeNil())
var availableMachineTypesIDs []string
for _, it := range availableMachineTypes.InstanceTypesList {
availableMachineTypesIDs = append(availableMachineTypesIDs, it.ID)
}
Expect(availableMachineTypesIDs).To(ContainElements(typesList))

By("List the available instance-types with the region flag and hosted-cp flag")
availableMachineTypes, _, err = ocmResourceService.ListInstanceTypes(
"--region", region, "--role-arn", classicInstallerRoleArn, "--hosted-cp")
Expect(err).To(BeNil())
for _, it := range availableMachineTypes.InstanceTypesList {
availableMachineTypesIDs = append(availableMachineTypesIDs, it.ID)
}
Expect(availableMachineTypesIDs).To(ContainElements(typesList))

By("Try to list instance-types with invalid region")
availableMachineTypes, output, err := ocmResourceService.ListInstanceTypes(
"--region", "xxx", "--role-arn", classicInstallerRoleArn)
Expect(err).To(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("ERR: Unsupported region 'xxx', available regions"))
})

It("can create spot machinepool - [id:43251]",
labels.Runtime.Day2,
labels.High,
Expand Down
50 changes: 48 additions & 2 deletions tests/e2e/test_rosacli_region.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package e2e

import (
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand All @@ -14,8 +17,9 @@ var _ = Describe("Region",
defer GinkgoRecover()

var (
rosaClient *rosacli.Client
ocmResourceService rosacli.OCMResourceService
rosaClient *rosacli.Client
ocmResourceService rosacli.OCMResourceService
permissionsBoundaryArn string = "arn:aws:iam::aws:policy/AdministratorAccess"
)

BeforeEach(func() {
Expand Down Expand Up @@ -43,4 +47,46 @@ var _ = Describe("Region",
Expect(r.MultiAZSupported).To(Equal("true"))
}
})

It("List instance-types with region flag - [id:72174]",
labels.Low, labels.Runtime.OCMResources,
func() {
By("List the available instance-types with the region flag")
typesList := []string{"dl1.24xlarge", "g4ad.16xlarge", "c5.xlarge"}
region := "us-west-2"
accountRolePrefix := fmt.Sprintf("QEAuto-accr72174-%s", time.Now().UTC().Format("20060102"))
_, err := ocmResourceService.CreateAccountRole("--mode", "auto",
"--prefix", accountRolePrefix,
"--permissions-boundary", permissionsBoundaryArn,
"-y")
Expect(err).To(BeNil())
defer ocmResourceService.DeleteAccountRole("--mode", "auto", "--prefix", accountRolePrefix, "-y")

accountRoleList, _, err := ocmResourceService.ListAccountRole()
Expect(err).To(BeNil())
classicInstallerRoleArn := accountRoleList.InstallerRole(accountRolePrefix, false).RoleArn
availableMachineTypes, _, err := ocmResourceService.ListInstanceTypes(
"--region", region, "--role-arn", classicInstallerRoleArn)
Expect(err).To(BeNil())
var availableMachineTypesIDs []string
for _, it := range availableMachineTypes.InstanceTypesList {
availableMachineTypesIDs = append(availableMachineTypesIDs, it.ID)
}
Expect(availableMachineTypesIDs).To(ContainElements(typesList))

By("List the available instance-types with the region flag and hosted-cp flag")
availableMachineTypes, _, err = ocmResourceService.ListInstanceTypes(
"--region", region, "--role-arn", classicInstallerRoleArn, "--hosted-cp")
Expect(err).To(BeNil())
for _, it := range availableMachineTypes.InstanceTypesList {
availableMachineTypesIDs = append(availableMachineTypesIDs, it.ID)
}
Expect(availableMachineTypesIDs).To(ContainElements(typesList))

By("Try to list instance-types with invalid region")
availableMachineTypes, output, err := ocmResourceService.ListInstanceTypes(
"--region", "xxx", "--role-arn", classicInstallerRoleArn)
Expect(err).To(HaveOccurred())
Expect(output.String()).Should(ContainSubstring("ERR: Unsupported region 'xxx', available regions"))
})
})

0 comments on commit 2e1aea4

Please sign in to comment.