-
Notifications
You must be signed in to change notification settings - Fork 245
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
DRIVERS-1675 Add log messages and tests to CMAP spec #1324
Conversation
|
||
The YAML and JSON files in this directory are platform-independent tests that |
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 content has been moved unchanged into /tests/cmap-format/README.rst
|
||
runOnRequirements: | ||
- topologies: | ||
- single # The number of log messages is different for each topology since there is a connection pool per host. |
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 considered writing per-topology versions of these tests but it didn't seem like the extra coverage would have a ton of value assuming drivers have well-abstracted connection pools that don't care about what topology type they live in. it looks like the existing CMAP integration tests also only instruct drivers to only run them against a single host in whatever topology they are connected to.
source/connection-monitoring-and-pooling/tests/logging/connection-logging.yml
Show resolved
Hide resolved
source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
Outdated
Show resolved
Hide resolved
source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
Outdated
Show resolved
Hide resolved
source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
Outdated
Show resolved
Hide resolved
source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
Outdated
Show resolved
Hide resolved
source/connection-monitoring-and-pooling/tests/logging/connection-logging.yml
Show resolved
Hide resolved
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.
Unified changes LGTM although I have one question. Not going to review the CMAP stuff.
@@ -1634,6 +1634,18 @@ specifications: | |||
Client operations that require special handling or are not documented by an | |||
existing specification are described below. | |||
|
|||
close |
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.
Just to confirm: is this the first PR introducing spec tests with a client.close
operation?
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.
Yes, from a search through the specs repo the only other occurrences of the close
operation I can find are for cursors and change streams. All of those occurrences are in the load balancer tests.
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.
Indeed, that operation is already documented in Cursor Operations. Thanks for confirming.
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.
FYI @jmikola I made a small addition to the paragraph here to clarify that entities descended from a closed client should also not be used after a close
.
subscriber if it is convenient to do so. | ||
|
||
The types used in the structured message definitions below are demonstrative, and drivers MAY use similar types instead so long as the information | ||
is present (e.g. a double instead of an integer, or a string instead of an integer if the structured logging framework does not support numeric types.) |
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.
nit: period at the end of the sentence?
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.
moved period out of the parentheses
message: "Connection checkout failed" | ||
serverHost: { $$type: string } | ||
serverPort: { $$type: [int, long] } | ||
reason: "An error occurred while trying to establish a connection" |
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 probably should be "An error occurred while trying to establish a new connection" ?
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.
yes good catch, I accidentally omitted the "new" here and in Rust impl. fixed.
FYI: It came up in driver-devs that Ruby does not close the connection pool when a client is closed. I was thinking about how these tests would work (or not work) for Ruby and I noticed all of the connection-pool-options tests were unnecessarily closing the client and expecting a corresponding log message so I have removed those. I think Ruby will just have to skip the one test that does need the close and write some prose test to cover that log message. |
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.
LGTM (minor comment)
serverHost: { $$type: string } | ||
serverPort: { $$type: [int, long] } | ||
|
||
# This test exists to probide coverage of checkout failed and pool cleared events. |
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.
typo: provide
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.
thanks, fixed.
|
||
The unstructured form SHOULD be as follows, using the values defined in the structured format above to fill in placeholders as appropriate: | ||
|
||
Connection checked out with driver-generated ID {{driverConnectionId}} to {{serverHost}}:{{serverPort}} |
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 is kind of a grammar nit, but I think this message reads a bit easier if the "with id" and "to <address>" phrases came before the verb here, since they're describing "Connection". If you drop the "with" part, the issue is a bit more obvious (e.g. "Connection checked out to a:12345" doesn't quite make sense).
Something like "Connection to a:12345 with driver-generated ID checked out" reads a bit better to me. The drawback with that is "Connection" and "checked out" are now separate, though I'm not sure if that's an issue or not. A more dramatic shift that doesn't have either problem could be something like "Connection checked out (driver-generated ID=1, destination=a:12345)".
WDYT?
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.
yeah I was having a hard time figuring out how to write the english for some of these and it shows here 😅
re-reading this I had a couple thoughts:
- I feel like the host/port should come before the ID as it feels more important given that IDs are only unique per-pool/endpoint
- maybe "for" would be a better word than to?
I do think keeping the "Connection checked out" part together and at the start of the message is useful so that if you are skimming you can easily see what the message is about from the start of it.
given these WDYT of either of the following:
- Connection checked out for endpoint a:12345 with driver-generated ID 123
- Connection checked out: endpoint=a:12345, driver-generated ID=123.
(borrowing "endpoint" terminology from elsewhere in CMAP)
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 kinda like 2. It's consistent and pretty easy to parse visually (and programatically in case a given language can't do structured logs).
"endpoint" is spec language-y though, I'm not sure if it ends up in our API or docs that often. What about just using "address" like the events do?
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.
cool, I updated to the second one (but with address instead of endpoint) and updated some of the other log messages to make the format/phrasing more consistent
source/connection-monitoring-and-pooling/connection-monitoring-and-pooling.rst
Show resolved
Hide resolved
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.
LGTM!
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.
LGTM
Please complete the following before merging:
This PR includes the following:
tests/cmap-format
directory, and the logging tests live in atests/logging
directory. Additionally, I moved all the content on the CMAP format tests into a new README intests/cmap-format
and edited the top-level README to discuss the different types of CMAP tests. I don't have strong feelings on the naming or particular organization here, so if anyone prefers something else, let me know. This just seemed like a logical enough way to do it.close
operation to the unified test format. This is required to be able to test pool close messages. Per a recent conversation with @jmikola I don't believe this warrants a new minor schema version: "Drivers are supposed to raise errors for unsupported operations so I'm not at all concerned about bumping a schema version for it. The reasoning behind schema changes is that drivers might silently ignore new syntax."The new tests pass in the Rust driver, but there are a few of them I had to skip from
connection-pool-options.yml
due to options we don't support. So if another driver is able to test these and let me know if they work for you, please let me know:For the latter two I wasn't sure if they were worth including given that the options are deprecated, but at least the .NET driver still supports those options so it seemed they would provide value to them. (cc @BorisDog)
I will leave some comments inline.