47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package app
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
"github.com/Nwflower/reims-go/internal/macos/reims"
|
|
"github.com/Nwflower/reims-go/internal/vmstart"
|
|
)
|
|
|
|
func TestBuildVMAffinityStatus(t *testing.T) {
|
|
dir := t.TempDir()
|
|
eco := true
|
|
if _, err := vmstart.SaveVMAffinity(dir, vmstart.VMAffinityConfig{
|
|
Mode: vmstart.AffinityCustom,
|
|
CPUs: []int{0, 2, 4, 6},
|
|
DisableEcoQoS: &eco,
|
|
}, 16); err != nil {
|
|
t.Fatalf("SaveVMAffinity: %v", err)
|
|
}
|
|
|
|
rep := host.Report{LogicalCPUs: 16}
|
|
st := buildVMAffinityStatus(reims.VMDetail{
|
|
Name: "test-vm",
|
|
Directory: dir,
|
|
CPUs: 6,
|
|
State: "stopped",
|
|
}, rep, true, 0)
|
|
|
|
if st.Mode != "custom" || st.EffectiveMode != "custom" {
|
|
t.Fatalf("modes = (%s, %s), want custom", st.Mode, st.EffectiveMode)
|
|
}
|
|
if !reflect.DeepEqual(st.EffectiveCPUs, []int{0, 2, 4, 6}) {
|
|
t.Fatalf("EffectiveCPUs = %v", st.EffectiveCPUs)
|
|
}
|
|
if st.EffectiveMaskHex != "0x55" {
|
|
t.Fatalf("EffectiveMaskHex = %s, want 0x55", st.EffectiveMaskHex)
|
|
}
|
|
if !st.Oversubscribed {
|
|
t.Fatalf("expected Oversubscribed=true for 4 CPUs < 6 vCPUs")
|
|
}
|
|
if !st.DisableEcoQoS {
|
|
t.Fatalf("expected DisableEcoQoS=true")
|
|
}
|
|
}
|