[CDRIVER-1954] Implement getters for internal fields of mongoc_find_and_modify_opts_t Created: 13/Dec/16 Updated: 05/Jan/17 Resolved: 05/Jan/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.6.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Samuel Rossi (Inactive) | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
To test that the options are getting passed through correctly to the C driver, the C++ driver implements tests that "interpose" between the C driver's database calls and assert that the options are what they're supposed to be. In order to implement |
| Comments |
| Comment by Githook User [ 05/Jan/17 ] | ||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | ||||||||||
| Comment by J Rassi [ 16/Dec/16 ] | ||||||||||
|
I agree with Sam that mongoc_find_and_modify_opts_t seems inconsistent with the other C driver options-like structs in that it cannot be introspected. Users of the C driver other than the C++ driver project could also find such introspection useful (for example: for being able to copy a mongoc_find_and_modify_opts_t, for debugging, or for their own unit testing). Note that our specific need could also be satisfied with some sort of BSON serialization function (like mongoc_write_concern_append()) or equality function, as the particular use that Sam lays out in the ticket description is fundamentally for being able to tell if two mongoc_find_and_modify_opts_t structs are equal. That said, this request is not a requirement for the C++ driver; if you decide to close this "Won't Fix", we'll simply test our find_and_modify() functionality with integration testing alone. The C++ driver is moving towards integration testing instead of unit testing for API functionality anyway. | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 15/Dec/16 ] | ||||||||||
|
We're willing to implement these getters if it's absolutely necessary. But it's a bummer to add more functions that we must maintain forever, only for the sake of C++ driver tests. Here's what I propose. Follow the lead of the PyMongo maxTimeMS test. First, in your test suite, check if the server version is 2.6 or later, and that it has failpoints enabled. Here's how to check in the shell that failpoints are enabled:
If you started the server with --setParameter enableTestCommands=1 then the output will be (in MongoDB 2.6+):
If the server is older than 2.6 or doesn't have failpoints enabled, skip your maxTimeMS test. Otherwise, configure maxTimeMS to always time out. In the shell:
Now you can verify you're passing maxTimeMS to the server correctly, by asserting that a findandmodify with no maxTimeMS succeeds, but with maxTimeMS it fails with error code 50:
Now fix the server:
This is a little complicated, but it's how other drivers have tested their maxTimeMS implementation. It's a good end-to-end test. We implemented this failpoint, and we enable failpoints on Evergreen, precisely so that tests like this are possible. | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 14/Dec/16 ] | ||||||||||
|
We didn't deprecate mongoc_collection_find_and_modify_with_opts. It's still special: if you set a write concern, FAM_with_opts uses the write concern if the wire version >= 4. Whereas mongoc_client_write_command_with_opts and co. use the write concern if wire version >= 5. (Because the server implemented write concern for findAndModify in MongoDB 3.2, and for other commands-that-write like dropCollection in MongoDB 3.4.) | ||||||||||
| Comment by Hannes Magnusson [ 14/Dec/16 ] | ||||||||||
|
Didn't we more or less deprecate the mongoc_find_and_modify_opts_* with the introduction of mongoc_*_*_command_with_opts() ? | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 14/Dec/16 ] | ||||||||||
|
You want these functions?:
|