Skip to content

Commit 6d89243

Browse files
authored
RUST-1090 Fix serverless tests (#666)
1 parent de3a594 commit 6d89243

File tree

27 files changed

+80
-78
lines changed

27 files changed

+80
-78
lines changed

.evergreen/config.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,8 @@ functions:
395395
export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
396396
export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
397397
398-
export MONGODB_URI="${MONGODB_URI}"
399398
export SSL="${SSL}"
400-
export SINGLE_MONGOS_LB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
401-
export MULTI_MONGOS_LB_URI="${MULTI_ATLASPROXY_SERVERLESS_URI}"
399+
export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"
402400
. .evergreen/generate-uri.sh
403401
404402
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
@@ -137,6 +137,7 @@ features = ["v4"]
137137

138138
[dev-dependencies]
139139
approx = "0.5.1"
140+
async_once = "0.2.6"
140141
derive_more = "0.99.13"
141142
function_name = "0.2.1"
142143
futures = "0.3"

src/client/options/mod.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,20 +1184,6 @@ impl ClientOptions {
11841184
crate::runtime::block_on(Self::parse_connection_string(conn_str, resolver_config))
11851185
}
11861186

1187-
#[cfg(test)]
1188-
pub(crate) fn parse_without_srv_resolution(s: &str) -> Result<Self> {
1189-
let mut conn_str = ConnectionString::parse(s)?;
1190-
let host_info = std::mem::take(&mut conn_str.host_info);
1191-
let mut options = Self::from_connection_string(conn_str);
1192-
options.hosts = match host_info {
1193-
HostInfo::HostIdentifiers(hosts) => hosts,
1194-
HostInfo::DnsRecord(_) => panic!("Expected non-SRV URI, got {:?}", s),
1195-
};
1196-
options.validate()?;
1197-
1198-
Ok(options)
1199-
}
1200-
12011187
fn from_connection_string(conn_str: ConnectionString) -> Self {
12021188
let mut credential = conn_str.credential;
12031189
// Populate default auth source, if needed.

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();
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
TopologyUpdater::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 (updater, mut receiver) = TopologyUpdater::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
updater,
162162
Some(self.pool_options),
@@ -426,7 +426,7 @@ async fn cmap_spec_tests() {
426426

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

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

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

460460
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async fn select_in_window() {
118118
async fn load_balancing_test() {
119119
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
120120

121-
let mut setup_client_options = CLIENT_OPTIONS.clone();
121+
let mut setup_client_options = CLIENT_OPTIONS.get().await.clone();
122122

123123
if setup_client_options.load_balanced.unwrap_or(false) {
124124
log_uncaptured("skipping load_balancing_test test due to load-balanced topology");
@@ -148,7 +148,7 @@ async fn load_balancing_test() {
148148
return;
149149
}
150150

151-
if CLIENT_OPTIONS.hosts.len() != 2 {
151+
if CLIENT_OPTIONS.get().await.hosts.len() != 2 {
152152
log_uncaptured("skipping load_balancing_test test due to topology not having 2 mongoses");
153153
return;
154154
}
@@ -215,7 +215,7 @@ async fn load_balancing_test() {
215215

216216
let mut handler = EventHandler::new();
217217
let mut subscriber = handler.subscribe();
218-
let mut options = CLIENT_OPTIONS.clone();
218+
let mut options = CLIENT_OPTIONS.get().await.clone();
219219
let max_pool_size = 10;
220220
let hosts = options.hosts.clone();
221221
options.local_threshold = Duration::from_secs(30).into();
@@ -260,7 +260,7 @@ async fn load_balancing_test() {
260260
.build();
261261
let failpoint = FailPoint::fail_command(&["find"], FailPointMode::AlwaysOn, options);
262262

263-
let slow_host = CLIENT_OPTIONS.hosts[0].clone();
263+
let slow_host = CLIENT_OPTIONS.get().await.hosts[0].clone();
264264
let criteria = SelectionCriteria::Predicate(Arc::new(move |si| si.address() == &slow_host));
265265
let fp_guard = setup_client
266266
.enable_failpoint(failpoint, criteria)

0 commit comments

Comments
 (0)