Skip to content

Commit a54eada

Browse files
Test fixes
1 parent 0252935 commit a54eada

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

internal/controller/hypervisor_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ var _ = Describe("Hypervisor Controller", func() {
122122
SupportedCpuModes: []string{"mode/example", "mode/example/1"},
123123
}, nil
124124
},
125+
GetAllocatedResourcesFunc: func() (map[string]resource.Quantity, error) {
126+
return map[string]resource.Quantity{
127+
"memory": *resource.NewQuantity(4096, resource.BinarySI),
128+
"cpu": *resource.NewQuantity(2, resource.DecimalSI),
129+
}, nil
130+
},
125131
},
126132
Systemd: &systemd.InterfaceMock{
127133
CloseFunc: func() {},

internal/emulator/libvirt.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
v1 "github.com/cobaltcore-dev/openstack-hypervisor-operator/api/v1"
2424
golibvirt "github.com/digitalocean/go-libvirt"
25+
"k8s.io/apimachinery/pkg/api/resource"
2526
logger "sigs.k8s.io/controller-runtime/pkg/log"
2627

2728
"github.com/cobaltcore-dev/kvm-node-agent/internal/libvirt"
@@ -62,6 +63,13 @@ func NewLibVirtEmulator(ctx context.Context) *libvirt.InterfaceMock {
6263
GetDomainCapabilitiesFunc: func() (v1.DomainCapabilities, error) {
6364
return domcapabilities.NewClientEmulator().Get(nil)
6465
},
66+
GetAllocatedResourcesFunc: func() (map[string]resource.Quantity, error) {
67+
log.Info("GetAllocatedResourcesFunc Func called")
68+
return map[string]resource.Quantity{
69+
"cpu": resource.MustParse("4"),
70+
"memory": resource.MustParse("8192Mi"),
71+
}, nil
72+
},
6573
}
6674
return mockedInterface
6775
}

0 commit comments

Comments
 (0)