fix(test): Fix WebSocketQueue test timeout and race conditions

Reduce worker polling interval from 5ms to 1ms for faster task pickup

Add 100ms buffer after job submission to allow queue to settle

Increase timeout from 30s to 60s to prevent flaky failures

Fixes intermittent timeout issues in integration tests
This commit is contained in:
Jeremie Fraeys 2026-02-23 14:38:18 -05:00
parent 551e6d4dbc
commit ec9e845bb6
No known key found for this signature in database

View file

@ -109,8 +109,11 @@ func TestWebSocketQueueEndToEnd(t *testing.T) {
}
submitWG.Wait()
// Give workers time to pick up any remaining tasks
time.Sleep(100 * time.Millisecond)
completed := 0
timeout := time.After(30 * time.Second)
timeout := time.After(60 * time.Second)
for completed < jobCount {
select {
case <-timeout:
@ -206,8 +209,11 @@ func TestWebSocketQueueEndToEndSQLite(t *testing.T) {
}
submitWG.Wait()
// Give workers time to pick up any remaining tasks
time.Sleep(100 * time.Millisecond)
completed := 0
timeout := time.After(30 * time.Second)
timeout := time.After(60 * time.Second)
for completed < jobCount {
select {
case <-timeout:
@ -310,11 +316,11 @@ func startFakeWorkers(
task, err := taskQueue.GetNextTaskWithLease(workerID, 30*time.Second)
if err != nil {
t.Logf("worker %s queue error: %v", workerID, err)
time.Sleep(5 * time.Millisecond)
time.Sleep(time.Millisecond)
continue
}
if task == nil {
time.Sleep(5 * time.Millisecond)
time.Sleep(time.Millisecond)
continue
}