Skip to content

Conversation

@kmahar
Copy link
Contributor

@kmahar kmahar commented May 28, 2020

This builds on my previous PR to add libmongoc support for directConnection=true to give us the desired discover behavior by default.

You can view a summary of the spec changes here.

I was able to pull in the relevant initial DNS seedlist discovery tests as we implement that test runner, but the other tests use the SDAM and connection string test runners which we do not implement yet.

I did some manual local testing using SDAM monitoring and everything seems to work as expected in terms of initial topology assumptions as well as errors being reported in the right scenarios.

let hostAddress = try ServerAddress(host)

// check event count and that events are of the expected types
expect(receivedEvents.count).to(beGreaterThanOrEqualTo(5))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

in this test we previously saw:

  • A topology opening event
  • A topology changed event (change from unknown to single, no hosts in list)
  • A server opening event
  • A server changed event, from unknown to standalone
  • A topology changed event, adding in the new server to the topology

We now see:

  • A topology opening event
  • A server opening event
  • A server changed event, from unknown to standalone
  • A topology changed event, from unknown to single

Previously in this case libmongoc by default would behave like the directConnection=true option was specified, which meant the topology would be assumed to be single right off the bat before discovering servers. Now that we specify directConnection=false that transition doesn't happen until the server has been discovered.

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2020

Codecov Report

Merging #490 into master will decrease coverage by 0.18%.
The diff coverage is 51.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #490      +/-   ##
==========================================
- Coverage   76.98%   76.79%   -0.19%     
==========================================
  Files         125      125              
  Lines       13050    13080      +30     
==========================================
- Hits        10046    10045       -1     
- Misses       3004     3035      +31     
Impacted Files Coverage Δ
Tests/BSONTests/DocumentTests.swift 98.09% <ø> (-0.01%) ⬇️
Tests/MongoSwiftSyncTests/SDAMTests.swift 65.15% <45.45%> (ø)
Sources/MongoSwift/ConnectionString.swift 70.76% <87.50%> (+1.09%) ⬆️
Sources/MongoSwift/MongoClient.swift 87.17% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 24de514...1e4cfaa. Read the comment docs.

Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

lgtm. I think in the commit message / ticket / release notes we should mention the behavioral change that came from this, since it is kind of hard to surmise it from the ticket name.

Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

I wonder if it's worth adding a test that verifies this option works, something like:

  • only run against replica sets
  • split up URI into separate hosts
  • connect to each of them separately (with directConnection unspecified) and try to perform an insert
  • assert insert worked (meaning each discovered the primary)

Possibly repeat the test with directConnection=true and verify at least one of the attempts failed.

@kmahar kmahar requested a review from nbbeeken May 29, 2020 16:43
@kmahar
Copy link
Contributor Author

kmahar commented May 29, 2020

whoops sorry I missed adding you somehow @nbbeeken. I will take a crack at adding a test like that now @patrickfreed

@kmahar
Copy link
Contributor Author

kmahar commented May 29, 2020

test added; was actually very easy thanks to the getConnectionStringPerHost() helper 🙂

@kmahar kmahar requested a review from patrickfreed May 29, 2020 17:13
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

test looks good, one doc suggestion, and I think this needs to be rebased off of master to get the error changes

public var dateCodingStrategy: DateCodingStrategy?

/// When true, the client will connect directly to a single host. When false, the client will attempt to
/// automatically discover all replica set members if a replica set name is provided.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should mention that the default behavior is the false one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, I had that in here but it seems like I accidentally deleted it, good catch. added

@kmahar kmahar force-pushed the SWIFT-742/unified-repl-set-discovery branch from 33463d9 to 1e4cfaa Compare May 29, 2020 21:54
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

lgtm!

@kmahar kmahar merged commit ca167f2 into master May 29, 2020
@kmahar kmahar deleted the SWIFT-742/unified-repl-set-discovery branch May 29, 2020 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants