[CSHARP-3878] Make sure DisposableMongoClient has a unique underlying Cluster Created: 23/Sep/21  Updated: 24/Sep/21  Resolved: 24/Sep/21

Status: Closed
Project: C# Driver
Component/s: Testing
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Unknown
Reporter: Robert Stam Assignee: Robert Stam
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Surprisingly this hasn't happened to us before, but today I wrote a test using a `DisposableMongoClient` that resulted in the rest of the test suite failing.

The new test looked like this:

var clientSettings = DriverTestConfiguration.Client.Settings.Clone();
// make some minor changes to the clientSettings
using (var client = DriverTestConfiguration.CreateDisposableClient(clientSettings))
{
    // the test
}

What happened was that the changes made to `clientSettings` were minor enough that they did not result in a new underlying `Cluster` being created. So when the `DisposableMongoClient` was `Disposed` so was the underlying `Cluster`.

But once that happend all other tests that use `DriverTestConfiguration.Client` (which is almost all tests) started failing because that `MongoClient` instance had its `Cluster` disposed out from under it.

The simplest way to make the `ClusterKey` for ` DisposableMongoClient` unique is to instantiate a new `ClusterConfigurator`, wrapping any existing one.

 



 Comments   
Comment by Githook User [ 24/Sep/21 ]

Author:

{'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}

Message: CSHARP-3878: Make sure DisposableMongoClient has a unique underlying Cluster.
Branch: master
https://github.com/mongodb/mongo-csharp-driver/commit/a10a07506f2ac9032fccef24d6f578c19ec782ad

Generated at Wed Feb 07 21:46:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.