Skip to content

CSHARP-4988: Fix flaky ServerMonitor test #1277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2024

Conversation

sanych-sun
Copy link
Member

No description provided.

@sanych-sun sanych-sun requested a review from a team as a code owner February 29, 2024 19:43
@sanych-sun sanych-sun removed the request for review from a team February 29, 2024 19:43
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), null);
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), null);
// Have to setup small delay on the heartbeat responses to emulate streamableServer functionality.
mockConnection.EnqueueCommandResponseMessage(CreateHeartbeatCommandResponseMessage(), TimeSpan.FromMilliseconds(500));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to reduce the delay a bit more to like maybe 100ms?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great if could not rely on timings at all, and then have much lower intervals like in the rest of tests (5ms).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So after additional discussion with Boris we decided to remove delays at all, as well as verification of the Start method was called after the very first heartbeat (because the way we detecting the first heartbeat was done is not that reliable)

@@ -307,9 +307,10 @@ public void RoundTripTimeMonitor_should_be_started_only_once_if_using_streaming_
var subject = CreateSubject(out var mockConnection, out _, out var mockRoundTripTimeMonitor, capturedEvents, serverMonitorSettings: serverMonitorSettings);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I think you might want remove the serverMonitorSettings variable before this. Looking at the code I don't think it is needed since we will be streaming heartbeats with the server.

Copy link
Member Author

@sanych-sun sanych-sun Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boris pointed to the fact that we still need this to override the default settings.

@@ -303,23 +303,17 @@ public void InitializeHelloProtocol_should_use_streaming_protocol_when_available
public void RoundTripTimeMonitor_should_be_started_only_once_if_using_streaming_protocol()
{
var capturedEvents = new EventCapturer().Capture<ServerHeartbeatSucceededEvent>();
var serverMonitorSettings = new ServerMonitorSettings(TimeSpan.FromSeconds(5), TimeSpan.FromMilliseconds(10));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we still need this to override the higher default interval.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will revert this =)

@sanych-sun sanych-sun requested a review from BorisDog February 29, 2024 21:21
Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@adelinowona adelinowona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sanych-sun sanych-sun merged commit 647d465 into mongodb:master Mar 1, 2024
@sanych-sun sanych-sun deleted the csharp4988 branch March 1, 2024 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants