diff --git a/test/e2e_node/container_lifecycle_pod_construction.go b/test/e2e_node/container_lifecycle_pod_construction.go index db48dd1018d04..09545bde74c06 100644 --- a/test/e2e_node/container_lifecycle_pod_construction.go +++ b/test/e2e_node/container_lifecycle_pod_construction.go @@ -122,23 +122,30 @@ func (o containerOutputList) String() string { // RunTogether returns an error the lhs and rhs run together func (o containerOutputList) RunTogether(lhs, rhs string) error { lhsStart := o.findIndex(lhs, "Started", 0) - rhsStart := o.findIndex(rhs, "Started", 0) - - lhsFinish := o.findIndex(lhs, "Exiting", 0) - rhsFinish := o.findIndex(rhs, "Exiting", 0) - if lhsStart == -1 { return fmt.Errorf("couldn't find that %s ever started, got\n%v", lhs, o) } + + rhsStart := o.findIndex(rhs, "Started", lhsStart+1) if rhsStart == -1 { return fmt.Errorf("couldn't find that %s ever started, got\n%v", rhs, o) } - if lhsFinish != -1 && rhsStart > lhsFinish { + lhsExit := o.findIndex(lhs, "Exiting", lhsStart+1) + if lhsExit == -1 { + return fmt.Errorf("couldn't find that %s ever exited, got\n%v", lhs, o) + } + + if rhsStart > lhsExit { return fmt.Errorf("expected %s to start before exiting %s, got\n%v", rhs, lhs, o) } - if rhsFinish != -1 && lhsStart > rhsFinish { + rhsExit := o.findIndex(rhs, "Exiting", rhsStart+1) + if rhsExit == -1 { + return fmt.Errorf("couldn't find that %s ever exited, got\n%v", rhs, o) + } + + if lhsStart > rhsExit { return fmt.Errorf("expected %s to start before exiting %s, got\n%v", lhs, rhs, o) } diff --git a/test/e2e_node/container_lifecycle_test.go b/test/e2e_node/container_lifecycle_test.go index 35250abc23135..660735efd07a0 100644 --- a/test/e2e_node/container_lifecycle_test.go +++ b/test/e2e_node/container_lifecycle_test.go @@ -1006,7 +1006,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func( }) ginkgo.It("should run both restartable init containers and third init container together", func() { - framework.ExpectNoError(results.RunTogether(restartableInit2, restartableInit1)) + framework.ExpectNoError(results.RunTogether(restartableInit1, restartableInit2)) framework.ExpectNoError(results.RunTogether(restartableInit1, init3)) framework.ExpectNoError(results.RunTogether(restartableInit2, init3)) })