mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-09 16:25:40 +02:00
Simplify state reconciliation and support changing Softnet settings (#364)
* Simplify state reconciliation and support changing Softnet settings * Remove unused "updateFunc" parameter from syncOnDiskVMs() * Don't take an address of a loop variable * ensure → ensures * updateVMState(): don't forget to update VMState * Introduce TestSpecUpdateSoftnet integration test * Update OpenAPI specification to include generation/observedGeneration
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/cirruslabs/orchard/internal/worker/ondiskname"
|
||||
"github.com/cirruslabs/orchard/internal/worker/vmmanager"
|
||||
v1 "github.com/cirruslabs/orchard/pkg/resource/v1"
|
||||
"github.com/samber/lo"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSortNonExistentAndFailedFirst(t *testing.T) {
|
||||
newVMTuple := func(name string, vmResource *v1.VM) lo.Tuple3[ondiskname.OnDiskName, *v1.VM, *vmmanager.VM] {
|
||||
return lo.T3(ondiskname.New(name, name, 0), vmResource, &vmmanager.VM{})
|
||||
}
|
||||
|
||||
target := []lo.Tuple3[ondiskname.OnDiskName, *v1.VM, *vmmanager.VM]{
|
||||
newVMTuple("test1", &v1.VM{Status: v1.VMStatusFailed}),
|
||||
newVMTuple("test2", &v1.VM{Status: v1.VMStatusPending}),
|
||||
newVMTuple("test3", &v1.VM{Status: v1.VMStatusRunning}),
|
||||
newVMTuple("test5", nil),
|
||||
newVMTuple("test4", &v1.VM{Status: v1.VMStatusFailed}),
|
||||
}
|
||||
|
||||
sortNonExistentAndFailedFirst(target)
|
||||
|
||||
expected := []lo.Tuple3[ondiskname.OnDiskName, *v1.VM, *vmmanager.VM]{
|
||||
newVMTuple("test5", nil),
|
||||
newVMTuple("test1", &v1.VM{Status: v1.VMStatusFailed}),
|
||||
newVMTuple("test4", &v1.VM{Status: v1.VMStatusFailed}),
|
||||
newVMTuple("test2", &v1.VM{Status: v1.VMStatusPending}),
|
||||
newVMTuple("test3", &v1.VM{Status: v1.VMStatusRunning}),
|
||||
}
|
||||
|
||||
require.Equal(t, expected, target)
|
||||
}
|
||||
Reference in New Issue
Block a user