Skip to content

Commit 31db94c

Browse files
committed
Fix subPath tests for Windows
Windows test for subPath is failing due to an issue related to removeUnusedContainers calls. After image is changed to Agnhost, it automatically has a args by default. However, there are places to use container commands instead of args and causing issues. This is the first step to fix this issue. Next plan to replace busybox used in Linux with Agnhost which can work for both linux and windows. I also mark two subPath tests as LinuxOnly. I think they are not ready for windows yet. Before they were passing due to wrong reason. The tests checks failed container status but the contain fails due to other reasons than what we expected.
1 parent 82baa26 commit 31db94c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/e2e/storage/testsuites/subpath.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
234234
TestBasicSubpath(f, f.Namespace.Name, l.pod)
235235
})
236236

237-
ginkgo.It("should fail if subpath directory is outside the volume [Slow]", func() {
237+
ginkgo.It("should fail if subpath directory is outside the volume [Slow][LinuxOnly]", func() {
238238
init()
239239
defer cleanup()
240240

@@ -272,7 +272,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
272272
testPodFailSubpath(f, l.pod, false)
273273
})
274274

275-
ginkgo.It("should fail if subpath with backstepping is outside the volume [Slow]", func() {
275+
ginkgo.It("should fail if subpath with backstepping is outside the volume [Slow][LinuxOnly]", func() {
276276
init()
277277
defer cleanup()
278278

@@ -443,6 +443,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T
443443
// Change volume container to busybox so we can exec later
444444
l.pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
445445
l.pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
446+
l.pod.Spec.Containers[1].Args = nil
446447

447448
ginkgo.By(fmt.Sprintf("Creating pod %s", l.pod.Name))
448449
removeUnusedContainers(l.pod)
@@ -618,8 +619,9 @@ func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source *
618619
}
619620

620621
func containerIsUnused(container *v1.Container) bool {
621-
// mountImage with nil Args or with just "mounttest" as Args does nothing. Leave everything else
622-
return container.Image == mountImage && (container.Args == nil || (len(container.Args) == 1 && container.Args[0] == "mounttest"))
622+
// mountImage with nil command and nil Args or with just "mounttest" as Args does nothing. Leave everything else
623+
return container.Image == mountImage && container.Command == nil &&
624+
(container.Args == nil || (len(container.Args) == 1 && container.Args[0] == "mounttest"))
623625
}
624626

625627
// removeUnusedContainers removes containers from a SubpathTestPod that aren't
@@ -830,9 +832,10 @@ func testPodContainerRestartWithHooks(f *framework.Framework, pod *v1.Pod, hooks
830832

831833
pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
832834
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
835+
pod.Spec.Containers[0].Args = nil
833836
pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
834837
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
835-
838+
pod.Spec.Containers[1].Args = nil
836839
hooks.AddLivenessProbe(pod, probeFilePath)
837840

838841
// Start pod
@@ -1003,9 +1006,10 @@ func testSubpathReconstruction(f *framework.Framework, hostExec utils.HostExec,
10031006
// Change to busybox
10041007
pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
10051008
pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000")
1009+
pod.Spec.Containers[0].Args = nil
10061010
pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox))
10071011
pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000")
1008-
1012+
pod.Spec.Containers[1].Args = nil
10091013
// If grace period is too short, then there is not enough time for the volume
10101014
// manager to cleanup the volumes
10111015
gracePeriod := int64(30)

0 commit comments

Comments
 (0)