mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 20:50:24 +00:00
e2e: simplify test cleanup
ginkgo.DeferCleanup has multiple advantages: - The cleanup operation can get registered if and only if needed. - No need to return a cleanup function that the caller must invoke. - Automatically determines whether a context is needed, which will simplify the introduction of context parameters. - Ginkgo's timeline shows when it executes the cleanup operation.
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user