Skip to content

CSHARP-5598: Fix CoreServerSessionPool.IsAboutToExpire test #1699

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
May 27, 2025

Conversation

sanych-sun
Copy link
Member

No description provided.

@sanych-sun sanych-sun requested a review from a team as a code owner May 26, 2025 20:14
@sanych-sun sanych-sun added the chore Label to hide PR from generated Release Notes label May 26, 2025
@sanych-sun sanych-sun requested review from papafe and BorisDog and removed request for a team and papafe May 26, 2025 20:14
public void IsAboutToExpire_should_never_expire_in_load_balancing_mode()
{
var subject = CreateSubject();
var mockedCluster = new TestCluster(ClusterType.LoadBalanced);
Copy link
Member Author

Choose a reason for hiding this comment

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

In scope of CSOT I've updated IClusterInternal interface, instead of mirroring the changes here, I've decided to remove local implementation by using Moq (CreateSubject method already constructing that mock)

var mockedCluster = new TestCluster(ClusterType.LoadBalanced);
var mockedServerSessionPool = new CoreServerSessionPool(mockedCluster);
var mockSession = new Mock<ICoreServerSession>();
var lastUsedAt = DateTime.UtcNow.AddSeconds(1741);
Copy link
Member Author

@sanych-sun sanych-sun May 26, 2025

Choose a reason for hiding this comment

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

This line of code is incorrect, we should add negative seconds to make session looks expired (see line 231 before the changes).

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 + minor comment

[InlineData(ClusterType.LoadBalanced, null, false)]
[InlineData(ClusterType.LoadBalanced, 1741, false)]
[InlineData(ClusterType.LoadBalanced, 1739, false)]
public void IsAboutToExpire_should_return_expected_result(ClusterType clusterType, int? lastUsedSecondsAgo, bool expectedResult)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: rename expectedResult to isAboutToExpire?

@sanych-sun sanych-sun merged commit dde1ef9 into mongodb:main May 27, 2025
30 of 34 checks passed
@sanych-sun sanych-sun deleted the csharp5598 branch May 27, 2025 19:41
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
chore Label to hide PR from generated Release Notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants