chore: fix Test_Runner/CleanupPendingBuild with testutil.Eventually (#19924)

Fixes https://github.com/coder/internal/issues/968
This commit is contained in:
Cian Johnston
2025-09-23 16:53:53 +01:00
committed by GitHub
parent f80cc15d90
commit a68122ca30
+5 -6
View File
@@ -264,7 +264,7 @@ func Test_Runner(t *testing.T) {
// Wait for the workspace build job to be picked up.
checkJobStartedCtx := testutil.Context(t, testutil.WaitLong)
jobCh := make(chan codersdk.ProvisionerJob, 1)
require.Eventually(t, func() bool {
testutil.Eventually(checkJobStartedCtx, t, func(ctx context.Context) bool {
workspaces, err := client.Workspaces(checkJobStartedCtx, codersdk.WorkspaceFilter{})
if err != nil {
return false
@@ -286,7 +286,7 @@ func Test_Runner(t *testing.T) {
}
jobCh <- ws.LatestBuild.Job
return true
}, testutil.WaitLong, testutil.IntervalSlow)
}, testutil.IntervalSlow)
t.Log("canceling scaletest workspace creation")
runnerCancel()
@@ -308,9 +308,8 @@ func Test_Runner(t *testing.T) {
}()
// Ensure the job has been marked as canceled
checkJobCanceledCtx := testutil.Context(t, testutil.WaitLong)
require.Eventually(t, func() bool {
pj, err := client.OrganizationProvisionerJob(checkJobCanceledCtx, runningJob.OrganizationID, runningJob.ID)
testutil.Eventually(cleanupCtx, t, func(ctx context.Context) bool {
pj, err := client.OrganizationProvisionerJob(ctx, runningJob.OrganizationID, runningJob.ID)
if !assert.NoError(t, err) {
return false
}
@@ -324,7 +323,7 @@ func Test_Runner(t *testing.T) {
}
return true
}, testutil.WaitLong, testutil.IntervalSlow)
}, testutil.IntervalSlow)
cleanupCancel()
<-done
cleanupLogsStr := cleanupLogs.String()