-
Notifications
You must be signed in to change notification settings - Fork 244
Add uri options tests #414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The presence of null
-valued keys in the hosts
and auth
object arrays seems unnecessary and makes changes to the connection-string
test-runner necessary. Can you comment on why/if we need to keep these keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there are some inconsistencies/ambiguities with the validation applied to the URI options during parsing. While we do expect incorrectly formatted readPreferenceTags
to raise warnings, inadmissiblereadPreference
values are not expected to do the same. Similarly, it is unclear whether any warnings are raised when the user passes cert files that don't exist/are not readable.
I think we should validate all options against their 'Accepted values' from the spec. If that validation fails, we should raise a warning.
@saghm can we add another test to test the 'last entry wins' parsing logic? For instance, |
The connection string spec is pretty explicit about not mandating a specific mechanism to resolve duplicate keys, and I'm not convinced that we should change that. |
Python POC has been updated with the new TLS option names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaving a LGTM, as I'm out sick today and don't want to hold things up further. If you'd like to address the last couple of comments I made (re: invalid tests for numeric and boolean options), feel free to do so and resolve the comment threads. If not, feel free to resolve them just the same and proceed without any changes.
"authmechanism": "GSSAPI", | ||
"authMechanismProperties": { | ||
"SERVICE_NAME": "other", | ||
"CANONICALIZE_HOST_NAME": "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this string "true"
instead of boolean true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure if we should be prescriptive about how/when drivers parse the authMechanismProperties from strings. Since it's a lot easier to go from the boolean to the string than from the string to the boolean though, I'll update this to use the boolean.
hosts: ~ | ||
auth: ~ | ||
options: | ||
compressors: "zlib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since compressors
is a
comma separated list of strings, e.g. “snappy,zlib”
I think this should be 1-member list with "zlib"
as its only member.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I suppose this isn't necessary (since it could just be a string with comma-separated values).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it should be a list, and there should be another test that contains multiple compressors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add these changes
"tls": true, | ||
"tlsCAFile": "ca.pem", | ||
"tlsCertificateKeyFile": "cert.pem", | ||
"tlsCertificateKeyPassword": "hunter2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "tlsCertificateKeyFilePassword"
.
"options": { | ||
"readPreference": "primaryPreferred", | ||
"readPreferenceTags": [ | ||
"dc:ny,rack", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not reflect the rack:1
from the YAML file. You might need to regenerate the JSONs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to update the JSON files before pushing; I'll do that now
171c2e9
to
d91db3b
Compare
@prashantmital are these working with the Python driver now? |
source/uri-options/tests/README.rst
Outdated
================= | ||
|
||
Testing whether a URI is valid or not requires testing whether URI parsing (or | ||
MongoClient construction) causes a warning due to a URI option being valid and asserting that the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should that be "being invalid"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, good catch!
{ | ||
"tests": [ | ||
{ | ||
"description": "Valid auth options are parsed correctly", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this test. It's saying that you should be able to specify all the auth options, but if there's no user name, auth should be disabled (but the auth properties should still be accessible)?
Java driver doesn't support this, as the ConnectionString returns a fully formed MongoCredential, not individual properties?
Would it go against the purpose of this test to add a username to the URI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hadn't considered that drivers might parse all options into a single object at once; I can add a username to this test.
warning: true | ||
hosts: ~ | ||
auth: ~ | ||
options: ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll make it easier for test runner writers if options is always a document, even if sometimes empty, rather than sometimes a document and sometimes null. I see other places where it is an empty document, so let's use that everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
auth: ~ | ||
options: | ||
readPreference: "primaryPreferred" | ||
readPreferenceTags: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make these match the format used my MongoDB, using documents rather than strings:
- {dc: ny, rack: 1}
- {dc: ny}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
hosts: ~ | ||
auth: ~ | ||
options: | ||
compressors: "zlib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it should be a list, and there should be another test that contains multiple compressors.
"description": "Invalid serverSelectionTryOnce causes a warning", | ||
"uri": "mongodb://example.com/?serverSelectionTryOnce=invalid", | ||
"valid": true, | ||
"warning": false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be warning: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, thanks
No description provided.