Skip to content
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

RUST-1149 Prose tests for change streams. #561

Merged
merged 34 commits into from
Jan 24, 2022

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Jan 18, 2022

RUST-1149

This implements the prose tests for change streams, with the exception of test 6, which is (a) tricky to observe and (b) essentially guaranteed to be correct by the design of the Rust driver. Some relatively minor updates were required to the change stream implementation as a result of bugs found by these tests.

.await;
new_stream.map(|cs| cs.with_type::<T>())
}));
// Iterate the loop so the new future gets polled and can register wakers.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the point of wrapping the logic in a loop - there needs to be an underlying future that's been polled rather than just returning Poll::Pending directly because with the latter this future will never be polled again due to the lack of registered wake conditions.

@abr-egn abr-egn marked this pull request as draft January 19, 2022 14:33
@abr-egn abr-egn marked this pull request as ready for review January 19, 2022 16:23
/// The [`Namespace`] containing the database and collection in which the change occurred.
Namespace(Namespace),
#[derive(Deserialize, Debug, PartialEq, Eq)]
pub struct ChangeStreamEventSource {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible this could change in the future? if so, we should keep it non_exhaustive

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call, done.


let (client, coll, mut stream) = match init_stream("track_resume_token", false).await? {
Some(t) => t,
None => return Ok(()),
Copy link
Contributor

Choose a reason for hiding this comment

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

can we log that we're skipping due to topology here? (in the spirit of #523)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

init_stream logs when it returns None :)

Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

overall looks really good, just have a few minor comments

src/test/change_stream.rs Show resolved Hide resolved
src/test/change_stream.rs Outdated Show resolved Hide resolved
@abr-egn abr-egn changed the title RUST-523 Prose tests for change streams. RUST-1149 Prose tests for change streams. Jan 20, 2022
Copy link
Contributor

@patrickfreed patrickfreed left a comment

Choose a reason for hiding this comment

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

LGTM!

@abr-egn abr-egn merged commit 637cb4d into mongodb:master Jan 24, 2022
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