Skip to content

DRIVERS-1713 Convert change stream tests to unified format #1156

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

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Mar 16, 2022

DRIVERS-1713

This PR pulls in the test conversion that was done earlier in mongodb/mongo-rust-driver#570. There was a little bit of merging needed in change-streams.yml because some new tests had been added since the conversion, but otherwise it's all a direct copy.

@abr-egn abr-egn requested a review from a team as a code owner March 16, 2022 16:58
@abr-egn abr-egn requested review from benjirewis and removed request for a team March 16, 2022 16:58
Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

Thanks for taking on this conversion! 🧑‍🔧 Haven't looked at all the converted tests yet; just a few initial comments.

@abr-egn abr-egn requested a review from benjirewis March 21, 2022 14:45
aggregate: *collection0
cursor: {}
pipeline:
- $changeStream: {}
Copy link
Member

Choose a reason for hiding this comment

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

Note: drivers that have yet to implement DRIVERS-2231 will fail this assertion. I don't think we need to fix that here, but we should note that here, but it would be good to bring it up in the downstream changes for this issue. I'll also add a "has to be done after" relationship between the issues.

Previously, the POC change stream tests used $$unsetOrMatches for fullDocument here. I opened DRIVERS-2261 to clean that up.

@jmikola
Copy link
Member

jmikola commented Apr 1, 2022

Just POC-ed these tests in PHPLIB, and apart from the comment tests lumped in here (likely from another PR) they passed after fixing a bug in our test runner with $$exists nested within $$unsetOrMatches (see: PHPLIB-831).

Will wait on suggested fixes above to be merged and this PR rebased, and then take a final review pass.

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.

I just noticed this PR introduces global entities, which I think may be redundant. Please check that out and report back.

Also left various formatting suggestions that might make the test files more readable/maintainable (disregard as you wish, since those aren't functional changes). I did point out one place where you used a literal string instead of a YAML reference, so that might be worth looking into even if the style suggestions are ignored.

pipeline: []
saveResultAsEntity: &changeStream0 changeStream0
- name: insertOne
object: *globalCollection0
Copy link
Member

@jmikola jmikola Apr 4, 2022

Choose a reason for hiding this comment

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

I realize the tests in poc-change-streams.yml did use separate collections for running insertOne, but I don't recall why that was done. Interestingly, the current unified tests in change-streams.yml don't do this and share the same collection object used to create the change stream.

I'd see if you can make do without this and, if so, remove all of the global entities added in this PR. I wouldn't object to stripping them from the POC file as well, but we can always punt on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The globalClient and associated data entities aren't strictly necessary AFAICT; the tests can be edited to only use client0 and add the insert to the expected command events. I'm not sure that's an improvement on the current setup, though, since it's adding noise to the expected output (these are testing change streams, not insert).

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I re-read the POC spec tests again and it looks like those separate collections did have their own client. That was likely done for ignoring insert in the APM events, as you pointed out.

The tests in change-streams.yml vary. Some don't expect events at all, and others include the insert command.

I suppose a third option is just to add insert to ignoreCommandMonitoringEvents if you'd like to avoid the extra entities, but I won't push for that. Totally up to you and I'm OK with leaving this as-is (thanks for indulging my questions).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, forgot to actually reply here :) I'd prefer to leave it as-is - none of the other options seem worth the churn.

- killCursors
useMultipleMongoses: false
- client:
id: &globalClient globalClient
Copy link
Member

Choose a reason for hiding this comment

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

Per my comments above, I'll note that none of the existing tests in this file required global clients, databases, or collections.

That said, if these tests will operate on multiple collections you may want to explicitly initialize those in initialData (as I did in poc-change-streams.yml).

@abr-egn
Copy link
Contributor Author

abr-egn commented Apr 6, 2022

Still working on the style updates but wanted to continue the discussion of client entities while I do that :)

- replicaset
- sharded
- load-balanced
topologies: [ replicaset, sharded, load-balanced ]
Copy link
Member

Choose a reason for hiding this comment

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

Is there a particular reason that load-balanced is included here but omitted in most later test requirements?

Separate question: if the main difference in test requirements is server versions, perhaps we can add a top-level runOnRequirements block with `minServerVersion: "3.6.0" and relevant topologies and reduce duplication in this file? Then, test-level requirements can just specify version requirements as needed.

Copy link
Contributor Author

@abr-egn abr-egn Apr 7, 2022

Choose a reason for hiding this comment

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

All of the constraints here were just ported straight from the legacy tests; I don't know why they were that way. I consolidated everything to use a top-level list that includes load-balanced (and validated that they pass on the rust driver in that configuration).

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.

Tested in PHPLIB. Various tests were skipped due to my local server version and there were a few failures due to us not having implemented comment, but everything looks OK otherwise.

Copy link
Contributor

@benjirewis benjirewis left a comment

Choose a reason for hiding this comment

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

These look great! They seem to work in the Go driver with additional logic for rename and ignoreExtraEvents. Thanks for the careful review responses. There are some merge conflicts that I think you'll have to handle, though.

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.

3 participants