Skip to content

Commit bf8c4e4

Browse files
authored
CSHARP-4017: Fix flaky Aggregate_with__out_includes_read_preference_for_5.0__server error (#1381)
1 parent 941a018 commit bf8c4e4

File tree

2 files changed

+2
-32
lines changed

2 files changed

+2
-32
lines changed

tests/MongoDB.Driver.Tests/Jira/CSharp3397Tests.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,6 @@ namespace MongoDB.Driver.Tests.Jira
2626
{
2727
public class CSharp3397Tests
2828
{
29-
[Fact]
30-
public void Aggregate_out_to_collection_should_work()
31-
{
32-
var client = DriverTestConfiguration.Client;
33-
var database = client.GetDatabase("test");
34-
var collection = database.GetCollection<BsonDocument>("test");
35-
var outCollection = database.GetCollection<AggregateCountResult>("out");
36-
37-
var writeConcern = WriteConcern.WMajority;
38-
if (DriverTestConfiguration.IsReplicaSet(client))
39-
{
40-
var n = DriverTestConfiguration.GetReplicaSetNumberOfDataBearingMembers(client);
41-
writeConcern = new WriteConcern(n);
42-
}
43-
44-
database.DropCollection("test");
45-
database.DropCollection("out");
46-
collection
47-
.WithWriteConcern(writeConcern)
48-
.InsertOne(new BsonDocument("_id", 1));
49-
50-
var pipeline = new EmptyPipelineDefinition<BsonDocument>()
51-
.Count()
52-
.Out(outCollection)
53-
.As<BsonDocument, AggregateCountResult, AggregateCountResultWithId>();
54-
var results = collection.WithReadPreference(ReadPreference.SecondaryPreferred).Aggregate(pipeline).ToList();
55-
56-
results.Single().Count.Should().Be(1);
57-
}
58-
5929
[Fact]
6030
public void Aggregate_out_to_time_series_collection_on_secondary_should_work()
6131
{

tests/MongoDB.Driver.Tests/UnifiedTestOperations/UnifiedTestRunner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ private void AddInitialData(IMongoClient client, BsonArray initialData, UnifiedE
197197
#pragma warning restore CS0618 // Type or member is obsolete
198198

199199
var writeConcern = WriteConcern.WMajority;
200-
if (client.Cluster.Description.Type == ClusterType.ReplicaSet)
200+
if (DriverTestConfiguration.IsReplicaSet(client))
201201
{
202202
// Makes server to wait for ack from all data nodes to make sure the test data availability before running the test itself.
203203
// It's limited to replica set only because there is no simple way to calculate proper w for sharded cluster.
204-
var dataBearingServersCount = client.Cluster.Description.Servers.Count(s => s.IsDataBearing);
204+
var dataBearingServersCount = DriverTestConfiguration.GetReplicaSetNumberOfDataBearingMembers(client);
205205
writeConcern = WriteConcern.Acknowledged.With(w: dataBearingServersCount, journal:true);
206206
}
207207

0 commit comments

Comments
 (0)