Merge pull request #114425 from pohly/e2e-ginkgo-timeouts-defer-cleanup

e2e ginkgo timeouts: simplify code
This commit is contained in:
Kubernetes Prow Robot
2022-12-13 10:28:09 -08:00
committed by GitHub
109 changed files with 821 additions and 1043 deletions

View File

@@ -1395,21 +1395,26 @@ func testRollingUpdateDeploymentWithLocalTrafficLoadBalancer(f *framework.Framew
}
e2eservice.TestReachableHTTP(lbNameOrAddress, svcPort, timeout)
expectedNodes, err := jig.GetEndpointNodeNames()
framework.ExpectNoError(err)
framework.Logf("Starting a goroutine to watch the service's endpoints in the background")
done := make(chan struct{})
failed := make(chan struct{})
defer close(done)
go func() {
defer ginkgo.GinkgoRecover()
expectedNodes, err := jig.GetEndpointNodeNames()
framework.ExpectNoError(err)
// The affinity policy should ensure that before an old pod is
// deleted, a new pod will have been created on the same node.
// Thus the set of nodes with local endpoints for the service
// should remain unchanged.
wait.Until(func() {
actualNodes, err := jig.GetEndpointNodeNames()
framework.ExpectNoError(err)
if err != nil {
framework.Logf("The previous set of nodes with local endpoints was %v, now the lookup failed: %v", expectedNodes.List(), err)
failed <- struct{}{}
return
}
if !actualNodes.Equal(expectedNodes) {
framework.Logf("The set of nodes with local endpoints changed; started with %v, now have %v", expectedNodes.List(), actualNodes.List())
failed <- struct{}{}

View File

@@ -78,7 +78,7 @@ func testFinishedJob(f *framework.Framework) {
job := e2ejob.NewTestJob("randomlySucceedOrFail", "rand-non-local", v1.RestartPolicyNever, parallelism, completions, nil, backoffLimit)
job.Spec.TTLSecondsAfterFinished = &ttl
job.ObjectMeta.Finalizers = []string{dummyFinalizer}
defer cleanupJob(f, job)
ginkgo.DeferCleanup(cleanupJob, f, job)
framework.Logf("Create a Job %s/%s with TTL", ns, job.Name)
job, err := e2ejob.CreateJob(c, ns, job)