Skip to content

Commit d338c46

Browse files
committed
Fix TestStreamReconnection hanging issue
Use BlockUntil() to properly synchronize with the fake clock before advancing time. This prevents the test from hanging while waiting for the goroutine to process the time advancement. Signed-off-by: Jakob Haahr Taankvist <[email protected]>
1 parent d934e3a commit d338c46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

service/sharddistributor/client/spectatorclient/clientimpl_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ func TestStreamReconnection(t *testing.T) {
204204
spectator.Start(context.Background())
205205
defer spectator.Stop()
206206

207-
// Advance time for retry
207+
// Wait for the goroutine to be blocked in Sleep, then advance time
208+
mockTimeSource.BlockUntil(1) // Wait for 1 goroutine to be blocked in Sleep
208209
mockTimeSource.Advance(2 * time.Second)
210+
209211
spectator.firstStateWG.Wait()
210212
}

0 commit comments

Comments
 (0)