Skip to content

Commit 9aa64d1

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 10s and the delay from 150ms to 300ms to accommodate slower CI environments.
1 parent e6907b1 commit 9aa64d1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tests/MultiLock.Tests/LeadershipExtensionMethodsTests.cs

Lines changed: 4 additions & 3 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(5));
512+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
513513
var subscriberRegistered = new TaskCompletionSource();
514514

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

537-
// Wait for debounce delay and event processing
538-
await Task.Delay(TimeSpan.FromMilliseconds(150), cts.Token);
537+
// 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);
539540
await TestHelpers.WaitForConditionAsync(() => events.Count >= 1, TimeSpan.FromSeconds(5), cts.Token, eventsLock);
540541

541542
// Cleanup - Cancel and wait for event task to complete before asserting

0 commit comments

Comments
 (0)