From ffdbce6291a73b69b1ba76a665136401df5319b7 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sun, 22 May 2022 15:34:38 +0200 Subject: [PATCH] e2e test for evicted pods --- test/e2e/node/pods.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/e2e/node/pods.go b/test/e2e/node/pods.go index 9fdfa935eb3..557b3a786dc 100644 --- a/test/e2e/node/pods.go +++ b/test/e2e/node/pods.go @@ -298,7 +298,49 @@ var _ = SIGDescribe("Pods Extended", func() { } } }) + + ginkgo.It("evicted pods should be terminal", func() { + ginkgo.By("creating the pod that should be evicted") + + name := "pod-should-be-evicted" + string(uuid.NewUUID()) + image := imageutils.GetE2EImage(imageutils.BusyBox) + pod := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + }, + Spec: v1.PodSpec{ + RestartPolicy: v1.RestartPolicyOnFailure, + Containers: []v1.Container{ + { + Name: "bar", + Image: image, + Command: []string{ + "/bin/sh", "-c", "sleep 10; fallocate -l 10M file; sleep 10000", + }, + Resources: v1.ResourceRequirements{ + Limits: v1.ResourceList{ + "ephemeral-storage": resource.MustParse("5Mi"), + }, + }}, + }, + }, + } + + ginkgo.By("submitting the pod to kubernetes") + podClient.Create(pod) + defer func() { + ginkgo.By("deleting the pod") + podClient.Delete(context.TODO(), pod.Name, metav1.DeleteOptions{}) + }() + + err := e2epod.WaitForPodTerminatedInNamespace(f.ClientSet, pod.Name, "Evicted", f.Namespace.Name) + if err != nil { + framework.Failf("error waiting for pod to be evicted: %v", err) + } + + }) }) + }) func createAndTestPodRepeatedly(workers, iterations int, scenario podScenario, podClient v1core.PodInterface) {