Skip to content

Commit 251177e

Browse files
authored
Merge pull request kubernetes#100154 from jsturtevant/windows-volume-tests
[sig-windows] Write to unique file to avoid conflicts with other tests
2 parents a8ac0c9 + 5dacb7b commit 251177e

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

test/e2e/windows/volumes.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ func doReadOnlyTest(f *framework.Framework, source v1.VolumeSource, volumePath s
100100

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

103+
ginkgo.By("verifying that pod will get an error when writing to a volume that is readonly")
103104
_, stderr, _ := f.ExecCommandInContainerWithFullOutput(podName, containerName, cmd...)
104-
105105
framework.ExpectEqual(stderr, "Access is denied.")
106106
}
107107

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

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

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

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

0 commit comments

Comments
 (0)