From 50b2ec2add1934780ecbfb88a5570b6b8d531bbd Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Tue, 4 Jan 2022 18:07:20 +0000 Subject: [PATCH] Execute sync before taking the snapshot --- test/e2e/storage/testsuites/snapshottable.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/storage/testsuites/snapshottable.go b/test/e2e/storage/testsuites/snapshottable.go index 327d4653bdc..0519b8d7af6 100644 --- a/test/e2e/storage/testsuites/snapshottable.go +++ b/test/e2e/storage/testsuites/snapshottable.go @@ -142,7 +142,9 @@ func (s *snapshottableTestSuite) DefineTests(driver storageframework.TestDriver, ginkgo.By("[init] starting a pod to use the claim") originalMntTestData = fmt.Sprintf("hello from %s namespace", f.Namespace.Name) - command := fmt.Sprintf("echo '%s' > %s", originalMntTestData, datapath) + // After writing data to a file `sync` flushes the data from memory to disk. + // sync is available in the Linux and Windows versions of agnhost. + command := fmt.Sprintf("echo '%s' > %s; sync", originalMntTestData, datapath) pod = StartInPodWithVolumeSource(cs, *volumeResource.VolSource, f.Namespace.Name, "pvc-snapshottable-tester", command, config.ClientNodeSelection) @@ -422,7 +424,9 @@ func (s *snapshottableTestSuite) DefineTests(driver storageframework.TestDriver, ginkgo.By("modifying the data in the source PVC") - command := fmt.Sprintf("echo '%s' > %s", modifiedMntTestData, datapath) + // After writing data to a file `sync` flushes the data from memory to disk. + // sync is available in the Linux and Windows versions of agnhost. + command := fmt.Sprintf("echo '%s' > %s; sync", modifiedMntTestData, datapath) RunInPodWithVolume(cs, f.Timeouts, pvc.Namespace, pvc.Name, "pvc-snapshottable-data-tester", command, config.ClientNodeSelection) ginkgo.By("creating a pvc from the snapshot")