Merge pull request #124668 from bart0sh/PR143-e2e-node-fix-containers-lifecycle

node_e2e: refactor RunTogether function
This commit is contained in:
Kubernetes Prow Robot 2024-05-06 15:11:46 -07:00 committed by GitHub
commit 65f8129e51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 8 deletions

View File

@ -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)
}

View File

@ -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))
})