use Cleanup instead of defer

This commit is contained in:
YamasouA 2025-03-05 09:24:47 +09:00
parent 41577dea1b
commit 8e4b00e949

View File

@ -1515,9 +1515,11 @@ func runWorkload(tCtx ktesting.TContext, tc *testCase, w *workload, informerFact
workload: w,
}
defer executor.wg.Wait()
defer executor.collectorWG.Wait()
defer tCtx.Cancel("workload is done")
tCtx.TB().Cleanup(func() {
tCtx.Cancel("workload is done")
executor.collectorWG.Wait()
executor.wg.Wait()
})
for opIndex, op := range unrollWorkloadTemplate(tCtx, tc.WorkloadTemplate, w) {
realOp, err := op.realOp.patchParams(w)