From b9071991e32ddeb72202ec8fdad2e85a2f3e5db3 Mon Sep 17 00:00:00 2001 From: Odin Ugedal Date: Tue, 27 Aug 2019 14:55:46 +0200 Subject: [PATCH] Add pre pull of e2e images after DiskPressure test The "system_node_critical_test" causes DiskPressure on the node, resulting in eviction of some of the pre pulled images. This makes all the resulting tests to fail, since their pod spec use PullPolicy: Never The PrePullImages is now inside a defer, so it will be executed even tho the assertions inside the "AfterEach" fail. --- test/e2e_node/eviction_test.go | 12 +++++++----- test/e2e_node/system_node_critical_test.go | 8 ++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/e2e_node/eviction_test.go b/test/e2e_node/eviction_test.go index 27a3796868b..8aecea325a7 100644 --- a/test/e2e_node/eviction_test.go +++ b/test/e2e_node/eviction_test.go @@ -521,17 +521,19 @@ func runEvictionTest(f *framework.Framework, pressureTimeout time.Duration, expe }) ginkgo.AfterEach(func() { + defer func() { + if expectedNodeCondition == v1.NodeDiskPressure && framework.TestContext.PrepullImages { + // The disk eviction test may cause the prepulled images to be evicted, + // prepull those images again to ensure this test not affect following tests. + PrePullAllImages() + } + }() ginkgo.By("deleting pods") for _, spec := range testSpecs { ginkgo.By(fmt.Sprintf("deleting pod: %s", spec.pod.Name)) f.PodClient().DeleteSync(spec.pod.Name, &metav1.DeleteOptions{}, 10*time.Minute) } reduceAllocatableMemoryUsage() - if expectedNodeCondition == v1.NodeDiskPressure && framework.TestContext.PrepullImages { - // The disk eviction test may cause the prepulled images to be evicted, - // prepull those images again to ensure this test not affect following tests. - PrePullAllImages() - } ginkgo.By("making sure we can start a new pod after the test") podName := "test-admit-pod" f.PodClient().CreateSync(&v1.Pod{ diff --git a/test/e2e_node/system_node_critical_test.go b/test/e2e_node/system_node_critical_test.go index 22065170c30..43cc58faebf 100644 --- a/test/e2e_node/system_node_critical_test.go +++ b/test/e2e_node/system_node_critical_test.go @@ -95,6 +95,13 @@ var _ = framework.KubeDescribe("SystemNodeCriticalPod [Slow] [Serial] [Disruptiv }, time.Minute*8, time.Second*4).ShouldNot(gomega.HaveOccurred()) }) ginkgo.AfterEach(func() { + defer func() { + if framework.TestContext.PrepullImages { + // The test may cause the prepulled images to be evicted, + // prepull those images again to ensure this test not affect following tests. + PrePullAllImages() + } + }() ginkgo.By("delete the static pod") err := deleteStaticPod(podPath, staticPodName, ns) gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) @@ -103,6 +110,7 @@ var _ = framework.KubeDescribe("SystemNodeCriticalPod [Slow] [Serial] [Disruptiv gomega.Eventually(func() error { return checkMirrorPodDisappear(f.ClientSet, mirrorPodName, ns) }, time.Minute, time.Second*2).Should(gomega.BeNil()) + }) }) })