Skip to content

RUST-979 Non-unified spec tests for load balancer support behavior #473

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 17 commits into from
Sep 27, 2021

Conversation

abr-egn
Copy link
Contributor

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

RUST-979

This pulls in changes and additions to non-unified spec tests (and, in one case, implements a prose test) that validate various behaviors in support of load balancer functionality.

#[builder(default, setter(skip))]
#[serde(skip)]
pub(crate) allow_load_balanced: bool,
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 particular gate key turned out to be more hassle than it was worth - it meant that attempting to parse options from test json would fail without jumping through a lot of hoops. The options validation now enforces that the load_balanced option is test-only, which seems a reasonable degree of protection.

pub(crate) heartbeat_freq: Option<Duration>,

/// Disable server and SRV-polling monitor threads.
pub(crate) disable_monitoring_threads: bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously known as Topology::new_mocked.

localhost_test_build_10gen(27018),
]));
let topology = Topology::new(options).unwrap();
RUNTIME.delay_for(rescan_interval * 2).await;
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 is unfortunately long, but also mandated by the spec :(

@@ -168,8 +94,6 @@ impl Topology {
handler.handle_topology_opening_event(event);
}

let hosts: Vec<_> = options.hosts.drain(..).collect();
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 drain was actually causing subtle bugs because code below expected options.hosts to still be populated. As far as I can tell it's fine to remove - it'll just populate the topology server map with some temporary values that get immediately overwritten by the add_new_server loop below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wow good catch. And yeah that seems fine.

} else {
ClientOptions::parse(&test_file.uri).await
};
async fn run_test(mut test_file: TestFile) {
Copy link
Contributor Author

@abr-egn abr-egn Sep 23, 2021

Choose a reason for hiding this comment

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

Despite what github's diff would tell you, this was moved mostly unchanged, the two deltas being:

  • the load_balanced skip
  • ResolvedOptions matching moved to a method

// SRV polling is not done for load-balanced clusters.
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
async fn load_balanced_no_srv_polling() {
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 has a different form than the other tests because those directly fire server updates, skipping the rest of the srv-polling machinery, whereas this one needs to test that the dns polling doesn't happen at all.

@abr-egn abr-egn marked this pull request as draft September 24, 2021 15:16
@abr-egn abr-egn force-pushed the RUST-979/lb-non-unified-tests branch from 4227a9f to c3e171d Compare September 24, 2021 15:31
} else {
ClientOptions::parse(&test_file.uri).await
};
// TODO RUST-979 unskip these tests
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 will require an evergreen config for running tests against a loadbalancer, which will come in a follow-up PR.

@abr-egn abr-egn marked this pull request as ready for review September 27, 2021 13:15
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.

One request for a minor comment, but otherwise LGTM! (don't need another round of review after the comment is added)

@@ -102,3 +104,24 @@ async fn timeout_error() {
async fn no_results() {
run_test(Ok(Vec::new()), DEFAULT_HOSTS.iter().cloned().collect()).await;
}

// SRV polling is not done for load-balanced clusters.
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 update this comment to refer to the spec that contains this prose test?

@@ -168,8 +94,6 @@ impl Topology {
handler.handle_topology_opening_event(event);
}

let hosts: Vec<_> = options.hosts.drain(..).collect();
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh wow good catch. And yeah that seems fine.

@abr-egn abr-egn force-pushed the RUST-979/lb-non-unified-tests branch from a93b58d to bbedec2 Compare September 27, 2021 16:42
@abr-egn abr-egn merged commit 214ed2c into mongodb:master Sep 27, 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.

2 participants