mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
node: e2e: ensure log rotation pod is deleted after test
Some node e2e tests check for expected number of pods running on the node to verify the correct state of that node after running test scenarios. An example of such a check is in the device plugin end to end test here: [1]. If the node is not left in a clean state after an e2e test finishes running, it can lead to flaky tests because the node might have unexpected pods running on the node. In order to avoid that, we make sure that the test pods are cleaned up after the test runs. [1]: https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/device_plugin_test.go#L189-L190 Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
This commit is contained in:
parent
0e19bbb916
commit
7e880d1bab
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user