Skip to content

Commit 6bf1a10

Browse files
author
Oleksandr Poliakov
committed
CSHARP-4988: Fix flaky ServerMonitor test
1 parent a90f0ab commit 6bf1a10

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/MongoDB.Driver.Core.Tests/Core/Servers/ServerMonitorTests.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,10 @@ public void RoundTripTimeMonitor_should_be_started_only_once_if_using_streaming_
307307
var subject = CreateSubject(out var mockConnection, out _, out var mockRoundTripTimeMonitor, capturedEvents, serverMonitorSettings: serverMonitorSettings);
308308

309309
SetupHeartbeatConnection(mockConnection, isStreamable: true, autoFillStreamingResponses: false);
310-
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), null);
311-
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), null);
312-
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), null);
310+
// Have to setup small delay on the heartbeat responses to emulate streamableServer functionality.
311+
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), TimeSpan.FromMilliseconds(500));
312+
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), TimeSpan.FromMilliseconds(500));
313+
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), TimeSpan.FromMilliseconds(500));
313314

314315
subject.Initialize();
315316
// spin until the initial handshake has happened in which case the server description state should be Connected

0 commit comments

Comments
 (0)