Skip to content

Commit 18b4511

Browse files
OCM-8327 | ci: automated test cases 73942,63139,63147
update comment
1 parent 4b1a13a commit 18b4511

File tree

11 files changed

+147
-16
lines changed

11 files changed

+147
-16
lines changed

tests/ci/connection.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ var (
4141
)
4242

4343
func createConnectionWithToken(token string) *client.Connection {
44-
4544
// Create the connection:
4645
connection, err := client.NewConnectionBuilder().
4746
Logger(logger).

tests/ci/profile_handler.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ func GenerateClusterCreationArgsByProfile(token string, profile *Profile) (clust
345345
}
346346

347347
if profile.Autoscale {
348-
clusterArgs.Autoscale = profile.Autoscale
348+
clusterArgs.Autoscaling = &exec.Autoscaling{
349+
AutoscalingEnabled: true,
350+
MinReplicas: 3,
351+
MaxReplicas: 6,
352+
}
349353
}
350354

351355
if profile.ComputeMachineType != "" {

tests/e2e/classic_machine_pool_test.go

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,40 @@ var _ = Describe("Create MachinePool", ci.Day2, ci.NonHCPCluster, ci.FeatureMach
606606
Expect(mpResponseBody.InstanceType()).To(Equal("m5.2xlarge"))
607607
})
608608

609+
It("can create machinepool with customized tags - [id:73942]", ci.High, ci.NonHCPCluster, func() {
610+
611+
By("Create a machinepool with variable aws_tags")
612+
name := "mp-73942"
613+
replicas := 0
614+
machineType := "r5.xlarge"
615+
616+
validTags := map[string]string{
617+
"tagsKey": "tagValue",
618+
}
619+
MachinePoolArgs := &exe.MachinePoolArgs{
620+
Cluster: &clusterID,
621+
Replicas: &replicas,
622+
MachineType: &machineType,
623+
Name: &name,
624+
Tags: &validTags,
625+
}
626+
_, err := mpService.Apply(MachinePoolArgs, false)
627+
Expect(err).ToNot(HaveOccurred())
628+
629+
By("Check the machinepool detail state")
630+
resp, err := cms.RetrieveClusterMachinePool(ci.RHCSConnection, clusterID, name)
631+
Expect(err).ToNot(HaveOccurred())
632+
for tagKey, tagValue := range validTags {
633+
Expect(tagValue).To(BeElementOf(resp.AWS().Tags()[tagKey]))
634+
}
635+
636+
By("Update the machinepool tags is not allowed")
637+
validTags["tagKey2"] = "tagValue2"
638+
_, err = mpService.Apply(MachinePoolArgs, false)
639+
Expect(err).To(HaveOccurred())
640+
Expect(err.Error()).Should(ContainSubstring("Attribute aws_tags, cannot be changed from"))
641+
})
642+
609643
It("can reconciliate with basic flow - [id:65645]", ci.Medium, func() {
610644
By("Create additional machinepool with taints")
611645
replicas := 3
@@ -648,6 +682,50 @@ var _ = Describe("Create MachinePool", ci.Day2, ci.NonHCPCluster, ci.FeatureMach
648682
Expect(taint.Value()).To(Equal(taints[index]["value"]))
649683
}
650684
})
685+
It("will validate well - [id:63139]", ci.Medium, ci.NonHCPCluster, func() {
686+
By("Will validate the subnet")
687+
MachinePoolArgs := &exe.MachinePoolArgs{
688+
Cluster: &clusterID,
689+
Replicas: h.IntPointer(0),
690+
MachineType: h.StringPointer("m5.xlarge"),
691+
Name: h.StringPointer("invalidsub"),
692+
SubnetID: h.StringPointer("subnet-invalidsubnetid"),
693+
}
694+
output, err := mpService.Apply(MachinePoolArgs, false)
695+
Expect(err).To(HaveOccurred())
696+
Expect(output).Should(ContainSubstring("Failed to find subnet"))
697+
698+
By("Will validate the instance type")
699+
MachinePoolArgs = &exe.MachinePoolArgs{
700+
Cluster: &clusterID,
701+
Replicas: h.IntPointer(0),
702+
MachineType: h.StringPointer("invalid"),
703+
Name: h.StringPointer("invalidinstype"),
704+
}
705+
output, err = mpService.Apply(MachinePoolArgs, false)
706+
Expect(err).To(HaveOccurred())
707+
Expect(output).Should(MatchRegexp(`[\s\S]*Machine type 'invalid'[\n\\n\s\t]*is not supported for cloud provider`))
708+
709+
By("Create machinepool creation plan with invalid tags")
710+
invalidTags := map[string]string{
711+
"aws:tags": "awsvalue",
712+
}
713+
replicas := 0
714+
machineType := "r5.xlarge"
715+
name := "mp-73942"
716+
717+
MachinePoolArgs = &exe.MachinePoolArgs{
718+
Cluster: &clusterID,
719+
Replicas: &replicas,
720+
MachineType: &machineType,
721+
Name: &name,
722+
Tags: &invalidTags,
723+
}
724+
output, err = mpService.Apply(MachinePoolArgs, false)
725+
Expect(err).To(HaveOccurred())
726+
Expect(output).Should(ContainSubstring("Tags that begin with 'aws:' are reserved"))
727+
728+
})
651729
})
652730

653731
var _ = Describe("Import MachinePool", ci.Day2, ci.NonHCPCluster, ci.FeatureImport, func() {

tests/e2e/cluster_edit_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var _ = Describe("Edit cluster", ci.Day2, func() {
2626
var err error
2727
clusterService, err = exec.NewClusterService(profile.GetClusterManifestsDir())
2828
Expect(err).ShouldNot(HaveOccurred())
29+
2930
})
3031

3132
Context("can edit/delete", func() {
@@ -537,5 +538,38 @@ var _ = Describe("Edit cluster", ci.Day2, func() {
537538
helper.ExpectTFErrorContains(err, "Attribute tags, cannot be changed from")
538539
})
539540
})
541+
Context("work for", func() {
542+
It("autoscaling change - [id:63147]",
543+
ci.Medium,
544+
func() {
545+
if profile.GetClusterType().HCP {
546+
Skip("This case only works for classic now")
547+
}
548+
549+
By("Define the recovery of the cluster")
550+
defer clusterService.Apply(&exec.ClusterCreationArgs{}, false, false)
551+
552+
By("Update the cluster to autoscaling")
553+
554+
clusterArgs = &exec.ClusterCreationArgs{
555+
Autoscaling: &exec.Autoscaling{
556+
AutoscalingEnabled: true,
557+
MinReplicas: 3,
558+
MaxReplicas: 6,
559+
},
560+
}
561+
if profile.Autoscale {
562+
clusterArgs = &exec.ClusterCreationArgs{
563+
Autoscaling: &exec.Autoscaling{
564+
AutoscalingEnabled: false,
565+
},
566+
Replicas: 3,
567+
}
568+
}
569+
err := clusterService.Apply(clusterArgs, false, false)
570+
Expect(err).To(HaveOccurred())
571+
helper.ExpectTFErrorContains(err, "Attribute max_replicas, cannot be changed from")
572+
})
573+
})
540574

541575
})
File renamed without changes.

tests/tf-manifests/rhcs/machine-pools/classic/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ resource "rhcs_machine_pool" "mp" {
2525
multi_availability_zone = var.multi_availability_zone
2626
disk_size = var.disk_size
2727
aws_additional_security_group_ids = var.additional_security_groups
28+
aws_tags = var.tags
2829
}

tests/tf-manifests/rhcs/machine-pools/classic/variable.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,7 @@ variable "additional_security_groups" {
6565
type = list(string)
6666
default = null
6767
}
68+
variable "tags" {
69+
type = map(string)
70+
default = null
71+
}

tests/utils/constants/config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ var RHCS = new(RHCSconfig)
2323
// RHCSConfig contains platforms info for the RHCS testing
2424
type RHCSconfig struct {
2525
// Env is the OpenShift Cluster Management environment used to provision clusters.
26-
RHCSURL string `env:"RHCS_URL" default:"api.stage.openshift.com" yaml:"env"`
27-
OCMEnv string `env:"OCM_ENV" default:"staging" yaml:"env"`
26+
RHCSURL string `env:"RHCS_URL" yaml:"rhcsURL,omitempty"`
27+
OCMEnv string `env:"OCM_ENV" default:"staging" yaml:"ocmENV,omitempty"`
2828
ClusterProfile string `env:"CLUSTER_PROFILE" yaml:"clusterProfile,omitempty"`
2929
ClusterProfileDir string `env:"CLUSTER_PROFILE_DIR" yaml:"clusterProfileDir,omitempty"`
3030
RhcsOutputDir string
3131
YAMLProfilesDir string
3232
RootDir string
3333
KubeConfigDir string
34-
RHCSSource string `env:"RHCS_SOURCE" default:"staging" yaml:"env"`
35-
RHCSVersion string `env:"RHCS_VERSION" default:"staging" yaml:"env"`
36-
RHCSClusterName string `env:"RHCS_CLUSTER_NAME" yaml:"clusterName"`
37-
RHCSClusterNamePrefix string `env:"RHCS_CLUSTER_NAME_PREFIX" yaml:"clusterNamePrefix"`
38-
RHCSClusterNameSuffix string `env:"RHCS_CLUSTER_NAME_SUFFIX" yaml:"clusterNameSuffix"`
34+
RHCSSource string `env:"RHCS_SOURCE" default:"staging" yaml:"rhcsSource,omitempty"`
35+
RHCSVersion string `env:"RHCS_VERSION" default:"staging" yaml:"rhcsVersion,omitempty"`
36+
RHCSClusterName string `env:"RHCS_CLUSTER_NAME" yaml:"clusterName,omitempty"`
37+
RHCSClusterNamePrefix string `env:"RHCS_CLUSTER_NAME_PREFIX" yaml:"clusterNamePrefix,omitempty"`
38+
RHCSClusterNameSuffix string `env:"RHCS_CLUSTER_NAME_SUFFIX" yaml:"clusterNameSuffix,omitempty"`
3939
}
4040

4141
func init() {
@@ -44,7 +44,7 @@ func init() {
4444
RHCS.RootDir = GetEnvWithDefault(WorkSpace, strings.SplitAfter(currentDir, project)[0])
4545

4646
// defaulted to staging
47-
RHCS.RHCSURL = GetEnvWithDefault(RHCSURL, RHCS.RHCSURL)
47+
RHCS.RHCSURL = GetEnvWithDefault(RHCSURL, "https://api.openshift.com")
4848
Logger.Infof("Running against RHCS URL: %s", RHCS.RHCSURL)
4949
RHCS.OCMEnv = ocmEnv(RHCS.RHCSURL)
5050

tests/utils/constants/constants.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ const (
101101
PreferNoSchedule = "PreferNoSchedule"
102102
)
103103

104+
// Machine pool
105+
const (
106+
DefaultMachinePoolName = "worker"
107+
)
108+
104109
type ClusterType struct {
105110
Name string
106111
HCP bool

tests/utils/exec/cluster.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ClusterCreationArgs struct {
2222
Fips bool `json:"fips,omitempty"`
2323
Tags map[string]string `json:"tags,omitempty"`
2424
AuditLogForward bool `json:"audit_log_forward,omitempty"`
25-
Autoscale bool `json:"autoscaling_enabled,omitempty"`
25+
Autoscaling *Autoscaling `json:"autoscaling,omitempty"`
2626
Etcd *bool `json:"etcd_encryption,omitempty"`
2727
EtcdKmsKeyARN *string `json:"etcd_kms_key_arn,omitempty"`
2828
KmsKeyARN *string `json:"kms_key_arn,omitempty"`
@@ -81,6 +81,12 @@ type ClusterOutput struct {
8181
UserTags map[string]string `json:"tags,omitempty"`
8282
}
8383

84+
type Autoscaling struct {
85+
AutoscalingEnabled bool `json:"autoscaling_enabled,omitempty"`
86+
MinReplicas int `json:"min_replicas,omitempty"`
87+
MaxReplicas int `json:"max_replicas,omitempty"`
88+
}
89+
8490
// ******************************************************
8591
// RHCS test cases used
8692
const (

0 commit comments

Comments
 (0)