Skip to content

Commit e163953

Browse files
committed
fix another race in test
1 parent 85b37cf commit e163953

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

dbos/workflows_test.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,11 +1260,14 @@ func TestWorkflowRecovery(t *testing.T) {
12601260

12611261
// At least 5 of the 2nd steps should have errored due to execution race
12621262
// Check they are DBOSErrors with StepExecutionError wrapping a ConflictingIDError
1263-
secondStepErrorsMu.Lock()
1264-
errorsCopy := make([]error, len(secondStepErrors))
1265-
copy(errorsCopy, secondStepErrors)
1266-
secondStepErrorsMu.Unlock()
1267-
require.GreaterOrEqual(t, len(errorsCopy), 5, "expected at least 5 errors from second steps due to recovery race, got %d", len(errorsCopy))
1263+
var errorsCopy []error
1264+
require.Eventually(t, func() bool {
1265+
secondStepErrorsMu.Lock()
1266+
errorsCopy := make([]error, len(secondStepErrors))
1267+
copy(errorsCopy, secondStepErrors)
1268+
secondStepErrorsMu.Unlock()
1269+
return len(errorsCopy) >= 5
1270+
}, 10*time.Second, 100*time.Millisecond)
12681271
for _, err := range errorsCopy {
12691272
dbosErr, ok := err.(*DBOSError)
12701273
require.True(t, ok, "expected error to be of type *DBOSError, got %T", err)

0 commit comments

Comments
 (0)