mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
cronjob: shut down integration test quickly again
6f2cd1b5bd
swapped the order of cancel() and
closeFn() so that closeFn got called first when the test was done. This caused
it to block while waiting for goroutines which themselves were waiting for
the context cancellation. The test still shut down, it just took ~86s instead
of ~30s.
The fix is to register the cancel twice: once as soon as the context is
created (to clean up in case of an unexpected panic) and once after
closeFn (because then it'll get called first, as before).
This commit is contained in:
parent
0e9ad242bd
commit
be82872eff
@ -152,6 +152,10 @@ func TestCronJobLaunchesPodAndCleansUp(t *testing.T) {
|
|||||||
closeFn, cjc, jc, informerSet, clientSet := setup(ctx, t)
|
closeFn, cjc, jc, informerSet, clientSet := setup(ctx, t)
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
|
|
||||||
|
// When shutting down, cancel must be called before closeFn.
|
||||||
|
// We simply call it multiple times.
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
cronJobName := "foo"
|
cronJobName := "foo"
|
||||||
namespaceName := "simple-cronjob-test"
|
namespaceName := "simple-cronjob-test"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user