Skip to content

Commit

Permalink
Merge pull request #100154 from jsturtevant/windows-volume-tests
Browse files Browse the repository at this point in the history
[sig-windows] Write to unique file to avoid conflicts with other tests
  • Loading branch information
k8s-ci-robot committed Mar 12, 2021
2 parents a8ac0c9 + 5dacb7b commit 251177e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions test/e2e/windows/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ func doReadOnlyTest(f *framework.Framework, source v1.VolumeSource, volumePath s

cmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}

ginkgo.By("verifying that pod will get an error when writing to a volume that is readonly")
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)

framework.ExpectEqual(stderr, "Access is denied.")
}

func doReadWriteReadOnlyTest(f *framework.Framework, source v1.VolumeSource, volumePath string) {
var (
filePath = volumePath + "\\test-file"
filePath = volumePath + "\\test-file" + string(uuid.NewUUID())
podName = "pod-" + string(uuid.NewUUID())
pod = testPodWithROVolume(podName, source, volumePath)
rwcontainerName = containerName + "-rw"
Expand All @@ -133,15 +133,17 @@ func doReadWriteReadOnlyTest(f *framework.Framework, source v1.VolumeSource, vol
ginkgo.By("verifying that pod has the correct nodeSelector")
framework.ExpectEqual(pod.Spec.NodeSelector["kubernetes.io/os"], "windows")

cmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}

stdoutRW, stderrRW, errRW := f.ExecCommandInContainerWithFullOutput(podName, rwcontainerName, cmd...)
msg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", cmd, stdoutRW, stderrRW)
ginkgo.By("verifying that pod can write to a volume with read/write access")
writecmd := []string{"cmd", "/c", "echo windows-volume-test", ">", filePath}
stdoutRW, stderrRW, errRW := f.ExecCommandInContainerWithFullOutput(podName, rwcontainerName, writecmd...)
msg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", writecmd, stdoutRW, stderrRW)
framework.ExpectNoError(errRW, msg)

_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)
ginkgo.By("verifying that pod will get an error when writing to a volume that is readonly")
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, writecmd...)
framework.ExpectEqual(stderr, "Access is denied.")

ginkgo.By("verifying that pod can read from the the volume that is readonly")
readcmd := []string{"cmd", "/c", "type", filePath}
readout, readerr, err := f.ExecCommandInContainerWithFullOutput(podName, containerName, readcmd...)
readmsg := fmt.Sprintf("cmd: %v, stdout: %q, stderr: %q", readcmd, readout, readerr)
Expand Down

0 comments on commit 251177e

Please sign in to comment.