Skip to content

Commit ea91862

Browse files
committed
timeout test after 2 seconds
1 parent 714625e commit ea91862

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

leader/leader_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,18 @@ func TestElector_Run_OnlyOneLeaderExecutesWork(t *testing.T) {
312312
}()
313313
}
314314

315-
wg.Wait()
315+
done := make(chan struct{})
316+
go func() {
317+
wg.Wait()
318+
close(done)
319+
}()
320+
321+
select {
322+
case <-done:
323+
// Success - Run exited
324+
case <-time.After(2 * time.Second):
325+
t.Fatal("test timed out waiting for Run to exit")
326+
}
316327

317328
if maxConcurrent.Load() > 1 {
318329
t.Fatalf("expected max 1 concurrent worker, got %d", maxConcurrent.Load())

0 commit comments

Comments
 (0)