From 5267f3d128c6412c5d3877164a53c39e4c9e327e Mon Sep 17 00:00:00 2001 From: Utku Ozdemir Date: Wed, 11 Dec 2024 23:52:07 +0100 Subject: [PATCH] test: assert power on/off status in static infra provider tests As the bare-metal infra provider gets power management implemented, we assert the power state of the infra machines in the tests. Signed-off-by: Utku Ozdemir --- cmd/integration-test/pkg/tests/infra.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/integration-test/pkg/tests/infra.go b/cmd/integration-test/pkg/tests/infra.go index 46207db6..77003e70 100644 --- a/cmd/integration-test/pkg/tests/infra.go +++ b/cmd/integration-test/pkg/tests/infra.go @@ -251,8 +251,9 @@ func AcceptInfraMachines(testCtx context.Context, omniState state.State, expecte assertion.True(isManagedByStaticInfraProvider) }) - // Assert that infra.MachineStatus resources are now created, and they are marked as ready to use + // Assert that infra.MachineStatus resources are now created, they are powered off and are marked as ready to use rtestutils.AssertResources(ctx, t, omniState, ids, func(res *infra.MachineStatus, assertion *assert.Assertions) { + assertion.Equal(specs.InfraMachineStatusSpec_POWER_STATE_OFF, res.TypedSpec().Value.PowerState) assertion.True(res.TypedSpec().Value.ReadyToUse) }) } @@ -273,19 +274,20 @@ func AssertInfraMachinesAreAllocated(testCtx context.Context, omniState state.St for machineSetNode := range nodeList.All() { id := machineSetNode.Metadata().ID() - // there must be an infra.Machine resource for each node + // There must be an infra.Machine resource for each node rtestutils.AssertResource[*infra.Machine](ctx, t, omniState, id, func(res *infra.Machine, assertion *assert.Assertions) { assertion.Equal(talosVersion, res.TypedSpec().Value.ClusterTalosVersion) assertion.Empty(res.TypedSpec().Value.WipeId) assertion.Equal(extensions, res.TypedSpec().Value.Extensions) }) - // machine is allocated, so the ReadyToUse field is set to false + // The machine is allocated, so the ReadyToUse field is set to false rtestutils.AssertResource[*infra.MachineStatus](ctx, t, omniState, id, func(res *infra.MachineStatus, assertion *assert.Assertions) { + assertion.Equal(specs.InfraMachineStatusSpec_POWER_STATE_ON, res.TypedSpec().Value.PowerState) assertion.False(res.TypedSpec().Value.ReadyToUse) }) - // omni receives a SequenceEvent from the SideroLink event sink and sets the Installed field to true + // Omni receives a SequenceEvent from the SideroLink event sink and sets the Installed field to true rtestutils.AssertResource[*infra.MachineState](ctx, t, omniState, id, func(res *infra.MachineState, assertion *assert.Assertions) { assertion.True(res.TypedSpec().Value.Installed) })