diff --git a/test/e2e_node/container_log_rotation_test.go b/test/e2e_node/container_log_rotation_test.go index 56796fd469b..6a6a2708446 100644 --- a/test/e2e_node/container_log_rotation_test.go +++ b/test/e2e_node/container_log_rotation_test.go @@ -50,7 +50,8 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func() initialConfig.ContainerLogMaxSize = testContainerLogMaxSize }) - ginkgo.It("should be rotated and limited to a fixed amount of files", func(ctx context.Context) { + var logRotationPod *v1.Pod + ginkgo.BeforeEach(func() { ginkgo.By("create log container") pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -72,10 +73,20 @@ var _ = SIGDescribe("ContainerLogRotation [Slow] [Serial] [Disruptive]", func() }, }, } - pod = e2epod.NewPodClient(f).CreateSync(pod) + logRotationPod = e2epod.NewPodClient(f).CreateSync(pod) + }) + + ginkgo.AfterEach(func() { + ginkgo.By("Deleting the log-rotation pod") + framework.Logf("Deleting pod: %s", logRotationPod.Name) + e2epod.NewPodClient(f).DeleteSync(logRotationPod.Name, metav1.DeleteOptions{}, time.Minute) + }) + + ginkgo.It("should be rotated and limited to a fixed amount of files", func(ctx context.Context) { + ginkgo.By("get container log path") - framework.ExpectEqual(len(pod.Status.ContainerStatuses), 1) - id := kubecontainer.ParseContainerID(pod.Status.ContainerStatuses[0].ContainerID).ID + framework.ExpectEqual(len(logRotationPod.Status.ContainerStatuses), 1) + id := kubecontainer.ParseContainerID(logRotationPod.Status.ContainerStatuses[0].ContainerID).ID r, _, err := getCRIClient() framework.ExpectNoError(err) resp, err := r.ContainerStatus(context.Background(), id, false)