Skip to content

Commit 289443e

Browse files
RUST-1722 Remove test lock (#945)
1 parent 132d828 commit 289443e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+48
-583
lines changed

src/client/session/test.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::{future::Future, sync::Arc, time::Duration};
44

55
use bson::Document;
66
use futures::stream::StreamExt;
7-
use tokio::sync::RwLockReadGuard;
87

98
use crate::{
109
bson::{doc, Bson},
@@ -22,7 +21,6 @@ use crate::{
2221
SdamEvent,
2322
TestClient,
2423
CLIENT_OPTIONS,
25-
LOCK,
2624
},
2725
Client,
2826
Collection,
@@ -212,8 +210,6 @@ macro_rules! for_each_op {
212210
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
213211
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
214212
async fn pool_is_lifo() {
215-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
216-
217213
let client = TestClient::new().await;
218214
// Wait for the implicit sessions created in TestClient::new to be returned to the pool.
219215
runtime::delay_for(Duration::from_millis(500)).await;
@@ -248,8 +244,6 @@ async fn pool_is_lifo() {
248244
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
249245
#[function_name::named]
250246
async fn cluster_time_in_commands() {
251-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
252-
253247
let test_client = TestClient::new().await;
254248
if test_client.is_standalone() {
255249
log_uncaptured("skipping cluster_time_in_commands test due to standalone topology");
@@ -402,8 +396,6 @@ async fn cluster_time_in_commands() {
402396
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
403397
#[function_name::named]
404398
async fn session_usage() {
405-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
406-
407399
let client = TestClient::new().await;
408400
if client.is_standalone() {
409401
return;
@@ -432,8 +424,6 @@ async fn session_usage() {
432424
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
433425
#[function_name::named]
434426
async fn implicit_session_returned_after_immediate_exhaust() {
435-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
436-
437427
let client = EventClient::new().await;
438428
if client.is_standalone() {
439429
return;
@@ -475,8 +465,6 @@ async fn implicit_session_returned_after_immediate_exhaust() {
475465
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
476466
#[function_name::named]
477467
async fn implicit_session_returned_after_exhaust_by_get_more() {
478-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
479-
480468
let client = EventClient::new().await;
481469
if client.is_standalone() {
482470
return;
@@ -527,8 +515,6 @@ async fn implicit_session_returned_after_exhaust_by_get_more() {
527515
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
528516
#[function_name::named]
529517
async fn find_and_getmore_share_session() {
530-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
531-
532518
let client = EventClient::new().await;
533519
if client.is_standalone() {
534520
log_uncaptured(

src/client/session/test/causal_consistency.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
use bson::{doc, Document};
22
use futures::{future::BoxFuture, FutureExt};
3-
use tokio::sync::RwLockReadGuard;
43

54
use crate::{
65
client::options::SessionOptions,
76
coll::options::CollectionOptions,
87
error::Result,
98
event::command::CommandEvent,
109
options::ReadConcern,
11-
test::{log_uncaptured, EventClient, LOCK},
10+
test::{log_uncaptured, EventClient},
1211
ClientSession,
1312
Collection,
1413
};
@@ -146,8 +145,6 @@ fn all_session_ops() -> impl Iterator<Item = Operation> {
146145
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
147146
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
148147
async fn new_session_operation_time_null() {
149-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
150-
151148
let client = EventClient::new().await;
152149

153150
if client.is_standalone() {
@@ -165,8 +162,6 @@ async fn new_session_operation_time_null() {
165162
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
166163
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
167164
async fn first_read_no_after_cluser_time() {
168-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
169-
170165
let client = EventClient::new().await;
171166

172167
if client.is_standalone() {
@@ -204,8 +199,6 @@ async fn first_read_no_after_cluser_time() {
204199
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
205200
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
206201
async fn first_op_update_op_time() {
207-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
208-
209202
let client = EventClient::new().await;
210203

211204
if client.is_standalone() {
@@ -254,8 +247,6 @@ async fn first_op_update_op_time() {
254247
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
255248
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
256249
async fn read_includes_after_cluster_time() {
257-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
258-
259250
let client = EventClient::new().await;
260251

261252
if client.is_standalone() {
@@ -299,8 +290,6 @@ async fn read_includes_after_cluster_time() {
299290
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
300291
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
301292
async fn find_after_write_includes_after_cluster_time() {
302-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
303-
304293
let client = EventClient::new().await;
305294

306295
if client.is_standalone() {
@@ -341,8 +330,6 @@ async fn find_after_write_includes_after_cluster_time() {
341330
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
342331
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
343332
async fn not_causally_consistent_omits_after_cluster_time() {
344-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
345-
346333
let client = EventClient::new().await;
347334

348335
if client.is_standalone() {
@@ -379,8 +366,6 @@ async fn not_causally_consistent_omits_after_cluster_time() {
379366
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
380367
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
381368
async fn omit_after_cluster_time_standalone() {
382-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
383-
384369
let client = EventClient::new().await;
385370

386371
if !client.is_standalone() {
@@ -414,8 +399,6 @@ async fn omit_after_cluster_time_standalone() {
414399
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
415400
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
416401
async fn omit_default_read_concern_level() {
417-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
418-
419402
let client = EventClient::new().await;
420403

421404
if client.is_standalone() {
@@ -455,8 +438,6 @@ async fn omit_default_read_concern_level() {
455438
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
456439
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
457440
async fn test_causal_consistency_read_concern_merge() {
458-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
459-
460441
let client = EventClient::new().await;
461442
if client.is_standalone() {
462443
log_uncaptured(
@@ -505,8 +486,6 @@ async fn test_causal_consistency_read_concern_merge() {
505486
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
506487
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
507488
async fn omit_cluster_time_standalone() {
508-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
509-
510489
let client = EventClient::new().await;
511490
if !client.is_standalone() {
512491
log_uncaptured("skipping omit_cluster_time_standalone due to unsupported topology");
@@ -527,8 +506,6 @@ async fn omit_cluster_time_standalone() {
527506
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
528507
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
529508
async fn cluster_time_sent_in_commands() {
530-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
531-
532509
let client = EventClient::new().await;
533510
if client.is_standalone() {
534511
log_uncaptured("skipping cluster_time_sent_in_commands due to unsupported topology");

src/cmap/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod integration;
44

55
use std::{collections::HashMap, ops::Deref, sync::Arc, time::Duration};
66

7-
use tokio::sync::{Mutex, RwLock, RwLockWriteGuard};
7+
use tokio::sync::{Mutex, RwLock};
88

99
use self::{
1010
event::EventHandler,
@@ -33,7 +33,6 @@ use crate::{
3333
MatchErrExt,
3434
Matchable,
3535
CLIENT_OPTIONS,
36-
LOCK,
3736
},
3837
};
3938
use bson::doc;
@@ -434,8 +433,6 @@ async fn cmap_spec_tests() {
434433
return;
435434
}
436435

437-
let _guard: RwLockWriteGuard<()> = LOCK.run_exclusively().await;
438-
439436
let mut options = CLIENT_OPTIONS.get().await.clone();
440437
if options.load_balanced.unwrap_or(false) {
441438
log_uncaptured(format!(

src/cmap/test/integration.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use serde::Deserialize;
2-
use tokio::sync::{RwLockReadGuard, RwLockWriteGuard};
32

43
use super::{event::EventHandler, EVENT_TIMEOUT};
54
use crate::{
@@ -23,7 +22,6 @@ use crate::{
2322
FailPointMode,
2423
TestClient,
2524
CLIENT_OPTIONS,
26-
LOCK,
2725
},
2826
};
2927
use semver::VersionReq;
@@ -42,8 +40,6 @@ struct DatabaseEntry {
4240
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
4341
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
4442
async fn acquire_connection_and_send_command() {
45-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
46-
4743
let client_options = CLIENT_OPTIONS.get().await.clone();
4844
let mut pool_options = ConnectionPoolOptions::from_client_options(&client_options);
4945
pool_options.ready = Some(true);
@@ -88,8 +84,6 @@ async fn acquire_connection_and_send_command() {
8884
#[cfg_attr(feature = "tokio-runtime", tokio::test)]
8985
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
9086
async fn concurrent_connections() {
91-
let _guard = LOCK.run_exclusively().await;
92-
9387
let mut options = CLIENT_OPTIONS.get().await.clone();
9488
if options.load_balanced.unwrap_or(false) {
9589
log_uncaptured("skipping concurrent_connections test due to load-balanced topology");
@@ -178,9 +172,8 @@ async fn concurrent_connections() {
178172
#[cfg_attr(feature = "tokio-runtime", tokio::test(flavor = "multi_thread"))]
179173
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
180174
#[function_name::named]
181-
async fn connection_error_during_establishment() {
182-
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
183175

176+
async fn connection_error_during_establishment() {
184177
let mut client_options = CLIENT_OPTIONS.get().await.clone();
185178
if client_options.load_balanced.unwrap_or(false) {
186179
log_uncaptured(
@@ -242,9 +235,8 @@ async fn connection_error_during_establishment() {
242235
#[cfg_attr(feature = "tokio-runtime", tokio::test(flavor = "multi_thread"))]
243236
#[cfg_attr(feature = "async-std-runtime", async_std::test)]
244237
#[function_name::named]
245-
async fn connection_error_during_operation() {
246-
let _guard: RwLockWriteGuard<_> = LOCK.run_exclusively().await;
247238

239+
async fn connection_error_during_operation() {
248240
let mut options = CLIENT_OPTIONS.get().await.clone();
249241
let handler = Arc::new(EventHandler::new());
250242
options.cmap_event_handler = Some(handler.clone() as Arc<dyn CmapEventHandler>);

src/compression/test.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ use bson::{doc, Bson};
99
use crate::{
1010
client::options::ClientOptions,
1111
compression::{Compressor, CompressorId, Decoder},
12-
test::{TestClient, CLIENT_OPTIONS, LOCK},
12+
test::{TestClient, CLIENT_OPTIONS},
1313
};
1414

15-
use tokio::sync::RwLockReadGuard;
16-
1715
#[cfg(feature = "zlib-compression")]
1816
#[test]
1917
fn test_zlib_compressor() {
@@ -110,7 +108,6 @@ async fn ping_server_with_all_compressors() {
110108
}
111109

112110
async fn send_ping_with_compression(client_options: ClientOptions) {
113-
let _guard: RwLockReadGuard<()> = LOCK.run_concurrently().await;
114111
let client = TestClient::with_options(Some(client_options)).await;
115112
let ret = client
116113
.database("admin")

0 commit comments

Comments
 (0)