Skip to content

Commit

Permalink
test: assert power on/off status in static infra provider tests
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
utkuozdemir committed Dec 11, 2024
1 parent 8aeff65 commit 5267f3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/integration-test/pkg/tests/infra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
Expand All @@ -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)
})
Expand Down

0 comments on commit 5267f3d

Please sign in to comment.