Skip to content

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

Merged
merged 25 commits into from
Jan 14, 2019
Merged

Add uri options tests #414

merged 25 commits into from
Jan 14, 2019

Conversation

saghm
Copy link
Contributor

@saghm saghm commented Nov 13, 2018

No description provided.

Copy link
Contributor

@prashantmital prashantmital left a 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?

Copy link
Contributor

@prashantmital prashantmital left a 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.

@prashantmital
Copy link
Contributor

@saghm can we add another test to test the 'last entry wins' parsing logic? For instance, zlibcompression=3&zlibCompressionLevel=4&zlibCompressionLevel=8 should result in zlibCompressionLevel=8. This would also nail down the warning behavior (should drivers raise a warning?) for this case.

@saghm
Copy link
Contributor Author

saghm commented Nov 16, 2018

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.

@prashantmital
Copy link
Contributor

Python POC has been updated with the new TLS option names.

Copy link
Member

@jmikola jmikola left a 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"
Copy link
Contributor

@prashantmital prashantmital Dec 19, 2018

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?

Copy link
Contributor Author

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"
Copy link
Contributor

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.

Copy link
Contributor

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).

Copy link
Contributor

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.

Copy link
Contributor Author

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"
Copy link
Contributor

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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

@saghm
Copy link
Contributor Author

saghm commented Jan 9, 2019

@prashantmital are these working with the Python driver now?

@jyemin jyemin self-requested a review January 10, 2019 12:55
=================

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
Copy link
Contributor

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"?

Copy link
Contributor Author

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",
Copy link
Contributor

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?

Copy link
Contributor Author

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: ~
Copy link
Contributor

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.

Copy link
Contributor Author

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:
Copy link
Contributor

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}

Copy link
Contributor Author

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"
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be warning: true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, thanks

@saghm saghm merged commit 99a5f80 into mongodb:master Jan 14, 2019
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.

6 participants