Fix size checks in storage test
With some provisioners, files can be over-allocated. Thus checking for
exactly 1G size of images can cause tests to fail.
@@ -363,7 +363,7 @@ var _ = Describe("Storage", func() {
virtClient,
vmiPod,
vmiPod.Spec.Containers[0].Name,
- []string{"find", hostdisk.GetMountedHostDiskDir("host-disk"), "-name", diskName, "-size", "1G"},
+ []string{"find", hostdisk.GetMountedHostDiskDir("host-disk"), "-name", diskName, "-size", "1G", "-o", "-size", "+1G"},
)
Expect(err).ToNot(HaveOccurred())
Expect(output).To(ContainSubstring(hostdisk.GetMountedHostDiskPath("host-disk", diskPath)))
@@ -386,7 +386,7 @@ var _ = Describe("Storage", func() {
virtClient,
vmiPod,
vmiPod.Spec.Containers[0].Name,
- []string{"find", hostdisk.GetMountedHostDiskDir("anotherdisk"), "-size", "1G"},
+ []string{"find", hostdisk.GetMountedHostDiskDir("anotherdisk"), "-size", "1G", "-o", "-size", "+1G"},
)
Expect(err).ToNot(HaveOccurred())
Expect(output).To(ContainSubstring(hostdisk.GetMountedHostDiskPath("anotherdisk", filepath.Join(hostDiskDir, "another.img"))))
@@ -396,7 +396,7 @@ var _ = Describe("Storage", func() {
virtClient,
vmiPod,
vmiPod.Spec.Containers[0].Name,
- []string{"find", hostdisk.GetMountedHostDiskDir("host-disk"), "-size", "1G"},
+ []string{"find", hostdisk.GetMountedHostDiskDir("host-disk"), "-size", "1G", "-o", "-size", "+1G"},
)
Expect(err).ToNot(HaveOccurred())
Expect(output).To(ContainSubstring(hostdisk.GetMountedHostDiskPath("host-disk", diskPath)))
@@ -493,12 +493,14 @@ var _ = Describe("Storage", func() {
By("Checking if disk.img exists")
vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmi, tests.NamespaceTestDefault)
- output, _ := tests.ExecuteCommandOnPod(
+ output, err := tests.ExecuteCommandOnPod(
virtClient,
vmiPod,
vmiPod.Spec.Containers[0].Name,
- []string{"find", "/var/run/kubevirt-private/vmi-disks/disk0/", "-name", "disk.img", "-size", "1G"},
+ []string{"find", "/var/run/kubevirt-private/vmi-disks/disk0/", "-name", "disk.img", "-size", "1G", "-o", "-size", "+1G"},
)
+ Expect(err).ToNot(HaveOccurred())
+
By("Checking if a disk image for PVC has been created")
Expect(strings.Contains(output, "disk.img")).To(BeTrue())
}
