add test 'check guest memory different from requested memory'
@@ -347,6 +347,49 @@ var _ = Describe("Configurations", func() {
Expect(err).ToNot(HaveOccurred())
})
+ })
+
+ Context("[rfe_id:140][crit:medium][vendor:cnv-qe@redhat.com][level:component]with support memory over commitment", func() {
+ It("[test_id:755]should show the requested memory different than guest memory", func() {
+ vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n")
+ guestMemory := resource.MustParse("256Mi")
+ vmi.Spec.Domain.Resources.Requests[kubev1.ResourceMemory] = resource.MustParse("64Mi")
+ vmi.Spec.Domain.Resources.OvercommitGuestOverhead = true
+ vmi.Spec.Domain.Memory = &v1.Memory{
+ Guest: &guestMemory,
+ }
+
+ vmi, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
+ Expect(err).ToNot(HaveOccurred())
+ tests.WaitForSuccessfulVMIStart(vmi)
+
+ expecter, err := tests.LoggedInCirrosExpecter(vmi)
+ Expect(err).ToNot(HaveOccurred())
+ defer expecter.Close()
+
+ res, err := expecter.ExpectBatch([]expect.Batcher{
+ &expect.BSnd{S: "free -m | grep Mem: | tr -s ' ' | cut -d' ' -f2\n"},
+ &expect.BExp{R: "236"},
+ &expect.BSnd{S: "swapoff -a && dd if=/dev/zero of=/dev/shm/test bs=1k count=118k; echo $?\n"},
+ &expect.BExp{R: "0"},
+ }, 20*time.Second)
+ log.DefaultLogger().Object(vmi).Infof("%v", res)
+ Expect(err).ToNot(HaveOccurred())
+
+ pod := tests.GetRunningPodByVirtualMachineInstance(vmi, tests.NamespaceTestDefault)
+ podMemoryUsage, err := tests.ExecuteCommandOnPod(
+ virtClient,
+ pod,
+ "compute",
+ []string{"/usr/bin/bash", "-c", "cat /sys/fs/cgroup/memory/memory.usage_in_bytes"},
+ )
+ Expect(err).ToNot(HaveOccurred())
+
+ By("Checking if pod memory usage is > 64Mi")
+ m, err := strconv.Atoi(strings.Trim(podMemoryUsage, "\n"))
+ Expect(err).ToNot(HaveOccurred())
+ Expect(m > 67108864).To(BeTrue())
+ })
})
