Skip to content

Commit 8148ee1

Browse files
authored
RUST-604 Use mongodb::Client for unified runner entities (#314)
1 parent eac52e8 commit 8148ee1

File tree

19 files changed

+177
-207
lines changed

19 files changed

+177
-207
lines changed

src/client/session/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async fn cluster_time_in_commands() {
242242
{
243243
let mut options = CLIENT_OPTIONS.clone();
244244
options.heartbeat_freq = Some(Duration::from_secs(1000));
245-
let client = EventClient::with_options(options, true).await;
245+
let client = EventClient::with_options(options).await;
246246

247247
operation(client.clone())
248248
.await

src/cmap/test/integration.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ async fn concurrent_connections() {
7979
options.direct_connection = Some(true);
8080
options.hosts.drain(1..);
8181

82-
let client = TestClient::with_options(Some(options), true).await;
82+
let client = TestClient::with_options(Some(options)).await;
8383
let version = VersionReq::parse(">= 4.2.9").unwrap();
8484
// blockConnection failpoint option only supported in 4.2.9+.
85-
if !version.matches(&client.server_version.as_ref().unwrap()) {
85+
if !version.matches(&client.server_version) {
8686
println!(
8787
"skipping concurrent_connections test due to server not supporting failpoint option"
8888
);
@@ -166,7 +166,7 @@ async fn connection_error_during_establishment() {
166166
client_options.direct_connection = Some(true);
167167
client_options.repl_set_name = None;
168168

169-
let client = TestClient::with_options(Some(client_options.clone()), true).await;
169+
let client = TestClient::with_options(Some(client_options.clone())).await;
170170
if !client.supports_fail_command().await {
171171
println!(
172172
"skipping {} due to failCommand not being supported",
@@ -217,7 +217,7 @@ async fn connection_error_during_operation() {
217217
options.hosts.drain(1..);
218218
options.max_pool_size = Some(1);
219219

220-
let client = TestClient::with_options(options.into(), true).await;
220+
let client = TestClient::with_options(options.into()).await;
221221
if !client.supports_fail_command().await {
222222
println!(
223223
"skipping {} due to failCommand not being supported",

src/cmap/test/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ async fn cmap_spec_tests() {
392392
let mut options = CLIENT_OPTIONS.clone();
393393
options.hosts.drain(1..);
394394
options.direct_connection = Some(true);
395-
let client = EventClient::with_options(options, true).await;
395+
let client = EventClient::with_options(options).await;
396396
if let Some(ref run_on) = test_file.run_on {
397397
let can_run_on = run_on.iter().any(|run_on| run_on.can_run_on(&client));
398398
if !can_run_on {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ async fn load_balancing_test() {
115115
let mut setup_client_options = CLIENT_OPTIONS.clone();
116116
setup_client_options.hosts.drain(1..);
117117
setup_client_options.direct_connection = Some(true);
118-
let setup_client = TestClient::with_options(Some(setup_client_options), true).await;
118+
let setup_client = TestClient::with_options(Some(setup_client_options)).await;
119119

120120
let version = VersionReq::parse(">= 4.2.9").unwrap();
121121
// blockConnection failpoint option only supported in 4.2.9+.
122-
if !version.matches(&setup_client.server_version.as_ref().unwrap()) {
122+
if !version.matches(&setup_client.server_version) {
123123
println!(
124124
"skipping load_balancing_test test due to server not supporting blockConnection option"
125125
);

src/sdam/test.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async fn min_heartbeat_frequency() {
3434
setup_client_options.hosts.drain(1..);
3535
setup_client_options.direct_connection = Some(true);
3636

37-
let setup_client = TestClient::with_options(Some(setup_client_options.clone()), true).await;
37+
let setup_client = TestClient::with_options(Some(setup_client_options.clone())).await;
3838

3939
if !setup_client.supports_fail_command().await {
4040
println!("skipping min_heartbeat_frequency test due to server not supporting fail points");
@@ -102,13 +102,12 @@ async fn sdam_pool_management() {
102102
Some(Duration::from_millis(50)),
103103
None,
104104
event_handler.clone(),
105-
true,
106105
)
107106
.await;
108107

109108
if !VersionReq::parse(">= 4.2.9")
110109
.unwrap()
111-
.matches(client.server_version.as_ref().unwrap())
110+
.matches(&client.server_version)
112111
{
113112
println!(
114113
"skipping sdam_pool_management test due to server not supporting appName failCommand"
@@ -160,11 +159,11 @@ async fn sdam_min_pool_size_error() {
160159
setup_client_options.hosts.drain(1..);
161160
setup_client_options.direct_connection = Some(true);
162161

163-
let setup_client = TestClient::with_options(Some(setup_client_options.clone()), true).await;
162+
let setup_client = TestClient::with_options(Some(setup_client_options.clone())).await;
164163

165164
if !VersionReq::parse(">= 4.9.0")
166165
.unwrap()
167-
.matches(setup_client.server_version.as_ref().unwrap())
166+
.matches(&setup_client.server_version)
168167
{
169168
println!(
170169
"skipping sdam_pool_management test due to server not supporting appName failCommand"
@@ -243,10 +242,10 @@ async fn auth_error() {
243242

244243
let mut setup_client_options = CLIENT_OPTIONS.clone();
245244
setup_client_options.hosts.drain(1..);
246-
let setup_client = TestClient::with_options(Some(setup_client_options.clone()), true).await;
245+
let setup_client = TestClient::with_options(Some(setup_client_options.clone())).await;
247246
if !VersionReq::parse(">= 4.4.0")
248247
.unwrap()
249-
.matches(setup_client.server_version.as_ref().unwrap())
248+
.matches(&setup_client.server_version)
250249
{
251250
println!("skipping auth_error test due to server not supporting appName failCommand");
252251
return;

src/test/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ async fn x509_auth() {
601601
.build(),
602602
);
603603

604-
let client = TestClient::with_options(Some(options), true).await;
604+
let client = TestClient::with_options(Some(options)).await;
605605
client
606606
.database(function_name!())
607607
.collection(function_name!())

src/test/coll.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ async fn find_one_and_delete_hint_test(options: Option<FindOneAndDeleteOptions>,
654654
let client = EventClient::new().await;
655655

656656
let req = VersionReq::parse(">= 4.2").unwrap();
657-
if options.is_some() && !req.matches(&client.server_version.as_ref().unwrap()) {
657+
if options.is_some() && !req.matches(&client.server_version) {
658658
return;
659659
}
660660

@@ -712,10 +712,10 @@ async fn find_one_and_delete_hint_server_version() {
712712

713713
let req1 = VersionReq::parse("< 4.2").unwrap();
714714
let req2 = VersionReq::parse("4.2.*").unwrap();
715-
if req1.matches(&client.server_version.as_ref().unwrap()) {
715+
if req1.matches(&client.server_version) {
716716
let error = res.expect_err("find one and delete should fail");
717717
assert!(matches!(error.kind, ErrorKind::OperationError { .. }));
718-
} else if req2.matches(&client.server_version.as_ref().unwrap()) {
718+
} else if req2.matches(&client.server_version) {
719719
let error = res.expect_err("find one and delete should fail");
720720
assert!(matches!(error.kind, ErrorKind::CommandError { .. }));
721721
} else {
@@ -953,7 +953,7 @@ async fn count_documents_with_wc() {
953953
.build()
954954
.into();
955955

956-
let client = TestClient::with_options(Some(options), true).await;
956+
let client = TestClient::with_options(Some(options)).await;
957957
let coll = client
958958
.database(function_name!())
959959
.collection(function_name!());

src/test/spec/command_monitoring/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ async fn run_command_monitoring_test(test_file: TestFile) {
5858

5959
if let Some(ref max_version) = test_case.max_version {
6060
let req = VersionReq::parse(&format!("<= {}", &max_version)).unwrap();
61-
if !req.matches(&client.server_version.as_ref().unwrap()) {
61+
if !req.matches(&client.server_version) {
6262
println!("Skipping {}", test_case.description);
6363
continue;
6464
}
6565
}
6666

6767
if let Some(ref min_version) = test_case.min_version {
6868
let req = VersionReq::parse(&format!(">= {}", &min_version)).unwrap();
69-
if !req.matches(&client.server_version.as_ref().unwrap()) {
69+
if !req.matches(&client.server_version) {
7070
println!("Skipping {}", test_case.description);
7171
continue;
7272
}
@@ -89,8 +89,7 @@ async fn run_command_monitoring_test(test_file: TestFile) {
8989
.hosts(CLIENT_OPTIONS.hosts.clone())
9090
.build();
9191
let client =
92-
EventClient::with_additional_options(Some(options), None, Some(false), None, true)
93-
.await;
92+
EventClient::with_additional_options(Some(options), None, Some(false), None).await;
9493

9594
let events: Vec<TestEvent> = client
9695
.run_operation_with_events(

src/test/spec/connection_stepdown.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
InsertManyOptions,
1616
WriteConcern,
1717
},
18-
test::{util::EventClient, CLIENT_OPTIONS, LOCK},
18+
test::{util::EventClient, LOCK},
1919
Collection,
2020
Database,
2121
RUNTIME,
@@ -24,11 +24,8 @@ use crate::{
2424
async fn run_test<F: Future>(name: &str, test: impl Fn(EventClient, Database, Collection) -> F) {
2525
let _guard: RwLockWriteGuard<()> = LOCK.run_exclusively().await;
2626

27-
let options = ClientOptions::builder()
28-
.retry_writes(false)
29-
.hosts(CLIENT_OPTIONS.hosts.clone())
30-
.build();
31-
let client = EventClient::with_additional_options(Some(options), None, None, None, true).await;
27+
let options = ClientOptions::builder().retry_writes(false).build();
28+
let client = EventClient::with_additional_options(Some(options), None, None, None).await;
3229

3330
if !client.is_replica_set() {
3431
return;

src/test/spec/retryable_writes/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ async fn run_spec_tests() {
4141
Some(Duration::from_millis(50)),
4242
test_case.use_multiple_mongoses,
4343
None,
44-
true,
4544
)
4645
.await;
4746

@@ -200,7 +199,7 @@ async fn transaction_ids_excluded() {
200199
assert!(excludes_txn_number("aggregate"));
201200

202201
let req = semver::VersionReq::parse(">=4.2").unwrap();
203-
if req.matches(&client.server_version.as_ref().unwrap()) {
202+
if req.matches(&client.server_version) {
204203
coll.aggregate(
205204
vec![
206205
doc! { "$match": doc! { "x": 1 } },
@@ -284,7 +283,7 @@ async fn mmapv1_error_raised() {
284283
let client = TestClient::new().await;
285284

286285
let req = semver::VersionReq::parse("<=4.0").unwrap();
287-
if !req.matches(&client.server_version.as_ref().unwrap()) || !client.is_replica_set() {
286+
if !req.matches(&client.server_version) || !client.is_replica_set() {
288287
return;
289288
}
290289

@@ -334,13 +333,13 @@ async fn label_not_added_second_read_error() {
334333
#[function_name::named]
335334
async fn label_not_added(retry_reads: bool) {
336335
let options = ClientOptions::builder().retry_reads(retry_reads).build();
337-
let client = TestClient::with_additional_options(Some(options), false, true).await;
336+
let client = TestClient::with_additional_options(Some(options), false).await;
338337

339338
// Configuring a failpoint is only supported on 4.0+ replica sets and 4.1.5+ sharded clusters.
340339
let req = VersionReq::parse(">=4.0").unwrap();
341340
let sharded_req = VersionReq::parse(">=4.1.5").unwrap();
342-
if client.is_sharded() && !sharded_req.matches(&client.server_version.as_ref().unwrap())
343-
|| !req.matches(&client.server_version.as_ref().unwrap())
341+
if client.is_sharded() && !sharded_req.matches(&client.server_version)
342+
|| !req.matches(&client.server_version)
344343
{
345344
return;
346345
}

0 commit comments

Comments
 (0)