Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3878

Make sure DisposableMongoClient has a unique underlying Cluster

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Testing
    • None

      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.

       

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: