From 31db94c8484cf16b3b0ed2913659ecf0e6dcf0b7 Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Wed, 3 Jun 2020 11:45:06 -0700 Subject: [PATCH] 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. --- test/e2e/storage/testsuites/subpath.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/test/e2e/storage/testsuites/subpath.go b/test/e2e/storage/testsuites/subpath.go index a479c5354f97..29adc9f7d3ee 100644 --- a/test/e2e/storage/testsuites/subpath.go +++ b/test/e2e/storage/testsuites/subpath.go @@ -234,7 +234,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T TestBasicSubpath(f, f.Namespace.Name, l.pod) }) - ginkgo.It("should fail if subpath directory is outside the volume [Slow]", func() { + ginkgo.It("should fail if subpath directory is outside the volume [Slow][LinuxOnly]", func() { init() defer cleanup() @@ -272,7 +272,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T testPodFailSubpath(f, l.pod, false) }) - ginkgo.It("should fail if subpath with backstepping is outside the volume [Slow]", func() { + ginkgo.It("should fail if subpath with backstepping is outside the volume [Slow][LinuxOnly]", func() { init() defer cleanup() @@ -443,6 +443,7 @@ func (s *subPathTestSuite) DefineTests(driver TestDriver, pattern testpatterns.T // Change volume container to busybox so we can exec later l.pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)) l.pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000") + l.pod.Spec.Containers[1].Args = nil ginkgo.By(fmt.Sprintf("Creating pod %s", l.pod.Name)) removeUnusedContainers(l.pod) @@ -618,8 +619,9 @@ func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source * } func containerIsUnused(container *v1.Container) bool { - // mountImage with nil Args or with just "mounttest" as Args does nothing. Leave everything else - return container.Image == mountImage && (container.Args == nil || (len(container.Args) == 1 && container.Args[0] == "mounttest")) + // mountImage with nil command and nil Args or with just "mounttest" as Args does nothing. Leave everything else + return container.Image == mountImage && container.Command == nil && + (container.Args == nil || (len(container.Args) == 1 && container.Args[0] == "mounttest")) } // removeUnusedContainers removes containers from a SubpathTestPod that aren't @@ -830,9 +832,10 @@ func testPodContainerRestartWithHooks(f *framework.Framework, pod *v1.Pod, hooks pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)) pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000") + pod.Spec.Containers[0].Args = nil pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)) pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000") - + pod.Spec.Containers[1].Args = nil hooks.AddLivenessProbe(pod, probeFilePath) // Start pod @@ -1003,9 +1006,10 @@ func testSubpathReconstruction(f *framework.Framework, hostExec utils.HostExec, // Change to busybox pod.Spec.Containers[0].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)) pod.Spec.Containers[0].Command = e2evolume.GenerateScriptCmd("sleep 100000") + pod.Spec.Containers[0].Args = nil pod.Spec.Containers[1].Image = e2evolume.GetTestImage(imageutils.GetE2EImage(imageutils.BusyBox)) pod.Spec.Containers[1].Command = e2evolume.GenerateScriptCmd("sleep 100000") - + pod.Spec.Containers[1].Args = nil // If grace period is too short, then there is not enough time for the volume // manager to cleanup the volumes gracePeriod := int64(30)