Skip to content

Commit 7ac7db0

Browse files
committed
test: updates for CAPI v1.10 new functions
1 parent f2797b3 commit 7ac7db0

File tree

9 files changed

+44
-40
lines changed

9 files changed

+44
-40
lines changed

test/e2e/shared/cluster.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ func createClusterctlLocalRepository(config *clusterctl.E2EConfig, repositoryFol
4242

4343
// Ensuring a CNI file is defined in the config and register a FileTransformation to inject the referenced file as in place of the CNI_RESOURCES envSubst variable.
4444
Expect(config.Variables).To(HaveKey(capie2e.CNIPath), "Missing %s variable in the config", capie2e.CNIPath)
45-
cniPath := config.GetVariable(capie2e.CNIPath)
45+
cniPath := config.MustGetVariable(capie2e.CNIPath)
4646
Expect(cniPath).To(BeAnExistingFile(), "The %s variable should resolve to an existing file", capie2e.CNIPath)
4747
createRepositoryInput.RegisterClusterResourceSetConfigMapTransformation(cniPath, capie2e.CNIResources)
4848

4949
// Ensuring a CCM file is defined in the config and register a FileTransformation to inject the referenced file as in place of the CCM_RESOURCES envSubst variable.
5050
Expect(config.Variables).To(HaveKey(CCMPath), "Missing %s variable in the config", CCMPath)
51-
ccmPath := config.GetVariable(CCMPath)
51+
ccmPath := config.MustGetVariable(CCMPath)
5252
Expect(ccmPath).To(BeAnExistingFile(), "The %s variable should resolve to an existing file", CCMPath)
5353
createRepositoryInput.RegisterClusterResourceSetConfigMapTransformation(ccmPath, CCMResources)
5454

@@ -69,7 +69,7 @@ func setupBootstrapCluster(config *clusterctl.E2EConfig, scheme *runtime.Scheme,
6969
// try to use an existing cluster
7070
if useExistingCluster {
7171
// If the kubeContext is locked: try to use the default kubeconfig with the current context
72-
kubeContext := config.GetVariable(KubeContext)
72+
kubeContext := config.GetVariableOrEmpty(KubeContext)
7373
if kubeContext != "" {
7474
testKubeconfigPath := clientcmd.NewDefaultClientConfigLoadingRules().GetDefaultFilename()
7575
kubecfg, err := clientcmd.LoadFromFile(testKubeconfigPath)

test/e2e/shared/common.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ func DumpSpecResourcesAndCleanup(ctx context.Context, specName string, namespace
8585
panic(r)
8686
}()
8787
framework.DeleteAllClustersAndWait(ctx, framework.DeleteAllClustersAndWaitInput{
88-
Client: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
89-
Namespace: namespace.Name,
88+
ClusterProxy: e2eCtx.Environment.BootstrapClusterProxy,
89+
ClusterctlConfigPath: e2eCtx.Settings.ConfigPath,
90+
Namespace: namespace.Name,
91+
ArtifactFolder: e2eCtx.Settings.ArtifactFolder,
9092
}, e2eCtx.E2EConfig.GetIntervals(specName, "wait-delete-cluster")...)
9193
}()
9294

@@ -118,9 +120,11 @@ func ClusterForSpec(ctx context.Context, e2eCtx *E2EContext, namespace *corev1.N
118120
func dumpSpecResources(ctx context.Context, e2eCtx *E2EContext, namespace *corev1.Namespace, directory ...string) {
119121
paths := append([]string{e2eCtx.Settings.ArtifactFolder, "clusters", e2eCtx.Environment.BootstrapClusterProxy.GetName(), "resources"}, directory...)
120122
framework.DumpAllResources(ctx, framework.DumpAllResourcesInput{
121-
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
122-
Namespace: namespace.Name,
123-
LogPath: filepath.Join(paths...),
123+
Lister: e2eCtx.Environment.BootstrapClusterProxy.GetClient(),
124+
KubeConfigPath: e2eCtx.Environment.BootstrapClusterProxy.GetKubeconfigPath(),
125+
ClusterctlConfigPath: e2eCtx.Settings.ConfigPath,
126+
Namespace: namespace.Name,
127+
LogPath: filepath.Join(paths...),
124128
})
125129
}
126130

@@ -232,7 +236,7 @@ func (o OpenStackLogCollector) CollectMachineLog(ctx context.Context, management
232236
if openStackCluster.Status.Bastion == nil {
233237
Logf("Skipping log collection for machine %q since no bastion is available", m.Name)
234238
} else {
235-
srvUser := o.E2EContext.E2EConfig.GetVariable(SSHUserMachine)
239+
srvUser := o.E2EContext.E2EConfig.MustGetVariable(SSHUserMachine)
236240
executeCommands(
237241
ctx,
238242
o.E2EContext.Settings.ArtifactFolder,

test/e2e/shared/images.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func CoreImages(e2eCtx *E2EContext) []DownloadImage {
6666
return []DownloadImage{
6767
{
6868
Name: "cirros",
69-
ArtifactPath: "cirros/2022-12-05/" + e2eCtx.E2EConfig.GetVariable("OPENSTACK_BASTION_IMAGE_NAME") + ".img",
69+
ArtifactPath: "cirros/2022-12-05/" + e2eCtx.E2EConfig.MustGetVariable("OPENSTACK_BASTION_IMAGE_NAME") + ".img",
7070

7171
// Specifying an image hash means we can't use
7272
// web-download. This serves as an E2E test of image
@@ -79,7 +79,7 @@ func CoreImages(e2eCtx *E2EContext) []DownloadImage {
7979
},
8080
{
8181
Name: "capo-default",
82-
ArtifactPath: "ubuntu/2024-11-21/" + e2eCtx.E2EConfig.GetVariable("OPENSTACK_IMAGE_NAME") + ".img",
82+
ArtifactPath: "ubuntu/2024-11-21/" + e2eCtx.E2EConfig.MustGetVariable("OPENSTACK_IMAGE_NAME") + ".img",
8383
},
8484
}
8585
}
@@ -231,8 +231,8 @@ func DeleteAllORCImages(ctx context.Context, e2eCtx *E2EContext) {
231231

232232
func generateCredentialsSecret(e2eCtx *E2EContext) *corev1.Secret {
233233
// We run in Node1BeforeSuite, so OPENSTACK_CLOUD_YAML_B64 is not yet set
234-
openStackCloudYAMLFile := e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile)
235-
caCertB64 := e2eCtx.E2EConfig.GetVariable(OpenStackCloudCACertB64)
234+
openStackCloudYAMLFile := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile)
235+
caCertB64 := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudCACertB64)
236236
caCert, err := base64.StdEncoding.DecodeString(caCertB64)
237237
Expect(err).NotTo(HaveOccurred(), "base64 decode CA Cert: "+caCertB64)
238238

@@ -264,7 +264,7 @@ func generateORCImage(e2eCtx *E2EContext, name, glanceName, url string, download
264264
WithURL(url)))).
265265
WithCloudCredentialsRef(orcapplyconfigv1alpha1.CloudCredentialsReference().
266266
WithSecretName(credentialsSecretName).
267-
WithCloudName(e2eCtx.E2EConfig.GetVariable("OPENSTACK_CLOUD"))))
267+
WithCloudName(e2eCtx.E2EConfig.MustGetVariable("OPENSTACK_CLOUD"))))
268268

269269
if downloadHash != nil {
270270
applyConfig.Spec.Resource.Content.Download.

test/e2e/shared/openstack.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,17 +657,17 @@ func GetOpenStackServerWithIP(e2eCtx *E2EContext, id string, openStackCluster *i
657657
}
658658

659659
func GetTenantProviderClient(e2eCtx *E2EContext) (*gophercloud.ProviderClient, *clientconfig.ClientOpts, *string, error) {
660-
openstackCloud := e2eCtx.E2EConfig.GetVariable(OpenStackCloud)
660+
openstackCloud := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloud)
661661
return getProviderClient(e2eCtx, openstackCloud)
662662
}
663663

664664
func GetAdminProviderClient(e2eCtx *E2EContext) (*gophercloud.ProviderClient, *clientconfig.ClientOpts, *string, error) {
665-
openstackCloud := e2eCtx.E2EConfig.GetVariable(OpenStackCloudAdmin)
665+
openstackCloud := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudAdmin)
666666
return getProviderClient(e2eCtx, openstackCloud)
667667
}
668668

669669
func getProviderClient(e2eCtx *E2EContext, openstackCloud string) (*gophercloud.ProviderClient, *clientconfig.ClientOpts, *string, error) {
670-
openStackCloudYAMLFile := e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile)
670+
openStackCloudYAMLFile := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile)
671671

672672
clouds := getParsedOpenStackCloudYAML(openStackCloudYAMLFile)
673673
cloud := clouds.Clouds[openstackCloud]

test/e2e/shared/suite.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func Node1BeforeSuite(ctx context.Context, e2eCtx *E2EContext) []byte {
6363
Logf("Loading the e2e test configuration from %q", e2eCtx.Settings.ConfigPath)
6464
e2eCtx.E2EConfig = LoadE2EConfig(e2eCtx.Settings.ConfigPath)
6565

66-
Expect(e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile)).To(BeAnExistingFile(), "Invalid test suite argument. Value of environment variable OPENSTACK_CLOUD_YAML_FILE should be an existing file: %s", e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile))
67-
Logf("Loading the clouds.yaml from %q", e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile))
66+
Expect(e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile)).To(BeAnExistingFile(), "Invalid test suite argument. Value of environment variable OPENSTACK_CLOUD_YAML_FILE should be an existing file: %s", e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile))
67+
Logf("Loading the clouds.yaml from %q", e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile))
6868

6969
templates := []clusterctl.Files{}
7070

@@ -196,8 +196,8 @@ func AllNodesBeforeSuite(e2eCtx *E2EContext, data []byte) {
196196
e2eCtx.Settings.GinkgoNodes = conf.GinkgoNodes
197197
e2eCtx.Settings.GinkgoSlowSpecThreshold = conf.GinkgoSlowSpecThreshold
198198

199-
openStackCloudYAMLFile := e2eCtx.E2EConfig.GetVariable(OpenStackCloudYAMLFile)
200-
openStackCloud := e2eCtx.E2EConfig.GetVariable(OpenStackCloud)
199+
openStackCloudYAMLFile := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloudYAMLFile)
200+
openStackCloud := e2eCtx.E2EConfig.MustGetVariable(OpenStackCloud)
201201
SetEnvVar("OPENSTACK_CLOUD_YAML_B64", getEncodedOpenStackCloudYAML(openStackCloudYAMLFile), true)
202202
SetEnvVar("OPENSTACK_CLOUD_PROVIDER_CONF_B64", getEncodedOpenStackCloudProviderConf(openStackCloudYAMLFile, openStackCloud), true)
203203
SetEnvVar("OPENSTACK_SSH_KEY_NAME", DefaultSSHKeyPairName, false)

test/e2e/suites/conformance/conformance_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var _ = Describe("conformance tests", func() {
5555

5656
It(specName, func(ctx context.Context) {
5757
name := fmt.Sprintf("cluster-%s", namespace.Name)
58-
kubernetesVersion := e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion)
58+
kubernetesVersion := e2eCtx.E2EConfig.MustGetVariable(shared.KubernetesVersion)
5959

6060
flavor := shared.FlavorDefault
6161
// * with UseCIArtifacts we use the latest Kubernetes ci release
@@ -65,9 +65,9 @@ var _ = Describe("conformance tests", func() {
6565
Expect(err).NotTo(HaveOccurred())
6666
}
6767

68-
workerMachineCount, err := strconv.ParseInt(e2eCtx.E2EConfig.GetVariable("CONFORMANCE_WORKER_MACHINE_COUNT"), 10, 64)
68+
workerMachineCount, err := strconv.ParseInt(e2eCtx.E2EConfig.MustGetVariable("CONFORMANCE_WORKER_MACHINE_COUNT"), 10, 64)
6969
Expect(err).NotTo(HaveOccurred())
70-
controlPlaneMachineCount, err := strconv.ParseInt(e2eCtx.E2EConfig.GetVariable("CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT"), 10, 64)
70+
controlPlaneMachineCount, err := strconv.ParseInt(e2eCtx.E2EConfig.MustGetVariable("CONFORMANCE_CONTROL_PLANE_MACHINE_COUNT"), 10, 64)
7171
Expect(err).NotTo(HaveOccurred())
7272

7373
experiment := gmeasure.NewExperiment(specName)

test/e2e/suites/e2e/clusterctl_upgrade_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var _ = Describe("When testing clusterctl upgrades (v0.10=>current) [clusterctl-
5959
InitWithControlPlaneProviders: []string{"kubeadm:" + OldCAPIVersion},
6060
MgmtFlavor: shared.FlavorDefault,
6161
WorkloadFlavor: shared.FlavorWithoutORC,
62-
InitWithKubernetesVersion: e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion),
62+
InitWithKubernetesVersion: e2eCtx.E2EConfig.MustGetVariable(shared.KubernetesVersion),
6363
}
6464
})
6565
})

test/e2e/suites/e2e/e2e_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ var _ = SynchronizedBeforeSuite(func(ctx context.Context) []byte {
100100

101101
upgradeImage = shared.DownloadImage{
102102
Name: "capo-upgrade-from",
103-
ArtifactPath: "ubuntu/2024-05-28/" + e2eCtx.E2EConfig.GetVariable("OPENSTACK_IMAGE_NAME_UPGRADE_FROM") + ".img",
103+
ArtifactPath: "ubuntu/2024-05-28/" + e2eCtx.E2EConfig.MustGetVariable("OPENSTACK_IMAGE_NAME_UPGRADE_FROM") + ".img",
104104
}
105105
})
106106

test/e2e/suites/e2e/e2e_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func flatcarImages(e2eCtx *shared.E2EContext) []shared.DownloadImage {
6868
return []shared.DownloadImage{
6969
{
7070
Name: "capo-flatcar",
71-
ArtifactPath: "flatcar/" + e2eCtx.E2EConfig.GetVariable("OPENSTACK_FLATCAR_IMAGE_NAME") + ".img",
71+
ArtifactPath: "flatcar/" + e2eCtx.E2EConfig.MustGetVariable("OPENSTACK_FLATCAR_IMAGE_NAME") + ".img",
7272
},
7373
{
7474
Name: "flatcar-openstack",
@@ -277,7 +277,7 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
277277
).Should(BeTrue())
278278

279279
shared.Logf("Create the bastion with a new flavor")
280-
bastionNewFlavorName := ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackBastionFlavorAlt))
280+
bastionNewFlavorName := ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackBastionFlavorAlt))
281281
bastionNewFlavor, err := shared.GetFlavorFromName(e2eCtx, bastionNewFlavorName)
282282
Expect(err).NotTo(HaveOccurred())
283283
openStackCluster, err = shared.ClusterForSpec(ctx, e2eCtx, namespace)
@@ -839,9 +839,9 @@ var _ = Describe("e2e tests [PR-Blocking]", func() {
839839
)
840840

841841
BeforeEach(func(ctx context.Context) {
842-
failureDomain = e2eCtx.E2EConfig.GetVariable(shared.OpenStackFailureDomain)
843-
failureDomainAlt = e2eCtx.E2EConfig.GetVariable(shared.OpenStackFailureDomainAlt)
844-
volumeTypeAlt = e2eCtx.E2EConfig.GetVariable(shared.OpenStackVolumeTypeAlt)
842+
failureDomain = e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackFailureDomain)
843+
failureDomainAlt = e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackFailureDomainAlt)
844+
volumeTypeAlt = e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackVolumeTypeAlt)
845845

846846
// We create the second compute host asynchronously, so
847847
// we need to ensure the alternate failure domain exists
@@ -1070,7 +1070,7 @@ func defaultConfigCluster(clusterName, namespace string) clusterctl.ConfigCluste
10701070
InfrastructureProvider: clusterctl.DefaultInfrastructureProvider,
10711071
Namespace: namespace,
10721072
ClusterName: clusterName,
1073-
KubernetesVersion: e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion),
1073+
KubernetesVersion: e2eCtx.E2EConfig.MustGetVariable(shared.KubernetesVersion),
10741074
}
10751075
}
10761076

@@ -1133,16 +1133,16 @@ func makeOpenStackMachineTemplate(namespace, clusterName, name string) *infrav1.
11331133
Spec: infrav1.OpenStackMachineTemplateSpec{
11341134
Template: infrav1.OpenStackMachineTemplateResource{
11351135
Spec: infrav1.OpenStackMachineSpec{
1136-
Flavor: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackNodeMachineFlavor)),
1136+
Flavor: ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackNodeMachineFlavor)),
11371137
Image: infrav1.ImageParam{
11381138
Filter: &infrav1.ImageFilter{
1139-
Name: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)),
1139+
Name: ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackImageName)),
11401140
},
11411141
},
11421142
SSHKeyName: shared.DefaultSSHKeyPairName,
11431143
IdentityRef: &infrav1.OpenStackIdentityReference{
11441144
Name: fmt.Sprintf("%s-cloud-config", clusterName),
1145-
CloudName: e2eCtx.E2EConfig.GetVariable(shared.OpenStackCloud),
1145+
CloudName: e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackCloud),
11461146
},
11471147
},
11481148
},
@@ -1159,16 +1159,16 @@ func makeOpenStackMachineTemplateWithPortOptions(namespace, clusterName, name st
11591159
Spec: infrav1.OpenStackMachineTemplateSpec{
11601160
Template: infrav1.OpenStackMachineTemplateResource{
11611161
Spec: infrav1.OpenStackMachineSpec{
1162-
Flavor: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackNodeMachineFlavor)),
1162+
Flavor: ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackNodeMachineFlavor)),
11631163
Image: infrav1.ImageParam{
11641164
Filter: &infrav1.ImageFilter{
1165-
Name: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.OpenStackImageName)),
1165+
Name: ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackImageName)),
11661166
},
11671167
},
11681168
SSHKeyName: shared.DefaultSSHKeyPairName,
11691169
IdentityRef: &infrav1.OpenStackIdentityReference{
11701170
Name: fmt.Sprintf("%s-cloud-config", clusterName),
1171-
CloudName: e2eCtx.E2EConfig.GetVariable(shared.OpenStackCloud),
1171+
CloudName: e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackCloud),
11721172
},
11731173
Ports: *portOpts,
11741174
Tags: machineTags,
@@ -1207,7 +1207,7 @@ func makeJoinBootstrapConfigTemplate(namespace, name string) *bootstrapv1.Kubead
12071207

12081208
func makeMachineDeployment(namespace, mdName, clusterName string, failureDomain string, replicas int32) *clusterv1.MachineDeployment {
12091209
if failureDomain == "" {
1210-
failureDomain = e2eCtx.E2EConfig.GetVariable(shared.OpenStackFailureDomain)
1210+
failureDomain = e2eCtx.E2EConfig.MustGetVariable(shared.OpenStackFailureDomain)
12111211
}
12121212
return &clusterv1.MachineDeployment{
12131213
ObjectMeta: metav1.ObjectMeta{
@@ -1251,7 +1251,7 @@ func makeMachineDeployment(namespace, mdName, clusterName string, failureDomain
12511251
Name: mdName,
12521252
Namespace: namespace,
12531253
},
1254-
Version: ptr.To(e2eCtx.E2EConfig.GetVariable(shared.KubernetesVersion)),
1254+
Version: ptr.To(e2eCtx.E2EConfig.MustGetVariable(shared.KubernetesVersion)),
12551255
},
12561256
},
12571257
},

0 commit comments

Comments
 (0)