Skip to content

Commit 0927182

Browse files
OCM-13976 | ci: adjust some configures to support OCP E2E jobs
1 parent 4d281ae commit 0927182

File tree

9 files changed

+187
-4
lines changed

9 files changed

+187
-4
lines changed

tests/ci/config/config.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type TestConfig struct {
4646
ProxyCABundleFile string
4747
GlobalENV *GlobalENVVariables
4848
ClusterENV *ClusterENVVariables
49+
Day2ConfENV *Day2ConfENVVariables
4950
}
5051
type GlobalENVVariables struct {
5152
ChannelGroup string `env:"CHANNEL_GROUP" default:""`
@@ -73,6 +74,12 @@ type ClusterENVVariables struct {
7374
AllowRegistries string `env:"ALLOW_REGISTRIES" default:""`
7475
}
7576

77+
type Day2ConfENVVariables struct {
78+
LocalZoneMP bool `env:"LOCAL_ZONE_MP" default:"false"`
79+
TuningConfig bool `env:"TUNING_CONFIG" default:"false"`
80+
TuningConfigMP bool `env:"TUNING_CONFIG_MP" default:"false"`
81+
}
82+
7683
func init() {
7784
Test = new(TestConfig)
7885
currentDir, _ := os.Getwd()
@@ -146,4 +153,13 @@ func init() {
146153
AllowRegistries: os.Getenv("ALLOW_REGISTRIES"),
147154
}
148155

156+
local_zone_mp, _ := strconv.ParseBool(helper.ReadENVWithDefaultValue("LOCAL_ZONE_MP", "false"))
157+
tuning_config, _ := strconv.ParseBool(helper.ReadENVWithDefaultValue("TUNING_CONFIG", "false"))
158+
tuning_config_mp, _ := strconv.ParseBool(helper.ReadENVWithDefaultValue("TUNING_CONFIG_MP", "false"))
159+
Test.Day2ConfENV = &Day2ConfENVVariables{
160+
LocalZoneMP: local_zone_mp,
161+
TuningConfig: tuning_config,
162+
TuningConfigMP: tuning_config_mp,
163+
}
164+
149165
}

tests/ci/data/profiles/rosa-classic.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ profiles:
1616
autoscale: true
1717
kms_key: true
1818
networking: true
19-
proxy_enabled: true
19+
proxy_enabled: false
2020
label_enabled: true
2121
tag_enabled: false
2222
zones: ""
@@ -34,6 +34,10 @@ profiles:
3434
account-role:
3535
path: "/test/"
3636
permission_boundary: "arn:aws:iam::aws:policy/AdministratorAccess"
37+
day2-conf:
38+
local-zone-mp: false
39+
tuning-config: false
40+
tuning-config-mp: false
3741
- as: rosa-private-link
3842
version: latest
3943
channel_group: "candidate"
@@ -51,7 +55,7 @@ profiles:
5155
autoscale: true
5256
kms_key: true
5357
networking: false
54-
proxy_enabled: false
58+
proxy_enabled: true
5559
label_enabled: false
5660
tag_enabled: false
5761
zones: ""

tests/ci/data/profiles/rosa-hcp.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,38 @@ profiles:
194194
account-role:
195195
customized_prefix: true
196196
path: ""
197-
permission_boundary: ""
197+
permission_boundary: ""
198+
- as: rosa-hcp-zero-egress
199+
version: latest
200+
channel_group: stable
201+
region: "us-west-2"
202+
cluster:
203+
multi_az: true
204+
shared_vpc: false
205+
instance_type: "m5.xlarge"
206+
hcp: true
207+
sts: true
208+
byo_vpc: true
209+
additional_principals: false
210+
imdsv2: "required"
211+
private: true
212+
etcd_encryption: true
213+
autoscale: true
214+
kms_key: true
215+
networking: true
216+
proxy_enabled: true
217+
label_enabled: false
218+
zones: ""
219+
tag_enabled: true
220+
etcd_kms: true
221+
fips: false
222+
oidc_config: "managed"
223+
admin_enabled: false
224+
volume_size: 75
225+
disable_uwm: true
226+
additional_sg_number: 3
227+
zero_egress: false
228+
account-role:
229+
customized_prefix: true
230+
path: ""
231+
permission_boundary: ""

tests/ci/labels/runtime.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type runtimeLabels struct {
1717
Day1 Labels
1818
Day1Readiness Labels
1919
Day1Post Labels
20+
Day2Readiness Labels
2021
Day2 Labels
2122
Upgrade Labels
2223
Destructive Labels
@@ -44,6 +45,7 @@ func initRuntime() *runtimeLabels {
4445
rLabels.Destructive = Label("destructive")
4546
rLabels.Destroy = Label("destroy")
4647
rLabels.DestroyPost = Label("destroy-post")
48+
rLabels.Day2Readiness = Label("day2-readiness")
4749

4850
rLabels.Day1Supplemental = Label("day1-supplemental")
4951
rLabels.OCMResources = Label("ocm-resources")

tests/e2e/e2e.test

75.9 MB
Binary file not shown.

tests/e2e/e2e_setup_test.go

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
. "github.com/onsi/ginkgo/v2"
99
. "github.com/onsi/gomega"
10+
"github.com/openshift-online/ocm-common/pkg/test/vpc_client"
1011

1112
"github.com/openshift/rosa/tests/ci/config"
1213
"github.com/openshift/rosa/tests/ci/labels"
@@ -141,4 +142,112 @@ var _ = Describe("Cluster preparation", labels.Feature.Cluster, func() {
141142
}
142143

143144
})
145+
146+
It("to prepare day2 conf for cluster",
147+
labels.Runtime.Day2Readiness,
148+
func() {
149+
profile := handler.LoadProfileYamlFileByENV()
150+
client := rosacli.NewClient()
151+
clusterHandler, err := handler.NewClusterHandlerFromFilesystem(client, profile)
152+
Expect(err).ToNot(HaveOccurred())
153+
154+
clusterID := clusterHandler.GetClusterDetail().ClusterID
155+
clusterService := client.Cluster
156+
output, err := clusterService.DescribeCluster(clusterID)
157+
Expect(err).To(BeNil())
158+
clusterDetails, err := clusterService.ReflectClusterDescription(output)
159+
Expect(err).To(BeNil())
160+
161+
clusterConfig, err := utilConfig.ParseClusterProfile()
162+
Expect(err).To(BeNil())
163+
164+
if profile.ClusterConfig.BYOVPC == false {
165+
Skip("This day2 config only work for byovpc cluster")
166+
}
167+
168+
//Create local zone for cluster
169+
if profile.Day2Config != nil && profile.Day2Config.LocalZoneMP {
170+
By("Prepare a subnet out of the cluster creation subnet")
171+
subnets := helper.ParseCommaSeparatedStrings(clusterConfig.Subnets.PrivateSubnetIds)
172+
173+
By("Build vpc client to find a local zone for subnet preparation")
174+
vpcClient, err := vpc_client.GenerateVPCBySubnet(subnets[0], clusterConfig.Region)
175+
Expect(err).ToNot(HaveOccurred())
176+
177+
zones, err := vpcClient.AWSClient.ListAvaliableZonesForRegion(clusterConfig.Region, "local-zone")
178+
Expect(err).ToNot(HaveOccurred())
179+
Expect(len(zones)).ToNot(BeZero(), "No local zone found in the region")
180+
localZone := zones[0]
181+
182+
By("Prepare the subnet for the picked zone")
183+
subNetMap, err := vpcClient.PreparePairSubnetByZone(localZone)
184+
Expect(err).ToNot(HaveOccurred())
185+
Expect(subNetMap).ToNot(BeNil())
186+
privateSubnet := subNetMap["private"]
187+
188+
By("Describe the cluster to get the infra ID for tagging")
189+
tagKey := fmt.Sprintf("kubernetes.io/cluster/%s", clusterDetails.InfraID)
190+
vpcClient.AWSClient.TagResource(privateSubnet.ID, map[string]string{
191+
tagKey: "shared",
192+
})
193+
194+
By("Find a machinetype supported by the zone")
195+
instanceTypes, err := vpcClient.AWSClient.ListAvaliableInstanceTypesForRegion(
196+
clusterConfig.Region, localZone)
197+
Expect(err).ToNot(HaveOccurred())
198+
199+
By("Create temporary account-roles for instance type list")
200+
namePrefix := helper.GenerateRandomName("test-day2-conf", 2)
201+
majorVersion := helper.SplitMajorVersion(clusterConfig.Version.RawID)
202+
_, err = client.OCMResource.CreateAccountRole("--mode", "auto",
203+
"--prefix", namePrefix,
204+
"--version", majorVersion,
205+
"--channel-group", clusterConfig.Version.ChannelGroup,
206+
"-y")
207+
Expect(err).ToNot(HaveOccurred())
208+
209+
var accountRoles *rosacli.AccountRolesUnit
210+
accRoleList, _, err := client.OCMResource.ListAccountRole()
211+
Expect(err).ToNot(HaveOccurred())
212+
accountRoles = accRoleList.DigAccountRoles(namePrefix, false)
213+
214+
defer client.OCMResource.DeleteAccountRole(
215+
"--prefix", namePrefix,
216+
"--mode", "auto",
217+
"-y")
218+
219+
rosaSupported, _, err := client.OCMResource.ListInstanceTypes(
220+
"--region", clusterConfig.Region,
221+
"--role-arn", accountRoles.InstallerRole,
222+
)
223+
Expect(err).ToNot(HaveOccurred())
224+
225+
bothSupported := []string{}
226+
for _, rosains := range rosaSupported.InstanceTypesList {
227+
if helper.SliceContains(instanceTypes, rosains.ID) {
228+
bothSupported = append(bothSupported, rosains.ID)
229+
}
230+
}
231+
Expect(bothSupported).ToNot(BeEmpty(), "There are no instance types supported in the zone")
232+
instanceType := bothSupported[0]
233+
234+
By("Create machinepool with the subnet specified will succeed")
235+
localZoneMpName := "localz-day2-conf"
236+
_, err = client.MachinePool.CreateMachinePool(clusterID, localZoneMpName,
237+
"--replicas", "1",
238+
"--subnet", privateSubnet.ID,
239+
"--instance-type", instanceType,
240+
"--labels", "prowci=true,node-role.kubernetes.io/edge=",
241+
"--taints", "prowci=true:NoSchedule,node-role.kubernetes.io/edge=:NoSchedule",
242+
)
243+
Expect(err).ToNot(HaveOccurred())
244+
245+
By("List the machinepools and check")
246+
mpList, err := client.MachinePool.ListAndReflectMachinePools(clusterID)
247+
Expect(err).ToNot(HaveOccurred())
248+
mp := mpList.Machinepool(localZoneMpName)
249+
Expect(mp.Replicas).To(Equal("1"))
250+
Expect(mp.Subnets).To(Equal(privateSubnet.ID))
251+
}
252+
})
144253
})

tests/utils/handler/cluster_handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ func (ch *clusterHandler) GenerateClusterCreateFlags() ([]string, error) {
812812
"--registry-config-additional-trusted-ca", caFile,
813813
"--registry-config-insecure-registries", "test.com,*.example",
814814
"--registry-config-allowed-registries-for-import",
815-
"docker.io:false,registry.redhat.com:false,registry.access.redhat.com:false,quay.io:false",
815+
"docker.io:false,registry.redhat.com:false,registry.access.redhat.com:false,quay.io:false,registry.redhat.io:false",
816816
)
817817
if ch.profile.ClusterConfig.AllowedRegistries {
818818
flags = append(flags,

tests/utils/handler/interface.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ type Profile struct {
99
Version string `yaml:"version,omitempty"`
1010
AccountRoleConfig *AccountRoleConfig `yaml:"account-role,omitempty"`
1111
ClusterConfig *ClusterConfig `yaml:"cluster,omitempty"`
12+
Day2Config *Day2Config `yaml:"day2-conf,omitempty"`
13+
}
14+
15+
// Day2Config will map the configuration of day2-conf from profile settings
16+
type Day2Config struct {
17+
LocalZoneMP bool `yaml:"local-zone-mp,omitempty"`
18+
TuningConfig bool `yaml:" tuning-config,omitempty"`
19+
TuningConfigMP bool `yaml:" tuning-config-mp,omitempty"`
1220
}
1321

1422
// AccountRoleConfig will map the configuration of account roles from profile settings

tests/utils/handler/profile.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func LoadProfileYamlFile(profileName string) *Profile {
8484
p := GetProfile(profileName, GetYAMLProfilesDir())
8585
log.Logger.Infof("Loaded cluster profile configuration from original profile %s : %v", profileName, *p)
8686
log.Logger.Infof("Loaded cluster profile configuration from original cluster %s : %v", profileName, *p.ClusterConfig)
87+
if p.Day2Config != nil {
88+
log.Logger.Infof("Loaded day2 configuration from original day2 conf %s : %v", profileName, *p.Day2Config)
89+
}
8790
if p.AccountRoleConfig != nil {
8891
log.Logger.Infof("Loaded cluster profile configuration from original account-roles %s : %v",
8992
profileName, *p.AccountRoleConfig)
@@ -182,5 +185,12 @@ func LoadProfileYamlFileByENV() *Profile {
182185
profile.ClusterConfig.AllowedRegistries = helper.ParseBool(config.Test.ClusterENV.AllowRegistries)
183186
}
184187

188+
if config.Test.Day2ConfENV.LocalZoneMP {
189+
if profile.Day2Config != nil {
190+
log.Logger.Infof("Got global env settings for LOCAL_ZONE_MP, overwritten the profile setting with value %v",
191+
config.Test.Day2ConfENV.LocalZoneMP)
192+
profile.Day2Config.LocalZoneMP = config.Test.Day2ConfENV.LocalZoneMP
193+
}
194+
}
185195
return profile
186196
}

0 commit comments

Comments
 (0)