Skip to content

RUST-980 Run load balancer tests on evergreen, and update existing tests #477

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 34 commits into from
Oct 6, 2021

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Sep 29, 2021

RUST-980

This adds evergreen configuration to run the tests against a load-balancer, updates several existing tests to run on that topology, and fixes several bugs that those tests revealed.

A few unrelated changes got picked up in test syncs: serverless run configuration (which the runner already understood) and language changes.

@@ -313,6 +313,7 @@ impl Connection {
let (tx, rx) = mpsc::channel(1);
self.pinned_sender = Some(tx);
Ok(PinnedConnectionHandle {
id: self.id,
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 isn't needed for functionality, but it's very handy for debugging.

@@ -78,6 +78,10 @@ async fn concurrent_connections() {
let _guard = LOCK.run_exclusively().await;

let mut options = CLIENT_OPTIONS.clone();
if options.load_balanced.unwrap_or(false) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

direct_connection is explicitly incompatible with load_balanced.

@@ -513,13 +513,11 @@ impl ConnectionPoolWorker {
handler.handle_pool_cleared_event(event);
});

if !self.generation.is_load_balanced() {
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 swear that some part of the spec said that the queue shouldn't be drained in load-balancing mode, but I was apparently hallucinating that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Did this draining behavior cause tests to fail? Intuitively, it makes sense to not drain in LB mode, since these requests will probably go to a working service rather than the one that caused a clear.

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 - https://github.com/mongodb/mongo-rust-driver/blob/master/src/test/spec/retryable_reads.rs#L74 failed (the second checkout succeeds rather than fails), and the load balancer spec specifically calls out retryable reads tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay, so that test is specifically verifying the pool paused behavior, which shouldn't apply to load balancers. The spec doesn't currently clarify this so I filed DRIVERS-1942 to update it. In the meantime, I think we can preserve the existing behavior of not clearing the WaitQueue on pool clear if in load balanced mode and just skip that individual test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated - needed to skip the equivalent test for retryable writes as well.

}

pub fn is_sharded(&self) -> bool {
self.server_info.msg.as_deref() == Some("isdbgrid")
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 returns true for load-balanced toplogies, so to avoid having to manually maintain a bunch of fiddly boolean exclusions I refactored these.

@abr-egn abr-egn marked this pull request as ready for review October 1, 2021 11:35
@@ -513,13 +513,11 @@ impl ConnectionPoolWorker {
handler.handle_pool_cleared_event(event);
});

if !self.generation.is_load_balanced() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did this draining behavior cause tests to fail? Intuitively, it makes sense to not drain in LB mode, since these requests will probably go to a working service rather than the one that caused a clear.

@abr-egn abr-egn requested a review from patrickfreed October 5, 2021 17:47
@@ -185,13 +190,20 @@ impl Handshaker {
if options.load_balanced {
command.body.insert("loadBalanced", true);
}

#[cfg(test)]
{
Copy link
Contributor

Choose a reason for hiding this comment

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

(just out of curiosity) why does this statement need to be in its own scope?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applying attributes to individual statements turns out not to be available in stable Rust yet.

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! I just have one question but I imagine it won't result in any further changes.

@abr-egn abr-egn force-pushed the RUST-980/lb-existing-tests branch from e55cb94 to afe3a39 Compare October 6, 2021 19:09
@abr-egn abr-egn merged commit 8b8c29e into mongodb:master Oct 6, 2021
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