Skip to content

Commit f13bfe2

Browse files
committed
E2E: Use UEFI
Switch e2e tests to UEFI instead of Legacy. Signed-off-by: Lennart Jern <lennart.jern@est.tech>
1 parent 3dac088 commit f13bfe2

11 files changed

Lines changed: 113 additions & 12 deletions

test/e2e/automated_cleaning_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var _ = Describe("Automated cleaning", Label("required", "automated-cleaning"),
5959
CredentialsName: "bmc-credentials",
6060
DisableCertificateVerification: bmc.DisableCertificateVerification,
6161
},
62-
BootMode: metal3api.Legacy,
62+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
6363
BootMACAddress: bmc.BootMacAddress,
6464
AutomatedCleaningMode: metal3api.CleaningModeMetadata,
6565
},

test/e2e/basic_ops_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var _ = Describe("basic", Label("required", "basic"), func() {
6161
CredentialsName: "bmc-credentials",
6262
DisableCertificateVerification: bmc.DisableCertificateVerification,
6363
},
64-
BootMode: metal3api.Legacy,
64+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
6565
BootMACAddress: bmc.BootMacAddress,
6666
},
6767
}

test/e2e/config/ironic.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ variables:
5555
IRONIC_PASSWORD: "changeme"
5656
IRONIC_PROVISIONING_IP: "192.168.222.2"
5757
IRONIC_PROVISIONING_PORT: "6385"
58+
# Boot mode can be legacy, UEFI or UEFISecureBoot
59+
BOOT_MODE: "UEFI"
5860

5961
NAMESPACE_SCOPED: "true"
6062

test/e2e/external_inspection_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ var _ = Describe("External Inspection", Label("required", "external-inspection")
212212
CredentialsName: "bmc-credentials-annotation",
213213
DisableCertificateVerification: bmc.DisableCertificateVerification,
214214
},
215-
BootMode: metal3api.Legacy,
215+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
216216
BootMACAddress: bmc.BootMacAddress,
217217
},
218218
}
@@ -283,7 +283,7 @@ var _ = Describe("External Inspection", Label("required", "external-inspection")
283283
CredentialsName: "bmc-credentials-hardware-data",
284284
DisableCertificateVerification: bmc.DisableCertificateVerification,
285285
},
286-
BootMode: metal3api.Legacy,
286+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
287287
BootMACAddress: bmc.BootMacAddress,
288288
InspectionMode: metal3api.InspectionModeDisabled,
289289
},

test/e2e/externally_provisioned_test.go

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1616
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1717
"k8s.io/apimachinery/pkg/types"
18+
"sigs.k8s.io/controller-runtime/pkg/client"
1819
"sigs.k8s.io/cluster-api/test/framework"
1920
)
2021

@@ -107,7 +108,102 @@ var _ = Describe("Create as externally provisioned, deprovision", Label("require
107108
By("Waiting for the secret to be deleted")
108109
Eventually(func() bool {
109110
err := clusterProxy.GetClient().Get(ctx, types.NamespacedName{
110-
Name: "bmc-credentials",
111+
Name: secretName,
112+
Namespace: namespace.Name,
113+
}, &corev1.Secret{})
114+
return k8serrors.IsNotFound(err)
115+
}, e2eConfig.GetIntervals(specName, "wait-secret-deletion")...).Should(BeTrue())
116+
})
117+
118+
It("transitions from Available to ExternallyProvisioned", func() {
119+
testSecretName := secretName + "-available-to-ext"
120+
By("Creating a secret with BMH credentials")
121+
bmcCredentialsData := map[string]string{
122+
"username": bmc.User,
123+
"password": bmc.Password,
124+
}
125+
CreateSecret(ctx, clusterProxy.GetClient(), namespace.Name, testSecretName, bmcCredentialsData)
126+
127+
By("Creating a BMH without ExternallyProvisioned to allow inspection")
128+
bmh := metal3api.BareMetalHost{
129+
ObjectMeta: metav1.ObjectMeta{
130+
Name: specName + "-available-to-ext",
131+
Namespace: namespace.Name,
132+
},
133+
Spec: metal3api.BareMetalHostSpec{
134+
BMC: metal3api.BMCDetails{
135+
Address: bmc.Address,
136+
CredentialsName: testSecretName,
137+
DisableCertificateVerification: bmc.DisableCertificateVerification,
138+
},
139+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
140+
BootMACAddress: bmc.BootMacAddress,
141+
ExternallyProvisioned: false, // Start with false to allow inspection
142+
},
143+
}
144+
err := clusterProxy.GetClient().Create(ctx, &bmh)
145+
Expect(err).NotTo(HaveOccurred())
146+
147+
By("waiting for the BMH to be in inspecting state")
148+
WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{
149+
Client: clusterProxy.GetClient(),
150+
Bmh: bmh,
151+
State: metal3api.StateInspecting,
152+
}, e2eConfig.GetIntervals(specName, "wait-inspecting")...)
153+
154+
By("Waiting for the BMH to complete inspection and reach Available state")
155+
WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{
156+
Client: clusterProxy.GetClient(),
157+
Bmh: bmh,
158+
State: metal3api.StateAvailable,
159+
}, e2eConfig.GetIntervals(specName, "wait-available")...)
160+
161+
By("Retrieving the BMH to verify inspection completed")
162+
err = clusterProxy.GetClient().Get(ctx, types.NamespacedName{
163+
Name: bmh.Name,
164+
Namespace: bmh.Namespace,
165+
}, &bmh)
166+
Expect(err).NotTo(HaveOccurred())
167+
168+
By("Verifying that inspection was performed")
169+
Expect(bmh.Status.OperationHistory.Inspect.Start.IsZero()).To(BeFalse(), "Inspection should have been performed")
170+
Expect(bmh.Status.HardwareDetails).NotTo(BeNil(), "Hardware details should be available after inspection")
171+
172+
By("Setting ExternallyProvisioned to true from Available state (allowed by webhook)")
173+
patch := client.MergeFrom(bmh.DeepCopy())
174+
bmh.Spec.ExternallyProvisioned = true
175+
err = clusterProxy.GetClient().Patch(ctx, &bmh, patch)
176+
Expect(err).NotTo(HaveOccurred())
177+
178+
By("Waiting for the BMH to transition to ExternallyProvisioned state")
179+
WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{
180+
Client: clusterProxy.GetClient(),
181+
Bmh: bmh,
182+
State: metal3api.StateExternallyProvisioned,
183+
}, e2eConfig.GetIntervals(specName, "wait-externally-provisioned")...)
184+
185+
By("Verifying that no BMO provisioning occurred after transition")
186+
err = clusterProxy.GetClient().Get(ctx, types.NamespacedName{
187+
Name: bmh.Name,
188+
Namespace: bmh.Namespace,
189+
}, &bmh)
190+
Expect(err).NotTo(HaveOccurred())
191+
Expect(bmh.Status.OperationHistory.Provision.Start.IsZero()).To(BeTrue(), "BMO provisioning should not have occurred")
192+
193+
By("Cleaning up the BMH")
194+
err = clusterProxy.GetClient().Delete(ctx, &bmh)
195+
Expect(err).NotTo(HaveOccurred())
196+
197+
WaitForBmhDeleted(ctx, WaitForBmhDeletedInput{
198+
Client: clusterProxy.GetClient(),
199+
BmhName: bmh.Name,
200+
Namespace: bmh.Namespace,
201+
}, e2eConfig.GetIntervals(specName, "wait-bmh-deleted")...)
202+
203+
By("Waiting for the secret to be deleted")
204+
Eventually(func() bool {
205+
err := clusterProxy.GetClient().Get(ctx, types.NamespacedName{
206+
Name: testSecretName,
111207
Namespace: namespace.Name,
112208
}, &corev1.Secret{})
113209
return k8serrors.IsNotFound(err)

test/e2e/inspection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ var _ = Describe("Inspection", Label("required", "inspection"), func() {
140140
CredentialsName: "bmc-credentials",
141141
DisableCertificateVerification: bmc.DisableCertificateVerification,
142142
},
143-
BootMode: metal3api.Legacy,
143+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
144144
BootMACAddress: bmc.BootMacAddress,
145145
},
146146
}

test/e2e/live_iso_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var _ = Describe("Live-ISO", Label("required", "live-iso"), func() {
7878
URL: imageURL,
7979
DiskFormat: pointer.String("live-iso"),
8080
},
81-
BootMode: metal3api.Legacy,
81+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
8282
BootMACAddress: bmc.BootMacAddress,
8383
AutomatedCleaningMode: metal3api.CleaningModeDisabled,
8484
},

test/e2e/provisioning_and_annotation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var _ = Describe("Provision, detach, recreate from status and deprovision", Labe
6363
CredentialsName: "bmc-credentials",
6464
DisableCertificateVerification: bmc.DisableCertificateVerification,
6565
},
66-
BootMode: metal3api.Legacy,
66+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
6767
BootMACAddress: bmc.BootMacAddress,
6868
AutomatedCleaningMode: "disabled",
6969
},
@@ -208,7 +208,7 @@ var _ = Describe("Provision, detach, recreate from status and deprovision", Labe
208208
CredentialsName: "bmc-credentials",
209209
DisableCertificateVerification: bmc.DisableCertificateVerification,
210210
},
211-
BootMode: metal3api.Legacy,
211+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
212212
BootMACAddress: bmc.BootMacAddress,
213213
AutomatedCleaningMode: "disabled",
214214
Image: &metal3api.Image{

test/e2e/re_inspection_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ var _ = Describe("Re-Inspection", Label("required", "re-inspection"), func() {
6363
CredentialsName: "bmc-credentials",
6464
DisableCertificateVerification: bmc.DisableCertificateVerification,
6565
},
66-
BootMode: metal3api.Legacy,
66+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
6767
BootMACAddress: bmc.BootMacAddress,
6868
},
6969
}

test/e2e/upgrade_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func RunUpgradeTest(ctx context.Context, input *BMOIronicUpgradeInput, upgradeCl
270270
CredentialsName: secretName,
271271
DisableCertificateVerification: bmc.DisableCertificateVerification,
272272
},
273-
BootMode: metal3api.Legacy,
273+
BootMode: metal3api.BootMode(e2eConfig.GetVariable("BOOT_MODE")),
274274
BootMACAddress: bmc.BootMacAddress,
275275
},
276276
}

0 commit comments

Comments
 (0)