From 367e8c557802b148081cf9c746a1e28f538240a3 Mon Sep 17 00:00:00 2001 From: Matthias Bertschy Date: Sun, 2 Jun 2024 21:43:23 +0200 Subject: [PATCH] ignore starting order in RunTogether, add another that does Signed-off-by: Matthias Bertschy --- .../container_lifecycle_pod_construction.go | 12 +++++++++++- test/e2e_node/container_lifecycle_test.go | 14 +++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/test/e2e_node/container_lifecycle_pod_construction.go b/test/e2e_node/container_lifecycle_pod_construction.go index 90af81b3744..ed7db4cd030 100644 --- a/test/e2e_node/container_lifecycle_pod_construction.go +++ b/test/e2e_node/container_lifecycle_pod_construction.go @@ -119,8 +119,18 @@ func (o containerOutputList) String() string { return b.String() } -// RunTogether returns an error the lhs and rhs run together +// RunTogether returns an error if containers don't run together func (o containerOutputList) RunTogether(lhs, rhs string) error { + if err := o.RunTogetherLhsFirst(lhs, rhs); err != nil { + if err := o.RunTogetherLhsFirst(rhs, lhs); err != nil { + return err + } + } + return nil +} + +// RunTogetherLhsFirst returns an error if containers don't run together or if rhs starts before lhs +func (o containerOutputList) RunTogetherLhsFirst(lhs, rhs string) error { lhsStart := o.findIndex(lhs, "Started", 0) if lhsStart == -1 { return fmt.Errorf("couldn't find that %s ever started, got\n%v", lhs, o) diff --git a/test/e2e_node/container_lifecycle_test.go b/test/e2e_node/container_lifecycle_test.go index cf50dcb9d62..6caf25bfca1 100644 --- a/test/e2e_node/container_lifecycle_test.go +++ b/test/e2e_node/container_lifecycle_test.go @@ -834,9 +834,9 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun ginkgo.By("Analyzing results") // readiness probes are called during pod termination - framework.ExpectNoError(results.RunTogether(prefixedName(PreStopPrefix, regular1), prefixedName(ReadinessPrefix, regular1))) + framework.ExpectNoError(results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), prefixedName(ReadinessPrefix, regular1))) // liveness probes are not called during pod termination - err = results.RunTogether(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, regular1)) + err = results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, regular1)) gomega.Expect(err).To(gomega.HaveOccurred()) }) @@ -897,11 +897,11 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun ginkgo.By("Analyzing results") // FIXME ExpectNoError: this will be implemented in KEP 4438 // liveness probes are called for restartable init containers during pod termination - err = results.RunTogether(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, restartableInit1)) + err = results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, restartableInit1)) gomega.Expect(err).To(gomega.HaveOccurred()) // FIXME ExpectNoError: this will be implemented in KEP 4438 // restartable init containers are restarted during pod termination - err = results.RunTogether(prefixedName(PreStopPrefix, regular1), restartableInit1) + err = results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), restartableInit1) gomega.Expect(err).To(gomega.HaveOccurred()) }) }) @@ -1147,12 +1147,8 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func( framework.ExpectNoError(results.ExitsBefore(init1, restartableInit1)) }) - ginkgo.It("should start first restartable init container before starting second init container", func() { - framework.ExpectNoError(results.StartsBefore(restartableInit1, init2)) - }) - ginkgo.It("should run first init container and first restartable init container together", func() { - framework.ExpectNoError(results.RunTogether(restartableInit1, init2)) + framework.ExpectNoError(results.RunTogetherLhsFirst(restartableInit1, init2)) }) ginkgo.It("should run second init container to completion before starting second restartable init container", func() {