Skip to content

CSHARP-5608: CSOT: Command Execution #1709

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 8 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
528 changes: 259 additions & 269 deletions src/MongoDB.Driver/Core/Clusters/Cluster.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ namespace MongoDB.Driver.Core.Clusters.ServerSelectors
{
internal sealed class OperationsCountServerSelector : IServerSelector
{
private readonly IEnumerable<IClusterableServer> _clusterableServers;
private IReadOnlyList<IClusterableServer> _clusterableServers;

public OperationsCountServerSelector(IEnumerable<IClusterableServer> clusterableServers)
public OperationsCountServerSelector(IReadOnlyList<IClusterableServer> clusterableServers)
{
_clusterableServers = clusterableServers;
}
Expand Down Expand Up @@ -58,6 +58,11 @@ public IEnumerable<ServerDescription> SelectServers(ClusterDescription cluster,
}
}

public void PopulateServers(IReadOnlyList<IClusterableServer> clusterableServers)
{
_clusterableServers = clusterableServers;
}

/// <inheritdoc/>
public override string ToString() =>
nameof(OperationsCountServerSelector);
Expand Down
2 changes: 1 addition & 1 deletion tests/MongoDB.Driver.Tests/Core/Jira/CSharp3173Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private IServerSelector CreateWritableServerAndEndPointSelector(EndPoint endPoin
private void ForceClusterId(MultiServerCluster cluster, ClusterId clusterId)
{
Reflector.SetFieldValue(cluster, "_clusterId", clusterId);
Reflector.SetFieldValue(cluster, "_descriptionWithChangedTaskCompletionSource", new Cluster.ClusterDescriptionChangeSource(ClusterDescription.CreateInitial(clusterId, __directConnection)));
Reflector.SetFieldValue(cluster, "_expirableClusterDescription", new Cluster.ExpirableClusterDescription(cluster, ClusterDescription.CreateInitial(clusterId, __directConnection)));
}

private void SetupServerMonitorConnection(
Expand Down
2 changes: 1 addition & 1 deletion tests/MongoDB.Driver.Tests/Core/Jira/CSharp3302Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ private IServerSelector CreateWritableServerAndEndPointSelector(EndPoint endPoin
private void ForceClusterId(MultiServerCluster cluster, ClusterId clusterId)
{
Reflector.SetFieldValue(cluster, "_clusterId", clusterId);
Reflector.SetFieldValue(cluster, "_descriptionWithChangedTaskCompletionSource", new Cluster.ClusterDescriptionChangeSource(ClusterDescription.CreateInitial(clusterId, __directConnection)));
Reflector.SetFieldValue(cluster, "_expirableClusterDescription", new Cluster.ExpirableClusterDescription(cluster, ClusterDescription.CreateInitial(clusterId, __directConnection)));
}

private void SetupServerMonitorConnection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static IEnumerable<object[]> EventsData()
(new LogCategories.Command(), new CommandStartedEvent("test", new Bson.BsonDocument(), new DatabaseNamespace("test"), 1, 1, connectionId)),
(new LogCategories.Connection(), new ConnectionCreatedEvent(connectionId, null, 1)),
(new LogCategories.SDAM(), new ServerHeartbeatStartedEvent(connectionId, true)),
(new LogCategories.ServerSelection(), new ClusterSelectingServerEvent(clusterDescription, new RandomServerSelector(), default, default))
(new LogCategories.ServerSelection(), new ClusterSelectingServerEvent(clusterDescription, Mock.Of<IServerSelector>(), default, default))
};

var booleanValues = new[] { true, false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public void BypassSpawningMongocryptdTest(
var exception = Record.Exception(() => adminDatabase.RunCommand<BsonDocument>(legacyHelloCommand));

exception.Should().BeOfType<TimeoutException>();
exception.Message.Should().Contain("A timeout occurred after 1000ms selecting a server").And.Contain("localhost:27021");
exception.Message.Should().MatchRegex(@".*A timeout occurred after \d+ms selecting a server.*").And.Contain("localhost:27021");
}

IMongoClient EnsureEnvironmentAndConfigureTestClientEncrypted()
Expand Down