Skip to content

Commit

Permalink
tests, Update Default VMI memory request to 128Mi
Browse files Browse the repository at this point in the history
As suggested by Cirros community [1],
increase default VMI memory to be 128Mi
instead of 8Mi or 64Mi in the specific
functions that create VMI template and update
the memory request to 64M.

Use the right notation of Mi instead of M.

Remove duplicate memory settings in order
to make code lighter.

[1] cirros-dev/cirros#52 (comment)

Signed-off-by: Or Shoval <[email protected]>
  • Loading branch information
oshoval committed Feb 25, 2021
1 parent 3b8ed60 commit a80bb3c
Show file tree
Hide file tree
Showing 23 changed files with 45 additions and 109 deletions.
2 changes: 1 addition & 1 deletion examples/vm-alpine-datavolume.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- dataVolume:
Expand Down
2 changes: 1 addition & 1 deletion examples/vm-alpine-multipvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- name: pvcdisk1
Expand Down
2 changes: 1 addition & 1 deletion examples/vm-cirros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vm-priorityclass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
priorityClassName: non-preemtible
terminationGracePeriodSeconds: 0
volumes:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-block-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- name: blockpvcdisk
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-ephemeral.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-flavor-small.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-host-disk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- hostDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-migratable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
networks:
- name: default
pod: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-nocloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-preset-small.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
selector:
matchLabels:
kubevirt.io/vmPreset: vmi-preset-small
2 changes: 1 addition & 1 deletion examples/vmi-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- name: pvcdisk
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-replicaset-cirros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion examples/vmi-sata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
type: ""
resources:
requests:
memory: 64M
memory: 128Mi
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
Expand Down
2 changes: 1 addition & 1 deletion tests/libvmi/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewCirros(opts ...Option) *kvirtv1.VirtualMachineInstance {
cirrosOpts := []Option{
WithContainerImage(cd.ContainerDiskFor(cd.ContainerDiskCirros)),
WithCloudInitNoCloudUserData("#!/bin/bash\necho 'hello'\n", true),
WithResourceMemory("64M"),
WithResourceMemory("128Mi"),
WithTerminationGracePeriod(DefaultTestGracePeriod),
}
cirrosOpts = append(cirrosOpts, opts...)
Expand Down
6 changes: 3 additions & 3 deletions tests/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,16 @@ var _ = Describe("[Serial]VirtualMachineRestore Tests", func() {
Expect(err).ToNot(HaveOccurred())

origSpec = vm.Spec.DeepCopy()
Expect(origSpec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory]).To(Equal(resource.MustParse("64M")))
Expect(origSpec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory]).To(Equal(resource.MustParse("128Mi")))

vm.Spec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory] = resource.MustParse("128M")
vm.Spec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory] = resource.MustParse("256Mi")
updatedVM, err = virtClient.VirtualMachine(vm.Namespace).Update(vm)
if errors.IsConflict(err) {
return false
}
vm = updatedVM
Expect(err).ToNot(HaveOccurred())
Expect(vm.Spec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory]).To(Equal(resource.MustParse("128M")))
Expect(vm.Spec.Template.Spec.Domain.Resources.Requests[corev1.ResourceMemory]).To(Equal(resource.MustParse("256Mi")))
return true
}, 180*time.Second, time.Second).Should(BeTrue())

Expand Down
12 changes: 4 additions & 8 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,15 +1917,14 @@ func NewRandomVMIWithNS(namespace string) *v1.VirtualMachineInstance {
Masquerade: &v1.InterfaceMasquerade{}}}}}

vmi.Spec.Networks = []v1.Network{*v1.DefaultPodNetwork()}
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("128Mi")

return vmi
}

func NewRandomVMIWithDataVolume(dataVolumeName string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

diskName := "disk0"
bus := "virtio"
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Expand Down Expand Up @@ -2089,7 +2088,6 @@ func NewRandomMigration(vmiName string, namespace string) *v1.VirtualMachineInst
func NewRandomVMIWithEphemeralDisk(containerImage string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")
AddEphemeralDisk(vmi, "disk0", "virtio", containerImage)
if containerImage == cd.ContainerDiskFor(cd.ContainerDiskFedora) {
vmi.Spec.Domain.Devices.Rng = &v1.Rng{} // newer fedora kernels may require hardware RNG to boot
Expand Down Expand Up @@ -2231,7 +2229,7 @@ func NewRandomVMIWithFSFromDataVolume(dataVolumeName string) *v1.VirtualMachineI

func NewRandomVMIWithPVCFS(claimName string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

containerImage := cd.ContainerDiskFor(cd.ContainerDiskFedoraTestTooling)
AddEphemeralDisk(vmi, "disk0", "virtio", containerImage)
vmi = AddPVCFS(vmi, "disk1", claimName)
Expand Down Expand Up @@ -2342,14 +2340,14 @@ func addCloudInitDiskAndVolume(vmi *v1.VirtualMachineInstance, name string, volu

func NewRandomVMIWithPVC(claimName string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

vmi = AddPVCDisk(vmi, "disk0", "virtio", claimName)
return vmi
}

func NewRandomVMIWithPVCAndUserData(claimName, userData string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()
vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

vmi = AddPVCDisk(vmi, "disk0", "virtio", claimName)
AddUserData(vmi, "disk1", userData)
return vmi
Expand Down Expand Up @@ -2467,7 +2465,6 @@ func deleteBlockPVAndPVC() {
func NewRandomVMIWithCDRom(claimName string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Name: "disk0",
DiskDevice: v1.DiskDevice{
Expand All @@ -2492,7 +2489,6 @@ func NewRandomVMIWithCDRom(claimName string) *v1.VirtualMachineInstance {
func NewRandomVMIWithEphemeralPVC(claimName string) *v1.VirtualMachineInstance {
vmi := NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Name: "disk0",
DiskDevice: v1.DiskDevice{
Expand Down
4 changes: 0 additions & 4 deletions tests/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,6 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:[email protected]][level:com

vmi := tests.NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

diskName := "disk0"
bus := "virtio"
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Expand Down Expand Up @@ -205,8 +203,6 @@ var _ = Describe("[rfe_id:1177][crit:medium][vendor:[email protected]][level:com

vmi := tests.NewRandomVMI()

vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceMemory] = resource.MustParse("64M")

diskName := "disk0"
bus := "virtio"
vmi.Spec.Domain.Devices.Disks = append(vmi.Spec.Domain.Devices.Disks, v1.Disk{
Expand Down
Loading

0 comments on commit a80bb3c

Please sign in to comment.