Skip to content

MongoDB DNS seedlist#750

Merged
cchantep merged 19 commits into
ReactiveMongo:masterfrom
cchantep:feature/dns_seedlist
Jun 26, 2018
Merged

MongoDB DNS seedlist#750
cchantep merged 19 commits into
ReactiveMongo:masterfrom
cchantep:feature/dns_seedlist

Conversation

@cchantep
Copy link
Copy Markdown
Member

No description provided.

@cchantep cchantep force-pushed the feature/dns_seedlist branch from 3863f54 to aec02b5 Compare June 20, 2018 19:30
cchantep 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.
@cchantep cchantep force-pushed the feature/dns_seedlist branch from 97f64eb to f2ce750 Compare June 25, 2018 19:13
cchantep 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.
@cchantep cchantep merged commit 4d9bb42 into ReactiveMongo:master Jun 26, 2018
@cchantep cchantep deleted the feature/dns_seedlist branch June 26, 2018 09:57
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.

1 participant