From ee34cd640ac7c6934acc5ecc815061c4e1c614dc Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Mon, 29 Mar 2021 22:28:59 +0000 Subject: [PATCH 1/6] enable gcpdcsi multivolume tests with windows nodes --- test/e2e/framework/pod/utils.go | 10 +--------- test/e2e/framework/volume/fixtures.go | 7 +++++++ test/e2e/storage/testsuites/multivolume.go | 4 ++-- test/e2e/storage/utils/utils.go | 18 ++++++++++++++---- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/test/e2e/framework/pod/utils.go b/test/e2e/framework/pod/utils.go index a5b9991f3ac..fb034e4b316 100644 --- a/test/e2e/framework/pod/utils.go +++ b/test/e2e/framework/pod/utils.go @@ -37,17 +37,9 @@ func NodeOSDistroIs(distro string) bool { } // GenerateScriptCmd generates the corresponding command lines to execute a command. -// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh func GenerateScriptCmd(command string) []string { var commands []string - if command == "" { - return commands - } - if !NodeOSDistroIs("windows") { - commands = []string{"/bin/sh", "-c", command} - } else { - commands = []string{"powershell", "/c", command} - } + commands = []string{"/bin/sh", "-c", command} return commands } diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 7c9842eec83..f91fccedf86 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -619,6 +619,13 @@ func generateWriteFileCmd(content, fullPath string) []string { // CheckVolumeModeOfPath check mode of volume func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { + // in windows a symlink is created instead of mounting a volume + // we just check if the symlink exists + if framework.NodeOSDistroIs("windows") { + VerifyExecInPodSucceed(f, pod, fmt.Sprintf("ls %s", path)) + return + } + if volMode == v1.PersistentVolumeBlock { // Check if block exists VerifyExecInPodSucceed(f, pod, fmt.Sprintf("test -b %s", path)) diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index e3ab2793b3d..c0c80010efd 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -132,7 +132,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p // [ node1 ] ==> [ node1 ] // / \ <- same volume mode / \ // [volume1] [volume2] [volume1] [volume2] - ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on the same node [LinuxOnly]", func() { + ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on the same node", func() { // Currently, multiple volumes are not generally available for pre-provisoined volume, // because containerized storage servers, such as iSCSI and rbd, are just returning // a static volume inside container, not actually creating a new volume per request. @@ -510,7 +510,7 @@ func testAccessMultipleVolumes(f *framework.Framework, cs clientset.Interface, n // CreateSecPodWithNodeSelection make volumes accessible via /mnt/volume({i} + 1) index := i + 1 path := fmt.Sprintf("/mnt/volume%d", index) - ginkgo.By(fmt.Sprintf("Checking if the volume%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode)) + ginkgo.By(fmt.Sprintf("Checking if the volume=%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode)) e2evolume.CheckVolumeModeOfPath(f, pod, *pvc.Spec.VolumeMode, path) if readSeedBase > 0 { diff --git a/test/e2e/storage/utils/utils.go b/test/e2e/storage/utils/utils.go index 50b1f6eca0f..b657c397763 100644 --- a/test/e2e/storage/utils/utils.go +++ b/test/e2e/storage/utils/utils.go @@ -543,8 +543,13 @@ func CheckReadFromPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persisten sum := sha256.Sum256(genBinDataFromSeed(len, seed)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum)) + if framework.NodeOSDistroIs("windows") { + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum", pathForVolMode)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum | grep -Fq %x", pathForVolMode, sum)) + } else { + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum)) + } } // CheckWriteToPath that file can be properly written. @@ -568,8 +573,13 @@ func CheckWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persistent encoded := base64.StdEncoding.EncodeToString(genBinDataFromSeed(len, seed)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len)) + if framework.NodeOSDistroIs("windows") { + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d > %s", encoded, pathForVolMode)) + } else { + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len)) + } } // GetSectorSize returns the sector size of the device. From 54070a6628490ca0a9eb2337ea036018ffdc6d7f Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Mon, 29 Mar 2021 23:32:20 +0000 Subject: [PATCH 2/6] Enable another test in windows, use a /bin/sh command instead of a PS one --- test/e2e/framework/volume/fixtures.go | 6 +----- test/e2e/storage/testsuites/multivolume.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index f91fccedf86..9c324928499 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -368,11 +368,7 @@ func runVolumeTesterPod(client clientset.Interface, timeouts *framework.TimeoutC var gracePeriod int64 = 1 var command string - if !framework.NodeOSDistroIs("windows") { - command = "while true ; do sleep 2; done " - } else { - command = "while(1) {sleep 2}" - } + command = "while true ; do sleep 2; done " seLinuxOptions := &v1.SELinuxOptions{Level: "s0:c0,c1"} clientPod := &v1.Pod{ TypeMeta: metav1.TypeMeta{ diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index c0c80010efd..9e170422637 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -292,7 +292,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p // [ node1 ] // \ / <- same volume mode // [volume1] - ginkgo.It("should concurrently access the single volume from pods on the same node [LinuxOnly]", func() { + ginkgo.It("should concurrently access the single volume from pods on the same node", func() { init() defer cleanup() From 9a146bc3e99541074f375d24106d4177e8fe2334 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Tue, 30 Mar 2021 00:10:21 +0000 Subject: [PATCH 3/6] Remove [LinuxOnly] string from ginkgo tests --- test/e2e/storage/testsuites/multivolume.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index 9e170422637..256ad70c675 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -162,7 +162,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p // [ node1 ] ==> [ node2 ] // / \ <- same volume mode / \ // [volume1] [volume2] [volume1] [volume2] - ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on different node [LinuxOnly]", func() { + ginkgo.It("should access to two volumes with the same volume mode and retain data across pod recreation on different node", func() { // Currently, multiple volumes are not generally available for pre-provisoined volume, // because containerized storage servers, such as iSCSI and rbd, are just returning // a static volume inside container, not actually creating a new volume per request. @@ -203,7 +203,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p // [ node1 ] ==> [ node1 ] // / \ <- different volume mode / \ // [volume1] [volume2] [volume1] [volume2] - ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on the same node [LinuxOnly]", func() { + ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on the same node", func() { if pattern.VolMode == v1.PersistentVolumeFilesystem { e2eskipper.Skipf("Filesystem volume case should be covered by block volume case -- skipping") } @@ -242,7 +242,7 @@ func (t *multiVolumeTestSuite) DefineTests(driver storageframework.TestDriver, p // [ node1 ] ==> [ node2 ] // / \ <- different volume mode / \ // [volume1] [volume2] [volume1] [volume2] - ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on different node [LinuxOnly]", func() { + ginkgo.It("should access to two volumes with different volume mode and retain data across pod recreation on different node", func() { if pattern.VolMode == v1.PersistentVolumeFilesystem { e2eskipper.Skipf("Filesystem volume case should be covered by block volume case -- skipping") } From f0d7e9c9d1d0ff1c45d0eec2f8fa4a925ef33a1d Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Wed, 31 Mar 2021 16:46:54 +0000 Subject: [PATCH 4/6] undo windows compatibility changes because the linux commands work --- test/e2e/framework/volume/fixtures.go | 10 +++------- test/e2e/storage/testsuites/multivolume.go | 2 +- test/e2e/storage/utils/utils.go | 18 ++++-------------- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 9c324928499..34673e2df9b 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -615,14 +615,10 @@ func generateWriteFileCmd(content, fullPath string) []string { // CheckVolumeModeOfPath check mode of volume func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { - // in windows a symlink is created instead of mounting a volume - // we just check if the symlink exists - if framework.NodeOSDistroIs("windows") { - VerifyExecInPodSucceed(f, pod, fmt.Sprintf("ls %s", path)) - return - } - if volMode == v1.PersistentVolumeBlock { + // NOTE: gcepd-csi doesn't support a block volume in windows, this method won't + // be called because the test is skipped + // Check if block exists VerifyExecInPodSucceed(f, pod, fmt.Sprintf("test -b %s", path)) diff --git a/test/e2e/storage/testsuites/multivolume.go b/test/e2e/storage/testsuites/multivolume.go index 256ad70c675..7e3e8dea28e 100644 --- a/test/e2e/storage/testsuites/multivolume.go +++ b/test/e2e/storage/testsuites/multivolume.go @@ -510,7 +510,7 @@ func testAccessMultipleVolumes(f *framework.Framework, cs clientset.Interface, n // CreateSecPodWithNodeSelection make volumes accessible via /mnt/volume({i} + 1) index := i + 1 path := fmt.Sprintf("/mnt/volume%d", index) - ginkgo.By(fmt.Sprintf("Checking if the volume=%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode)) + ginkgo.By(fmt.Sprintf("Checking if the volume%d exists as expected volume mode (%s)", index, *pvc.Spec.VolumeMode)) e2evolume.CheckVolumeModeOfPath(f, pod, *pvc.Spec.VolumeMode, path) if readSeedBase > 0 { diff --git a/test/e2e/storage/utils/utils.go b/test/e2e/storage/utils/utils.go index b657c397763..50b1f6eca0f 100644 --- a/test/e2e/storage/utils/utils.go +++ b/test/e2e/storage/utils/utils.go @@ -543,13 +543,8 @@ func CheckReadFromPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persisten sum := sha256.Sum256(genBinDataFromSeed(len, seed)) - if framework.NodeOSDistroIs("windows") { - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum", pathForVolMode)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("cat %s | sha256sum | grep -Fq %x", pathForVolMode, sum)) - } else { - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum)) - } + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum", pathForVolMode, iflag, len)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("dd if=%s %s bs=%d count=1 | sha256sum | grep -Fq %x", pathForVolMode, iflag, len, sum)) } // CheckWriteToPath that file can be properly written. @@ -573,13 +568,8 @@ func CheckWriteToPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persistent encoded := base64.StdEncoding.EncodeToString(genBinDataFromSeed(len, seed)) - if framework.NodeOSDistroIs("windows") { - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d > %s", encoded, pathForVolMode)) - } else { - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) - e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len)) - } + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | sha256sum", encoded)) + e2evolume.VerifyExecInPodSucceed(f, pod, fmt.Sprintf("echo %s | base64 -d | dd of=%s %s bs=%d count=1", encoded, pathForVolMode, oflag, len)) } // GetSectorSize returns the sector size of the device. From 7aa8a497df0145dc0f5f2395f221ae10cb485dd1 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Mon, 5 Apr 2021 18:19:27 +0000 Subject: [PATCH 5/6] replaced usage of powershell commands with linux commands --- test/e2e/framework/volume/fixtures.go | 3 --- test/e2e/storage/testsuites/provisioning.go | 6 ++---- test/e2e/storage/testsuites/subpath.go | 6 +----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 34673e2df9b..9af6d3cdd35 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -616,9 +616,6 @@ func generateWriteFileCmd(content, fullPath string) []string { // CheckVolumeModeOfPath check mode of volume func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.PersistentVolumeMode, path string) { if volMode == v1.PersistentVolumeBlock { - // NOTE: gcepd-csi doesn't support a block volume in windows, this method won't - // be called because the test is skipped - // Check if block exists VerifyExecInPodSucceed(f, pod, fmt.Sprintf("test -b %s", path)) diff --git a/test/e2e/storage/testsuites/provisioning.go b/test/e2e/storage/testsuites/provisioning.go index cc98a412eba..08c7db678fb 100644 --- a/test/e2e/storage/testsuites/provisioning.go +++ b/test/e2e/storage/testsuites/provisioning.go @@ -551,7 +551,8 @@ func PVWriteReadSingleNodeCheck(client clientset.Interface, timeouts *framework. command += " || (mount | grep 'on /mnt/test'; false)" if framework.NodeOSDistroIs("windows") { - command = "select-string 'hello world' /mnt/test/data" + // agnhost doesn't support mount + command = "grep 'hello world' /mnt/test/data" } RunInPodWithVolume(client, timeouts, claim.Namespace, claim.Name, "pvc-volume-tester-reader", command, e2epod.NodeSelection{Name: actualNodeName}) @@ -596,9 +597,6 @@ func PVMultiNodeCheck(client clientset.Interface, timeouts *framework.TimeoutCon e2epod.SetAntiAffinity(&secondNode, actualNodeName) ginkgo.By(fmt.Sprintf("checking the created volume is readable and retains data on another node %+v", secondNode)) command = "grep 'hello world' /mnt/test/data" - if framework.NodeOSDistroIs("windows") { - command = "select-string 'hello world' /mnt/test/data" - } pod = StartInPodWithVolume(client, claim.Namespace, claim.Name, "pvc-reader-node2", command, secondNode) framework.ExpectNoError(e2epod.WaitForPodSuccessInNamespaceTimeout(client, pod.Name, pod.Namespace, timeouts.PodStartSlow)) runningPod, err = client.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{}) diff --git a/test/e2e/storage/testsuites/subpath.go b/test/e2e/storage/testsuites/subpath.go index 99394d78a48..4f6b10faddd 100644 --- a/test/e2e/storage/testsuites/subpath.go +++ b/test/e2e/storage/testsuites/subpath.go @@ -323,11 +323,7 @@ func (s *subPathTestSuite) DefineTests(driver storageframework.TestDriver, patte // Create the directory var command string - if framework.NodeOSDistroIs("windows") { - command = fmt.Sprintf("mkdir -p %v; New-Item -itemtype File -path %v", l.subPathDir, probeFilePath) - } else { - command = fmt.Sprintf("mkdir -p %v; touch %v", l.subPathDir, probeFilePath) - } + command = fmt.Sprintf("mkdir -p %v; touch %v", l.subPathDir, probeFilePath) setInitCommand(l.pod, command) testPodContainerRestart(f, l.pod) }) From 6583b05f07b777b3edbf5a95ef1706b0b8929594 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Thu, 29 Apr 2021 17:45:45 +0000 Subject: [PATCH 6/6] replace more powershell commands with /bin/sh in volume/fixtures.go --- test/e2e/framework/volume/fixtures.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 9af6d3cdd35..f13a5cb2fe9 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -568,47 +568,30 @@ func InjectContent(f *framework.Framework, config TestConfig, fsGroup *int64, fs // generateWriteCmd is used by generateWriteBlockCmd and generateWriteFileCmd func generateWriteCmd(content, path string) []string { var commands []string - if !framework.NodeOSDistroIs("windows") { - commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path} - } else { - commands = []string{"powershell", "/c", "echo '" + content + "' > " + path} - } + commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path} return commands } // generateReadBlockCmd generates the corresponding command lines to read from a block device with the given file path. -// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh func generateReadBlockCmd(fullPath string, numberOfCharacters int) []string { var commands []string - if !framework.NodeOSDistroIs("windows") { - commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath} - } else { - // TODO: is there a way on windows to get the first X bytes from a device? - commands = []string{"powershell", "/c", "type " + fullPath} - } + commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath} return commands } // generateWriteBlockCmd generates the corresponding command lines to write to a block device the given content. -// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh func generateWriteBlockCmd(content, fullPath string) []string { return generateWriteCmd(content, fullPath) } // GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path. -// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh func GenerateReadFileCmd(fullPath string) []string { var commands []string - if !framework.NodeOSDistroIs("windows") { - commands = []string{"cat", fullPath} - } else { - commands = []string{"powershell", "/c", "type " + fullPath} - } + commands = []string{"cat", fullPath} return commands } // generateWriteFileCmd generates the corresponding command lines to write a file with the given content and file path. -// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh func generateWriteFileCmd(content, fullPath string) []string { return generateWriteCmd(content, fullPath) }