Skip to content

Commit 064bc7a

Browse files
committed
e2e: new test on external inspection without annotations
With HardwareData CR, we don't actually need to use annotations to populate the hardware details. And with new InspectionMode, we don't need the disabled annotation either. Let's test the behavior to be able to document it. Signed-off-by: Dmitry Tantsur <[email protected]>
1 parent fe67e1a commit 064bc7a

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

test/e2e/external_inspection_test.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,79 @@ var _ = Describe("External Inspection", Label("required", "external-inspection")
249249
}, e2eConfig.GetIntervals(specName, "wait-bmh-deleted")...)
250250
})
251251

252+
It("should skip inspection and become available when HardwareData exists and BMH has inspection disabled", func() {
253+
By("Creating a secret with BMH credentials")
254+
bmcCredentialsData := map[string]string{
255+
"username": bmc.User,
256+
"password": bmc.Password,
257+
}
258+
CreateSecret(ctx, clusterProxy.GetClient(), namespace.Name, secretName, bmcCredentialsData)
259+
260+
By("pre-creating a hardware data")
261+
hwdata := metal3api.HardwareData{
262+
ObjectMeta: metav1.ObjectMeta{
263+
Name: specName + "-inspect",
264+
Namespace: namespace.Name,
265+
},
266+
Spec: metal3api.HardwareDataSpec{
267+
HardwareDetails: &metal3api.HardwareDetails{},
268+
},
269+
}
270+
err := json.Unmarshal([]byte(hardwareDetails), hwdata.Spec.HardwareDetails)
271+
Expect(err).NotTo(HaveOccurred())
272+
err = clusterProxy.GetClient().Create(ctx, &hwdata)
273+
Expect(err).NotTo(HaveOccurred())
274+
275+
By("creating a BMH with inspection disabled and hardware details added")
276+
bmh := metal3api.BareMetalHost{
277+
ObjectMeta: metav1.ObjectMeta{
278+
Name: specName + "-inspect",
279+
Namespace: namespace.Name,
280+
},
281+
Spec: metal3api.BareMetalHostSpec{
282+
BMC: metal3api.BMCDetails{
283+
Address: bmc.Address,
284+
CredentialsName: "bmc-credentials",
285+
DisableCertificateVerification: bmc.DisableCertificateVerification,
286+
},
287+
BootMode: metal3api.Legacy,
288+
BootMACAddress: bmc.BootMacAddress,
289+
InspectionMode: metal3api.InspectionModeDisabled,
290+
},
291+
}
292+
err = clusterProxy.GetClient().Create(ctx, &bmh)
293+
Expect(err).NotTo(HaveOccurred())
294+
295+
By("waiting for the BMH to become available")
296+
WaitForBmhInProvisioningState(ctx, WaitForBmhInProvisioningStateInput{
297+
Client: clusterProxy.GetClient(),
298+
Bmh: bmh,
299+
State: metal3api.StateAvailable,
300+
UndesiredStates: []metal3api.ProvisioningState{metal3api.StateInspecting},
301+
}, e2eConfig.GetIntervals(specName, "wait-available")...)
302+
303+
By("checking that the BMH was not inspected")
304+
key := types.NamespacedName{Namespace: bmh.Namespace, Name: bmh.Name}
305+
Expect(clusterProxy.GetClient().Get(ctx, key, &bmh)).To(Succeed())
306+
Expect(bmh.Status.OperationHistory.Inspect.Start.IsZero()).To(BeTrue())
307+
308+
By("checking that the hardware details match what was in hardware data")
309+
hwStatusJSON, err := json.Marshal(bmh.Status.HardwareDetails)
310+
Expect(err).NotTo(HaveOccurred())
311+
Expect(hwStatusJSON).To(MatchJSON(hardwareDetails))
312+
313+
By("Delete BMH")
314+
err = clusterProxy.GetClient().Delete(ctx, &bmh)
315+
Expect(err).NotTo(HaveOccurred())
316+
317+
By("Waiting for the BMH to be deleted")
318+
WaitForBmhDeleted(ctx, WaitForBmhDeletedInput{
319+
Client: clusterProxy.GetClient(),
320+
BmhName: bmh.Name,
321+
Namespace: bmh.Namespace,
322+
}, e2eConfig.GetIntervals(specName, "wait-bmh-deleted")...)
323+
})
324+
252325
AfterEach(func() {
253326
DumpResources(ctx, e2eConfig, clusterProxy, path.Join(artifactFolder, specName))
254327
if !skipCleanup {

0 commit comments

Comments
 (0)