Skip to content

Commit d4a217a

Browse files
authored
[2.2.x backport] RUST-1090 Fix serverless tests (#670)
1 parent 2b5da04 commit d4a217a

File tree

26 files changed

+78
-71
lines changed

26 files changed

+78
-71
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,8 @@ functions:
394394
export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
395395
export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
396396
397-
export MONGODB_URI="${MONGODB_URI}"
398397
export SSL="${SSL}"
399-
export SINGLE_MONGOS_LB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
400-
export MULTI_MONGOS_LB_URI="${MULTI_ATLASPROXY_SERVERLESS_URI}"
398+
export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"
401399
. .evergreen/generate-uri.sh
402400
403401
SNAPPY_COMPRESSION_ENABLED="true" \

.evergreen/run-serverless-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ cargo_test test::spec::sessions > sessions.xml
4545
cargo_test test::spec::transactions > transactions.xml
4646
cargo_test test::spec::load_balancers > load_balancers.xml
4747
cargo_test test::cursor > cursor.xml
48+
cargo_test test::spec::collection_management > coll.xml
4849

49-
junit-report-merger results.xml crud.xml retryable_reads.xml retryable_writes.xml versioned_api.xml sessions.xml transactions.xml load_balancers.xml cursor.xml
50+
junit-report-merger results.xml crud.xml retryable_reads.xml retryable_writes.xml versioned_api.xml sessions.xml transactions.xml load_balancers.xml cursor.xml coll.xml
5051

5152
exit $CARGO_RESULT

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ features = ["v4"]
136136

137137
[dev-dependencies]
138138
approx = "0.5.1"
139+
async_once = "0.2.6"
139140
derive_more = "0.99.13"
140141
function_name = "0.2.0"
141142
futures = "0.3"

src/client/options/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,6 @@ impl ClientOptions {
10501050
Ok(options)
10511051
}
10521052

1053-
#[cfg(test)]
1054-
pub(crate) fn parse_without_srv_resolution(s: &str) -> Result<Self> {
1055-
let parser = ClientOptionsParser::parse(s)?;
1056-
let options: Self = parser.into();
1057-
options.validate()?;
1058-
1059-
Ok(options)
1060-
}
1061-
10621053
pub(crate) fn tls_options(&self) -> Option<TlsOptions> {
10631054
match self.tls {
10641055
Some(Tls::Enabled(ref opts)) => Some(opts.clone()),

src/client/session/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ async fn cluster_time_in_commands() {
248248
F: Fn(EventClient) -> G,
249249
G: Future<Output = Result<R>>,
250250
{
251-
let mut options = CLIENT_OPTIONS.clone();
251+
let mut options = CLIENT_OPTIONS.get().await.clone();
252252
options.heartbeat_freq = Some(Duration::from_secs(1000));
253253
let client = EventClient::with_options(options).await;
254254

src/cmap/establish/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async fn speculative_auth_test(
4141
.credential(credential.clone())
4242
.build(),
4343
);
44-
pool_options.tls_options = CLIENT_OPTIONS.tls_options();
44+
pool_options.tls_options = CLIENT_OPTIONS.get().await.tls_options();
4545

4646
let description = client.topology_description().await;
4747

src/cmap/test/integration.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct DatabaseEntry {
4242
async fn acquire_connection_and_send_command() {
4343
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
4444

45-
let client_options = CLIENT_OPTIONS.clone();
45+
let client_options = CLIENT_OPTIONS.get().await.clone();
4646
let mut pool_options = ConnectionPoolOptions::from_client_options(&client_options);
4747
pool_options.ready = Some(true);
4848

@@ -86,7 +86,7 @@ async fn acquire_connection_and_send_command() {
8686
async fn concurrent_connections() {
8787
let _guard = LOCK.run_exclusively().await;
8888

89-
let mut options = CLIENT_OPTIONS.clone();
89+
let mut options = CLIENT_OPTIONS.get().await.clone();
9090
if options.load_balanced.unwrap_or(false) {
9191
log_uncaptured("skipping concurrent_connections test due to load-balanced topology");
9292
return;
@@ -117,13 +117,13 @@ async fn concurrent_connections() {
117117
.expect("failpoint should succeed");
118118

119119
let handler = Arc::new(EventHandler::new());
120-
let client_options = CLIENT_OPTIONS.clone();
120+
let client_options = CLIENT_OPTIONS.get().await.clone();
121121
let mut options = ConnectionPoolOptions::from_client_options(&client_options);
122122
options.cmap_event_handler = Some(handler.clone() as Arc<dyn crate::cmap::CmapEventHandler>);
123123
options.ready = Some(true);
124124

125125
let pool = ConnectionPool::new(
126-
CLIENT_OPTIONS.hosts[0].clone(),
126+
CLIENT_OPTIONS.get().await.hosts[0].clone(),
127127
Default::default(),
128128
ServerUpdateSender::channel().0,
129129
Some(options),
@@ -174,7 +174,7 @@ async fn concurrent_connections() {
174174
async fn connection_error_during_establishment() {
175175
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
176176

177-
let mut client_options = CLIENT_OPTIONS.clone();
177+
let mut client_options = CLIENT_OPTIONS.get().await.clone();
178178
if client_options.load_balanced.unwrap_or(false) {
179179
log_uncaptured(
180180
"skipping connection_error_during_establishment test due to load-balanced topology",
@@ -235,7 +235,7 @@ async fn connection_error_during_establishment() {
235235
async fn connection_error_during_operation() {
236236
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
237237

238-
let mut options = CLIENT_OPTIONS.clone();
238+
let mut options = CLIENT_OPTIONS.get().await.clone();
239239
let handler = Arc::new(EventHandler::new());
240240
options.cmap_event_handler = Some(handler.clone() as Arc<dyn CmapEventHandler>);
241241
options.hosts.drain(1..);

src/cmap/test/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ impl CmapThread {
122122
}
123123

124124
impl Executor {
125-
fn new(test_file: TestFile) -> Self {
125+
async fn new(test_file: TestFile) -> Self {
126126
let handler = Arc::new(EventHandler::new());
127127
let error = test_file.error;
128128

129129
let mut pool_options = test_file.pool_options.unwrap_or_default();
130-
pool_options.tls_options = CLIENT_OPTIONS.tls_options();
130+
pool_options.tls_options = CLIENT_OPTIONS.get().await.tls_options();
131131
pool_options.cmap_event_handler = Some(handler.clone());
132132
pool_options.server_api = SERVER_API.clone();
133133

@@ -156,7 +156,7 @@ impl Executor {
156156
let (update_sender, mut update_receiver) = ServerUpdateSender::channel();
157157

158158
let pool = ConnectionPool::new(
159-
CLIENT_OPTIONS.hosts[0].clone(),
159+
CLIENT_OPTIONS.get().await.hosts[0].clone(),
160160
Default::default(),
161161
update_sender,
162162
Some(self.pool_options),
@@ -427,7 +427,7 @@ async fn cmap_spec_tests() {
427427

428428
let _guard: RwLockWriteGuard<()> = LOCK.run_exclusively().await;
429429

430-
let mut options = CLIENT_OPTIONS.clone();
430+
let mut options = CLIENT_OPTIONS.get().await.clone();
431431
if options.load_balanced.unwrap_or(false) {
432432
log_uncaptured(format!(
433433
"skipping {:?} due to load balanced topology",
@@ -455,7 +455,7 @@ async fn cmap_spec_tests() {
455455
.unwrap();
456456
}
457457

458-
let executor = Executor::new(test_file);
458+
let executor = Executor::new(test_file).await;
459459
executor.execute_test().await;
460460

461461
if should_disable_fp {

src/compression/test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn test_snappy_compressor() {
6969
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
7070
#[cfg(feature = "zlib-compression")]
7171
async fn ping_server_with_zlib_compression() {
72-
let mut client_options = CLIENT_OPTIONS.clone();
72+
let mut client_options = CLIENT_OPTIONS.get().await.clone();
7373
client_options.compressors = Some(vec![Compressor::Zlib { level: Some(4) }]);
7474
send_ping_with_compression(client_options).await;
7575
}
@@ -78,7 +78,7 @@ async fn ping_server_with_zlib_compression() {
7878
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
7979
#[cfg(feature = "zstd-compression")]
8080
async fn ping_server_with_zstd_compression() {
81-
let mut client_options = CLIENT_OPTIONS.clone();
81+
let mut client_options = CLIENT_OPTIONS.get().await.clone();
8282
client_options.compressors = Some(vec![Compressor::Zstd { level: None }]);
8383
send_ping_with_compression(client_options).await;
8484
}
@@ -87,7 +87,7 @@ async fn ping_server_with_zstd_compression() {
8787
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
8888
#[cfg(feature = "snappy-compression")]
8989
async fn ping_server_with_snappy_compression() {
90-
let mut client_options = CLIENT_OPTIONS.clone();
90+
let mut client_options = CLIENT_OPTIONS.get().await.clone();
9191
client_options.compressors = Some(vec![Compressor::Snappy]);
9292
send_ping_with_compression(client_options).await;
9393
}
@@ -100,7 +100,7 @@ async fn ping_server_with_snappy_compression() {
100100
feature = "snappy-compression"
101101
))]
102102
async fn ping_server_with_all_compressors() {
103-
let mut client_options = CLIENT_OPTIONS.clone();
103+
let mut client_options = CLIENT_OPTIONS.get().await.clone();
104104
client_options.compressors = Some(vec![
105105
Compressor::Zlib { level: None },
106106
Compressor::Snappy,

src/sdam/description/topology/server_selection/test/in_window.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async fn select_in_window() {
116116
async fn load_balancing_test() {
117117
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
118118

119-
let mut setup_client_options = CLIENT_OPTIONS.clone();
119+
let mut setup_client_options = CLIENT_OPTIONS.get().await.clone();
120120

121121
if setup_client_options.load_balanced.unwrap_or(false) {
122122
log_uncaptured("skipping load_balancing_test test due to load-balanced topology");
@@ -146,7 +146,7 @@ async fn load_balancing_test() {
146146
return;
147147
}
148148

149-
if CLIENT_OPTIONS.hosts.len() != 2 {
149+
if CLIENT_OPTIONS.get().await.hosts.len() != 2 {
150150
log_uncaptured("skipping load_balancing_test test due to topology not having 2 mongoses");
151151
return;
152152
}
@@ -210,7 +210,7 @@ async fn load_balancing_test() {
210210

211211
let mut handler = EventHandler::new();
212212
let mut subscriber = handler.subscribe();
213-
let mut options = CLIENT_OPTIONS.clone();
213+
let mut options = CLIENT_OPTIONS.get().await.clone();
214214
options.local_threshold = Duration::from_secs(30).into();
215215
let client = TestClient::with_handler(Some(Arc::new(handler.clone())), options).await;
216216

0 commit comments

Comments
 (0)