mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 02:06:23 +00:00
Merge pull request #137870 from tallclair/push-lplxytyovnkw
test: fix flaky static pod tests by asserting on termination message …
This commit is contained in:
@@ -75,7 +75,6 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
})
|
||||
|
||||
var initCtrID string
|
||||
var startTime *metav1.Time
|
||||
mirrorPodName := fmt.Sprintf("%s-%s", staticPod.Name, framework.TestContext.NodeName)
|
||||
ginkgo.By("wait for the mirror pod to be updated")
|
||||
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
||||
@@ -85,9 +84,10 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
cstatus := pod.Status.InitContainerStatuses[0]
|
||||
// Wait until the init container is terminated.
|
||||
g.Expect(cstatus.State.Terminated).NotTo(gomega.BeNil())
|
||||
g.Expect(cstatus.State.Terminated.Reason).To(gomega.Equal("Completed"))
|
||||
g.Expect(cstatus.State.Terminated.ExitCode).To(gomega.BeZero())
|
||||
g.Expect(cstatus.State.Terminated.ContainerID).NotTo(gomega.BeEmpty())
|
||||
initCtrID = cstatus.ContainerID
|
||||
startTime = pod.Status.StartTime
|
||||
}, 2*time.Minute, 5*time.Second).Should(gomega.Succeed())
|
||||
|
||||
ginkgo.By("remove init container")
|
||||
@@ -103,7 +103,6 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
ginkgo.By("wait for the mirror pod to be updated")
|
||||
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
||||
pod, err := f.ClientSet.CoreV1().Pods(staticPod.Namespace).Get(ctx, mirrorPodName, metav1.GetOptions{})
|
||||
g.Expect(pod.Status.StartTime.Equal(startTime)).To(gomega.BeFalseBecause("startTime should not be equal"))
|
||||
g.Expect(err).Should(gomega.Succeed())
|
||||
g.Expect(pod.Status.InitContainerStatuses).To(gomega.HaveLen(1))
|
||||
cstatus := pod.Status.InitContainerStatuses[0]
|
||||
@@ -111,6 +110,7 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
g.Expect(cstatus.State.Terminated).NotTo(gomega.BeNil())
|
||||
g.Expect(cstatus.State.Terminated.Reason).To(gomega.Equal("Completed"))
|
||||
g.Expect(cstatus.State.Terminated.ExitCode).To(gomega.BeZero())
|
||||
g.Expect(cstatus.State.Terminated.Message).To(gomega.ContainSubstring("Unable to get init container status"))
|
||||
}, 2*time.Minute, 5*time.Second).Should(gomega.Succeed())
|
||||
})
|
||||
})
|
||||
@@ -151,7 +151,6 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
})
|
||||
|
||||
var sidecarCtrID string
|
||||
var startTime *metav1.Time
|
||||
mirrorPodName := fmt.Sprintf("%s-%s", staticPod.Name, framework.TestContext.NodeName)
|
||||
ginkgo.By("wait for the mirror pod to be updated")
|
||||
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
||||
@@ -162,7 +161,6 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
// Wait until the sidecar container starts running.
|
||||
g.Expect(cstatus.State.Running).NotTo(gomega.BeNil())
|
||||
sidecarCtrID = cstatus.ContainerID
|
||||
startTime = pod.Status.StartTime
|
||||
}, 2*time.Minute, 5*time.Second).Should(gomega.Succeed())
|
||||
|
||||
// Stop kubelet first not to restart the sidecar container.
|
||||
@@ -181,12 +179,12 @@ var _ = SIGDescribe("StaticPod", framework.WithSerial(), func() {
|
||||
ginkgo.By("wait for the mirror pod to be updated")
|
||||
gomega.Eventually(ctx, func(g gomega.Gomega) {
|
||||
pod, err := f.ClientSet.CoreV1().Pods(staticPod.Namespace).Get(ctx, mirrorPodName, metav1.GetOptions{})
|
||||
g.Expect(pod.Status.StartTime.Equal(startTime)).To(gomega.BeFalseBecause("startTime should not be equal"))
|
||||
g.Expect(err).Should(gomega.Succeed())
|
||||
g.Expect(pod.Status.InitContainerStatuses).To(gomega.HaveLen(1))
|
||||
cstatus := pod.Status.InitContainerStatuses[0]
|
||||
// Sidecar container should be restarted and running.
|
||||
g.Expect(cstatus.State.Running).NotTo(gomega.BeNil())
|
||||
g.Expect(cstatus.ContainerID).NotTo(gomega.Equal(sidecarCtrID))
|
||||
}, 2*time.Minute, 5*time.Second).Should(gomega.Succeed())
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user