Skip to content

Commit 049940f

Browse files
committed
fix(tests): increase timeout and delay for Debounce test
The Debounce extension delays each event by the specified timespan (100ms), so we need to allow enough time for the debounced events to be processed before checking the results. Increased the timeout from 5s to 15s and the delay from 150ms to 500ms to accommodate slower CI environments.
1 parent d9d6886 commit 049940f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

tests/MultiLock.Tests/LeadershipExtensionMethodsTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ public async Task Debounce_ShouldDelayEvents()
509509
var service = (LeaderElectionService)services.GetRequiredService<ILeaderElectionService>();
510510
var events = new List<LeadershipChangedEventArgs>();
511511
object eventsLock = new();
512-
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
512+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15));
513513
var subscriberRegistered = new TaskCompletionSource();
514514

515515
// Act - Start listening BEFORE starting service
@@ -535,9 +535,10 @@ public async Task Debounce_ShouldDelayEvents()
535535
await service.StopAsync(cts.Token);
536536

537537
// Wait for debounce delay and event processing - debounce needs time to process events
538-
// Each event is delayed by 100ms, so we need at least 200ms for 2 events plus processing time
539-
await Task.Delay(TimeSpan.FromMilliseconds(300), cts.Token);
540-
await TestHelpers.WaitForConditionAsync(() => events.Count >= 1, TimeSpan.FromSeconds(5), cts.Token, eventsLock);
538+
// The debounce waits 100ms after each event, so we need significant time for 2 events
539+
// plus the time for the stream to complete after the service stops
540+
await Task.Delay(TimeSpan.FromMilliseconds(500), cts.Token);
541+
await TestHelpers.WaitForConditionAsync(() => events.Count >= 1, TimeSpan.FromSeconds(10), cts.Token, eventsLock);
541542

542543
// Cleanup - Cancel and wait for event task to complete before asserting
543544
await cts.CancelAsync();

0 commit comments

Comments
 (0)