Skip to content

Commit

Permalink
OCM-11609 | test: updated id:68971,68172
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraj7 committed Oct 8, 2024
1 parent 28734e8 commit 5e93792
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 46 deletions.
1 change: 1 addition & 0 deletions tests/ci/data/profiles/rosa-hcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ profiles:
volume_size: 75
disable_uwm: true
autoscaler_enabled: false
additional_sg_number: 3
account-role:
customized_prefix: true
path: ""
Expand Down
6 changes: 5 additions & 1 deletion tests/e2e/test_rosacli_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,10 @@ var _ = Describe("Classic cluster creation validation",
"--additional-control-plane-security-group-ids": "invalid",
"--additional-compute-security-group-ids": "invalid",
}
invalidHCPSecurityGroups = map[string]string{
"--additional-infra-security-group-ids": "sg-aisgi",
"--additional-control-plane-security-group-ids": "sg-acpsgi",
}
)

By("Prepare a vpc for the testing")
Expand Down Expand Up @@ -1388,7 +1392,7 @@ var _ = Describe("Classic cluster creation validation",
}

By("Try creating HCP cluster with additional security groups flag")
for additionalSecurityGroupFlag := range securityGroups {
for additionalSecurityGroupFlag := range invalidHCPSecurityGroups {
By("Create account-roles of hosted-cp")
_, err := ocmResourceService.CreateAccountRole("--mode", "auto",
"--prefix", "akanni",
Expand Down
96 changes: 61 additions & 35 deletions tests/e2e/test_rosacli_cluster_post.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,47 +164,73 @@ var _ = Describe("Healthy check",
Expect(output.String()).Should(ContainSubstring("--additional-infra-security-group-ids"))
Expect(output.String()).Should(ContainSubstring("--additional-control-plane-security-group-ids"))

By("Describe the cluster to check the control plane and infra additional security groups")
des, err := clusterService.DescribeClusterAndReflect(clusterID)
Expect(err).ToNot(HaveOccurred())
var additionalMap []interface{}
for _, item := range des.Nodes {
if value, ok := item["Additional Security Group IDs"]; ok {
additionalMap = value.([]interface{})
if isHosted {
By("Describe the cluster to check the additional compute security groups")
rosaClient.Runner.JsonFormat()
output, err := clusterService.DescribeCluster(clusterID)
Expect(err).ToNot(HaveOccurred())
jsonData := rosaClient.Parser.JsonData.Input(output).Parse()
computeSgIDs := jsonData.DigString("aws", "additional_compute_security_group_ids")
computeSgIDs = computeSgIDs[1 : len(computeSgIDs)-1]
Expect(strings.ReplaceAll(computeSgIDs, " ", ",")).To(
Equal(clusterConfig.AdditionalSecurityGroups.WorkerSecurityGroups))

By("Describe the workers nodepool and check the compute security groups")
npList, err := machinePoolService.ListAndReflectNodePools(clusterID)
Expect(err).ToNot(HaveOccurred())
for _, np := range npList.NodePools {
Expect(np.ID).ToNot(BeNil())
if strings.HasPrefix(np.ID, constants.DefaultHostedWorkerPool) {
npDesc, err := machinePoolService.DescribeAndReflectNodePool(clusterID, np.ID)
Expect(err).ToNot(HaveOccurred())
Expect(npDesc.AdditionalSecurityGroupIDs).To(
Equal(helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.WorkerSecurityGroups)))
}
}
}
if clusterConfig.AdditionalSecurityGroups == nil {
Expect(additionalMap).To(BeNil())
} else {
Expect(additionalMap).ToNot(BeNil())
for _, addSgGroups := range additionalMap {
if value, ok := addSgGroups.(map[string]interface{})["Control Plane"]; ok {
Expect(value).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.ControlPlaneSecurityGroups)))
} else {
value = addSgGroups.(map[string]interface{})["Infra"]
Expect(value).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.InfraSecurityGroups)))

By("Describe the cluster to check the control plane and infra additional security groups")
des, err := clusterService.DescribeClusterAndReflect(clusterID)
Expect(err).ToNot(HaveOccurred())
var additionalMap []interface{}
for _, item := range des.Nodes {
if value, ok := item["Additional Security Group IDs"]; ok {
additionalMap = value.([]interface{})
}
}
if clusterConfig.AdditionalSecurityGroups == nil {
Expect(additionalMap).To(BeNil())
} else {
Expect(additionalMap).ToNot(BeNil())
for _, addSgGroups := range additionalMap {
if value, ok := addSgGroups.(map[string]interface{})["Control Plane"]; ok {
Expect(value).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.ControlPlaneSecurityGroups)))
} else {
value = addSgGroups.(map[string]interface{})["Infra"]
Expect(value).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.InfraSecurityGroups)))
}
}
}
}

By("Describe the worker pool and check the compute security groups")
mp, err := machinePoolService.DescribeAndReflectMachinePool(clusterID, constants.DefaultClassicWorkerPool)
Expect(err).ToNot(HaveOccurred())
if clusterConfig.AdditionalSecurityGroups == nil {
Expect(mp.SecurityGroupIDs).To(BeEmpty())
} else {
Expect(mp.SecurityGroupIDs).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.WorkerSecurityGroups)))
By("Describe the worker pool and check the compute security groups")
mp, err := machinePoolService.DescribeAndReflectMachinePool(clusterID, constants.DefaultClassicWorkerPool)
Expect(err).ToNot(HaveOccurred())
if clusterConfig.AdditionalSecurityGroups == nil {
Expect(mp.SecurityGroupIDs).To(BeEmpty())
} else {
Expect(mp.SecurityGroupIDs).
To(Equal(
helper.ReplaceCommaWithCommaSpace(
clusterConfig.AdditionalSecurityGroups.WorkerSecurityGroups)))
}
}

})

It("bring your own kms key functionality works on cluster creation - [id:60082]",
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/exec/rosacli/cluster_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (c *clusterService) ReflectClusterDescription(result bytes.Buffer) (res *Cl
}

func (c *clusterService) List() (bytes.Buffer, error) {
list := c.client.Runner.Cmd("list", "cluster")
list := c.client.Runner.Cmd("list", "cluster").CmdFlags()
return list.Run()
}

Expand Down
27 changes: 18 additions & 9 deletions tests/utils/profilehandler/profile_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,15 +491,24 @@ func GenerateClusterCreateFlags(profile *Profile, client *rosacli.Client) ([]str
computeSGs := strings.Join(securityGroups, ",")
infraSGs := strings.Join(securityGroups, ",")
controlPlaneSGs := strings.Join(securityGroups, ",")
flags = append(flags,
"--additional-infra-security-group-ids", infraSGs,
"--additional-control-plane-security-group-ids", controlPlaneSGs,
"--additional-compute-security-group-ids", computeSGs,
)
clusterConfiguration.AdditionalSecurityGroups = &ClusterConfigure.AdditionalSecurityGroups{
ControlPlaneSecurityGroups: controlPlaneSGs,
InfraSecurityGroups: infraSGs,
WorkerSecurityGroups: computeSGs,
if profile.ClusterConfig.HCP {
flags = append(flags,
"--additional-compute-security-group-ids", computeSGs,
)
clusterConfiguration.AdditionalSecurityGroups = &ClusterConfigure.AdditionalSecurityGroups{
WorkerSecurityGroups: computeSGs,
}
} else {
flags = append(flags,
"--additional-infra-security-group-ids", infraSGs,
"--additional-control-plane-security-group-ids", controlPlaneSGs,
"--additional-compute-security-group-ids", computeSGs,
)
clusterConfiguration.AdditionalSecurityGroups = &ClusterConfigure.AdditionalSecurityGroups{
ControlPlaneSecurityGroups: controlPlaneSGs,
InfraSecurityGroups: infraSGs,
WorkerSecurityGroups: computeSGs,
}
}
}
if profile.ClusterConfig.ProxyEnabled {
Expand Down

0 comments on commit 5e93792

Please sign in to comment.