mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #100548 from mauriciopoppe/ephemeral-storage-e2e-windows
Make ephemeral volume tests work with Windows nodes
This commit is contained in:
commit
2f6d79ca88
@ -638,9 +638,6 @@ func CheckVolumeModeOfPath(f *framework.Framework, pod *v1.Pod, volMode v1.Persi
|
|||||||
// TODO: put this under e2epod once https://github.com/kubernetes/kubernetes/issues/81245
|
// TODO: put this under e2epod once https://github.com/kubernetes/kubernetes/issues/81245
|
||||||
// is resolved. Otherwise there will be dependency issue.
|
// is resolved. Otherwise there will be dependency issue.
|
||||||
func PodExec(f *framework.Framework, pod *v1.Pod, shExec string) (string, string, error) {
|
func PodExec(f *framework.Framework, pod *v1.Pod, shExec string) (string, string, error) {
|
||||||
if framework.NodeOSDistroIs("windows") {
|
|
||||||
return f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "powershell", "/c", shExec)
|
|
||||||
}
|
|
||||||
return f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", shExec)
|
return f.ExecCommandInContainerWithFullOutput(pod.Name, pod.Spec.Containers[0].Name, "/bin/sh", "-c", shExec)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,12 @@ func (p *ephemeralTestSuite) DefineTests(driver storageframework.TestDriver, pat
|
|||||||
|
|
||||||
l.testCase.ReadOnly = true
|
l.testCase.ReadOnly = true
|
||||||
l.testCase.RunningPodCheck = func(pod *v1.Pod) interface{} {
|
l.testCase.RunningPodCheck = func(pod *v1.Pod) interface{} {
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, "mount | grep /mnt/test | grep ro,")
|
command := "mount | grep /mnt/test | grep ro,"
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
// attempt to create a dummy file and expect for it not to be created
|
||||||
|
command = "ls /mnt/test* && (touch /mnt/test-0/hello-world || true) && [ ! -f /mnt/test-0/hello-world ]"
|
||||||
|
}
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, command)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
l.testCase.TestEphemeral()
|
l.testCase.TestEphemeral()
|
||||||
@ -164,7 +169,12 @@ func (p *ephemeralTestSuite) DefineTests(driver storageframework.TestDriver, pat
|
|||||||
|
|
||||||
l.testCase.ReadOnly = false
|
l.testCase.ReadOnly = false
|
||||||
l.testCase.RunningPodCheck = func(pod *v1.Pod) interface{} {
|
l.testCase.RunningPodCheck = func(pod *v1.Pod) interface{} {
|
||||||
e2evolume.VerifyExecInPodSucceed(f, pod, "mount | grep /mnt/test | grep rw,")
|
command := "mount | grep /mnt/test | grep rw,"
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
// attempt to create a dummy file and expect for it to be created
|
||||||
|
command = "ls /mnt/test* && touch /mnt/test-0/hello-world && [ -f /mnt/test-0/hello-world ]"
|
||||||
|
}
|
||||||
|
e2evolume.VerifyExecInPodSucceed(f, pod, command)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
l.testCase.TestEphemeral()
|
l.testCase.TestEphemeral()
|
||||||
@ -273,6 +283,10 @@ func (t EphemeralTest) TestEphemeral() {
|
|||||||
|
|
||||||
ginkgo.By(fmt.Sprintf("checking the requested inline volume exists in the pod running on node %+v", t.Node))
|
ginkgo.By(fmt.Sprintf("checking the requested inline volume exists in the pod running on node %+v", t.Node))
|
||||||
command := "mount | grep /mnt/test && sleep 10000"
|
command := "mount | grep /mnt/test && sleep 10000"
|
||||||
|
if framework.NodeOSDistroIs("windows") {
|
||||||
|
command = "ls /mnt/test* && sleep 10000"
|
||||||
|
}
|
||||||
|
|
||||||
var volumes []v1.VolumeSource
|
var volumes []v1.VolumeSource
|
||||||
numVolumes := t.NumInlineVolumes
|
numVolumes := t.NumInlineVolumes
|
||||||
if numVolumes == 0 {
|
if numVolumes == 0 {
|
||||||
@ -348,7 +362,8 @@ func StartInPodWithInlineVolume(c clientset.Interface, ns, podName, command stri
|
|||||||
{
|
{
|
||||||
Name: "csi-volume-tester",
|
Name: "csi-volume-tester",
|
||||||
Image: e2epod.GetDefaultTestImage(),
|
Image: e2epod.GetDefaultTestImage(),
|
||||||
Command: e2epod.GenerateScriptCmd(command),
|
// NOTE: /bin/sh works on both agnhost and busybox
|
||||||
|
Command: []string{"/bin/sh", "-c", command},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RestartPolicy: v1.RestartPolicyNever,
|
RestartPolicy: v1.RestartPolicyNever,
|
||||||
|
Loading…
Reference in New Issue
Block a user