perf: fix scheduler_perf framework orphaned scheduler on timeout

This commit is contained in:
gfilipek 2026-05-28 11:33:13 +00:00
parent 8822656b90
commit 0ca2bdcf3f

View file

@ -799,6 +799,13 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
scheduler, informerFactory, schedulerDone, tCtx := setupTestCase(b, tc, featureGates, w, opts)
tCtx.TB().Cleanup(func() {
tCtx.Cancel("workload is done")
<-schedulerDone
// Reset metrics to prevent metrics generated in current workload gets
// carried over to the next workload.
legacyregistry.Reset()
})
err := w.isValid(tc.MetricsCollectorConfig)
if err != nil {
@ -846,14 +853,6 @@ func RunBenchmarkPerfScheduling(b *testing.B, configFile string, topicName strin
tCtx.Errorf("%s: %s", w.Name, err)
}
tCtx.Cancel("workload is done")
// Wait for the scheduler to stop to avoid data races when resetting metrics.
<-schedulerDone
// Reset metrics to prevent metrics generated in current workload gets
// carried over to the next workload.
legacyregistry.Reset()
// Exactly one result is expected to contain the progress information.
for _, item := range results {
if len(item.progress) == 0 {
@ -923,6 +922,13 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string, options ...Sc
}
featureGates := featureGatesMerge(tc.FeatureGates, w.FeatureGates)
scheduler, informerFactory, schedulerDone, tCtx := setupTestCase(t, tc, featureGates, w, opts)
tCtx.TB().Cleanup(func() {
tCtx.Cancel("workload is done")
<-schedulerDone
// Reset metrics to prevent metrics generated in current workload gets
// carried over to the next workload.
legacyregistry.Reset()
})
err := w.isValid(tc.MetricsCollectorConfig)
if err != nil {
t.Fatalf("workload %s is not valid: %v", w.Name, err)
@ -937,14 +943,6 @@ func RunIntegrationPerfScheduling(t *testing.T, configFile string, options ...Sc
if err = checkEmptyInFlightEvents(); err != nil {
tCtx.Errorf("%s: %s", w.Name, err)
}
tCtx.Cancel("workload is done")
// Wait for the scheduler to stop to avoid data races when resetting metrics.
<-schedulerDone
// Reset metrics to prevent metrics generated in current workload gets
// carried over to the next workload.
legacyregistry.Reset()
})
}
})