MongoDB DNS seedlist#750
Merged
Merged
Conversation
3863f54 to
aec02b5
Compare
added 10 commits
June 20, 2018 22:10
Test dnsjava in SBT REPL to resolve SRV records:
```scala
import org.xbill.DNS._
scala> new Lookup(s"_imaps._tcp.gmail.com", Type.SRV).run()
// => Array[org.xbill.DNS.Record] = Array(_imaps._tcp.gmail.com. 21599 IN SRV 5 0 993 imap.gmail.com.)
// Note1: Lookup.setResolver(Lookup.getDefaultResolver.setTimeout(..))
def records(name: String): Array[Name] =
// name.count(_ == '.') >= 3
new Lookup(s"_imaps._tcp.${name}", Type.SRV).run().map(_.getAdditionalName)
// TODO: resolvedHosts.forAll(_ endsWith name.parent)
records("gmail.com")
// => Array[org.xbill.DNS.Name] = Array(imap.gmail.com.)
```
Then refactor this as first implementation directly in runnable specs (see UtilSpec).
sbt> testQuick UtilSpec -- include wip
Test in SBT console to list TXT records (as documentation is not crystal clear).
```scala
scala> import org.xbill.DNS._
import org.xbill.DNS._
scala> new Lookup("gmail.com", Type.TXT).run()
=> Array[org.xbill.DNS.Record] = Array(gmail.com. 299 IN TXT "v=spf1 redirect=_spf.google.com")
scala> new Lookup("gmail.com", Type.TXT).run().map(_.rdataToString)
=> Array[String] = Array("v=spf1 redirect=_spf.google.com")
```
Then add `txtRecords` in runnable specification `UtilSpec`.
sbt> testQuick UtilSpec -- include wip
- Move `srvRecords` to package object `reactivemongo.util`, with `resolver` parameter refactored as `timeout`.
- Add scaladoc
- Update `UtilSpec` accordingly.
testOnly UtilSpec -- include wip
- Move `txtRecords` to `reactivemongo.util` with `resolver` parameter refactored as `timeout`.
- Add scaladoc
- Update `UtilSpec` accordingly.
testOnly UtilSpec -- include wip
Refactor functions `srvRecords` and `txtRecords` to return `Future`, with error handling. Also support port in `srvRecords`. Execute `testOnly UtilSpec` with SBT to check there is no regression.
Update the parsing of the options for the connection URI, to be able to change the default values, as `sslEnabled` default value must be enforced when using seed list. Check there is no regression running `testOnly MongoURISpec` in the SBT console.
Update the parsing of the connection URI. - Pass down the flag indicating whether the URI is about a seed list. - Strip the options from the URI when it's parsed, to more easily parse the node set. Make sure there is no regression running `testOnly MongoURISpec` in SBT.
Refactor `srvRecords` to introduce an abstraction over DNS resolution, so that can be later mock, to test the validations specific to seed list, whatever is the underlying SRV resolution. Use it in the parsing of the connection URI if seed list is required. Update and execute the corresponding `UtilSpec`.
Use mock for `SRVResolver` in the runnable specs about URI parsing. Execute `testQuick MongoURISpec` to check there is no regression.
Add test about handling the seed list in the parsing for the connection URI. Run it with SBT using `testOnly MongoURISpec -- include wip` . As this new test detects the `option.sslEnabled` is not forced to true when the URI is specifying seed list, fix it.
97f64eb to
f2ce750
Compare
added 8 commits
June 25, 2018 21:36
Add tests to check erroneous cases from SRV resolution are handled when parsing seed list from a connection URI. Execute `testQuick MongoURISpec` from SBT.
- Update `txtRecords` return type; - Update `UtilSpec` as failing after `txtRecords` changes. Execute `testQuick UtilSpec` in SBT.
Refact `txtRecords` and use it in the parsing of the connection URI, to parse options from TXT records, overridden by values directly in URI, for the options defined in both. Make sure there is no regression running `testQuick MongoURISpec` in SBT.
Refactor `txtRecords` to return a function type, that can later be mock. Execute `testQuick MongoURISpec UtilSpec` with SBT to ensure there is no regression.
Refactor the parsing of the connection URI to pass TXT resolver as parameter. Update the tests and execute them with `testQuick MongoURISpec UtilSpec` in SBT.
Update the tests about seed list to check it's ok with credentials and DB name in the URI.
sbt 'testQuick MongoURISpec'
As it fails, update the parsing to fix it.
Add a test about handling TXT records as option while parsing connection URI. The tests are executed with `testQuick MongoURISpec` using SBT.
CI is failing: https://travis-ci.org/ReactiveMongo/ReactiveMongo/jobs/396612535#L2229 Revert the refactoring of `parseHosts` as `ListSet` order is not compatible between Scala versions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.