From 6d4e3162470e63206a0cecf211e7c1ac2961b29e Mon Sep 17 00:00:00 2001 From: Valentin Kovalenko Date: Tue, 31 Oct 2023 13:21:00 -0600 Subject: [PATCH] RUST-1231 Run tests using `DEFAULT_MAX_POOL_SIZE` (#980) --- src/client/options.rs | 2 +- src/cmap.rs | 2 +- .../description/topology/server_selection/test/in_window.rs | 4 ++-- src/test.rs | 5 ----- 4 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/client/options.rs b/src/client/options.rs index a905c3b7e..2575f2d40 100644 --- a/src/client/options.rs +++ b/src/client/options.rs @@ -802,7 +802,7 @@ pub struct ConnectionString { /// `max_pool_size` connections are checked out, the operation will block until an in-progress /// operation finishes and its connection is checked back into the pool. /// - /// The default value is 100. + /// The default value is 10. pub max_pool_size: Option, /// The minimum number of connections that should be available in a server's connection pool at diff --git a/src/cmap.rs b/src/cmap.rs index 894dd5e82..dd4ca5d1c 100644 --- a/src/cmap.rs +++ b/src/cmap.rs @@ -46,7 +46,7 @@ use worker::ConnectionPoolWorker; #[cfg(test)] use crate::runtime::WorkerHandle; -const DEFAULT_MAX_POOL_SIZE: u32 = 10; +pub(crate) const DEFAULT_MAX_POOL_SIZE: u32 = 10; /// A pool of connections implementing the CMAP spec. /// This type is actually a handle to task that manages the connections and is cheap to clone and diff --git a/src/sdam/description/topology/server_selection/test/in_window.rs b/src/sdam/description/topology/server_selection/test/in_window.rs index fc519a904..dfa93347d 100644 --- a/src/sdam/description/topology/server_selection/test/in_window.rs +++ b/src/sdam/description/topology/server_selection/test/in_window.rs @@ -6,6 +6,7 @@ use semver::VersionReq; use serde::Deserialize; use crate::{ + cmap::DEFAULT_MAX_POOL_SIZE, coll::options::FindOptions, error::Result, event::cmap::CmapEvent, @@ -216,10 +217,9 @@ async fn load_balancing_test() { let mut handler = EventHandler::new(); let mut subscriber = handler.subscribe(); let mut options = CLIENT_OPTIONS.get().await.clone(); - let max_pool_size = 10; + let max_pool_size = DEFAULT_MAX_POOL_SIZE; let hosts = options.hosts.clone(); options.local_threshold = Duration::from_secs(30).into(); - options.max_pool_size = Some(max_pool_size); options.min_pool_size = Some(max_pool_size); let client = TestClient::with_handler(Some(Arc::new(handler.clone())), options).await; diff --git a/src/test.rs b/src/test.rs index b96bf78f2..73e60c861 100644 --- a/src/test.rs +++ b/src/test.rs @@ -56,8 +56,6 @@ use crate::{ }; use std::{fs::read_to_string, str::FromStr}; -const MAX_POOL_SIZE: u32 = 100; - lazy_static! { pub(crate) static ref CLIENT_OPTIONS: AsyncOnce = AsyncOnce::new(async { let mut options = ClientOptions::parse_uri(&*DEFAULT_URI, None).await.unwrap(); @@ -113,9 +111,6 @@ lazy_static! { } pub(crate) fn update_options_for_testing(options: &mut ClientOptions) { - if options.max_pool_size.is_none() { - options.max_pool_size = Some(MAX_POOL_SIZE); - } if options.server_api.is_none() { options.server_api = SERVER_API.clone(); }