Skip to content

Commit b907199

Browse files
committed
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.
1 parent bdfc8f6 commit b907199

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

test/e2e_node/eviction_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,17 +521,19 @@ func runEvictionTest(f *framework.Framework, pressureTimeout time.Duration, expe
521521
})
522522

523523
ginkgo.AfterEach(func() {
524+
defer func() {
525+
if expectedNodeCondition == v1.NodeDiskPressure && framework.TestContext.PrepullImages {
526+
// The disk eviction test may cause the prepulled images to be evicted,
527+
// prepull those images again to ensure this test not affect following tests.
528+
PrePullAllImages()
529+
}
530+
}()
524531
ginkgo.By("deleting pods")
525532
for _, spec := range testSpecs {
526533
ginkgo.By(fmt.Sprintf("deleting pod: %s", spec.pod.Name))
527534
f.PodClient().DeleteSync(spec.pod.Name, &metav1.DeleteOptions{}, 10*time.Minute)
528535
}
529536
reduceAllocatableMemoryUsage()
530-
if expectedNodeCondition == v1.NodeDiskPressure && framework.TestContext.PrepullImages {
531-
// The disk eviction test may cause the prepulled images to be evicted,
532-
// prepull those images again to ensure this test not affect following tests.
533-
PrePullAllImages()
534-
}
535537
ginkgo.By("making sure we can start a new pod after the test")
536538
podName := "test-admit-pod"
537539
f.PodClient().CreateSync(&v1.Pod{

test/e2e_node/system_node_critical_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ var _ = framework.KubeDescribe("SystemNodeCriticalPod [Slow] [Serial] [Disruptiv
9595
}, time.Minute*8, time.Second*4).ShouldNot(gomega.HaveOccurred())
9696
})
9797
ginkgo.AfterEach(func() {
98+
defer func() {
99+
if framework.TestContext.PrepullImages {
100+
// The test may cause the prepulled images to be evicted,
101+
// prepull those images again to ensure this test not affect following tests.
102+
PrePullAllImages()
103+
}
104+
}()
98105
ginkgo.By("delete the static pod")
99106
err := deleteStaticPod(podPath, staticPodName, ns)
100107
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
@@ -103,6 +110,7 @@ var _ = framework.KubeDescribe("SystemNodeCriticalPod [Slow] [Serial] [Disruptiv
103110
gomega.Eventually(func() error {
104111
return checkMirrorPodDisappear(f.ClientSet, mirrorPodName, ns)
105112
}, time.Minute, time.Second*2).Should(gomega.BeNil())
113+
106114
})
107115
})
108116
})

0 commit comments

Comments
 (0)