Skip to content

Commit f2ee3d8

Browse files
committed
Fix test concurrency
1 parent 5514e58 commit f2ee3d8

File tree

4 files changed

+83
-82
lines changed

4 files changed

+83
-82
lines changed

object_store/src/aws/mod.rs

+29-17
Original file line numberDiff line numberDiff line change
@@ -1314,28 +1314,40 @@ mod tests {
13141314

13151315
#[tokio::test]
13161316
async fn s3_test() {
1317-
let config = maybe_skip_integration!();
1318-
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
1319-
let integration = config.build().unwrap();
1317+
let builder = maybe_skip_integration!();
1318+
let is_local = matches!(&builder.endpoint, Some(e) if e.starts_with("http://"));
13201319

1321-
// Localstack doesn't support listing with spaces https://github.com/localstack/localstack/issues/6328
1322-
put_get_delete_list_opts(&integration, is_local).await;
1323-
list_uses_directories_correctly(&integration).await;
1324-
list_with_delimiter(&integration).await;
1325-
rename_and_copy(&integration).await;
1326-
stream_get(&integration).await;
1320+
let test = |integration| async move {
1321+
// Localstack doesn't support listing with spaces https://github.com/localstack/localstack/issues/6328
1322+
put_get_delete_list_opts(&integration, is_local).await;
1323+
list_uses_directories_correctly(&integration).await;
1324+
list_with_delimiter(&integration).await;
1325+
rename_and_copy(&integration).await;
1326+
stream_get(&integration).await;
1327+
};
1328+
1329+
let (handle, shutdown) = dedicated_tokio();
1330+
1331+
let integration = builder.clone().build().unwrap();
1332+
handle.block_on(test(integration));
13271333

13281334
// run integration test with unsigned payload enabled
1329-
let config = maybe_skip_integration!().with_unsigned_payload(true);
1330-
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
1331-
let integration = config.build().unwrap();
1332-
put_get_delete_list_opts(&integration, is_local).await;
1335+
let integration = builder.clone().with_unsigned_payload(true).build().unwrap();
1336+
handle.block_on(test(integration));
13331337

13341338
// run integration test with checksum set to sha256
1335-
let config = maybe_skip_integration!().with_checksum_algorithm(Checksum::SHA256);
1336-
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
1337-
let integration = config.build().unwrap();
1338-
put_get_delete_list_opts(&integration, is_local).await;
1339+
let integration = builder
1340+
.clone()
1341+
.with_checksum_algorithm(Checksum::SHA256)
1342+
.build()
1343+
.unwrap();
1344+
handle.block_on(test(integration));
1345+
1346+
// run integration test without tokio runtime
1347+
let integration = builder.with_tokio_runtime(handle).build().unwrap();
1348+
futures::executor::block_on(test(integration));
1349+
1350+
shutdown();
13391351
}
13401352

13411353
#[tokio::test]

object_store/src/azure/mod.rs

+15-18
Original file line numberDiff line numberDiff line change
@@ -1137,30 +1137,27 @@ mod tests {
11371137
}};
11381138
}
11391139

1140-
#[test]
1141-
fn azure_blob_non_tokio() {
1142-
let (handle, shutdown) = dedicated_tokio();
1143-
let config = maybe_skip_integration!();
1144-
let integration = config.with_tokio_runtime(handle).build().unwrap();
1145-
futures::executor::block_on(async move {
1140+
#[tokio::test]
1141+
async fn azure_blob_test() {
1142+
let builder = maybe_skip_integration!();
1143+
let test = |integration| async move {
11461144
put_get_delete_list_opts(&integration, false).await;
11471145
list_uses_directories_correctly(&integration).await;
11481146
list_with_delimiter(&integration).await;
11491147
rename_and_copy(&integration).await;
1148+
copy_if_not_exists(&integration).await;
11501149
stream_get(&integration).await;
1151-
});
1152-
shutdown();
1153-
}
1150+
};
11541151

1155-
#[tokio::test]
1156-
async fn azure_blob_test() {
1157-
let integration = maybe_skip_integration!().build().unwrap();
1158-
put_get_delete_list_opts(&integration, false).await;
1159-
list_uses_directories_correctly(&integration).await;
1160-
list_with_delimiter(&integration).await;
1161-
rename_and_copy(&integration).await;
1162-
copy_if_not_exists(&integration).await;
1163-
stream_get(&integration).await;
1152+
let (handle, shutdown) = dedicated_tokio();
1153+
1154+
let integration = builder.clone().build().unwrap();
1155+
handle.block_on(test(integration));
1156+
1157+
let integration = builder.with_tokio_runtime(handle).build().unwrap();
1158+
futures::executor::block_on(test(integration));
1159+
1160+
shutdown();
11641161
}
11651162

11661163
// test for running integration test against actual blob service with service principal

object_store/src/gcp/mod.rs

+26-15
Original file line numberDiff line numberDiff line change
@@ -1275,22 +1275,33 @@ mod test {
12751275
shutdown();
12761276
}
12771277

1278-
#[tokio::test]
1279-
async fn gcs_test() {
1280-
let integration = maybe_skip_integration!().build().unwrap();
1278+
#[test]
1279+
fn gcs_test() {
1280+
let builder = maybe_skip_integration!();
1281+
let test = |integration: GoogleCloudStorage| async move {
1282+
put_get_delete_list(&integration).await;
1283+
list_uses_directories_correctly(&integration).await;
1284+
list_with_delimiter(&integration).await;
1285+
rename_and_copy(&integration).await;
1286+
if integration.client.base_url == default_gcs_base_url() {
1287+
// Fake GCS server doesn't currently honor ifGenerationMatch
1288+
// https://github.com/fsouza/fake-gcs-server/issues/994
1289+
copy_if_not_exists(&integration).await;
1290+
// Fake GCS server does not yet implement XML Multipart uploads
1291+
// https://github.com/fsouza/fake-gcs-server/issues/852
1292+
stream_get(&integration).await;
1293+
}
1294+
};
12811295

1282-
put_get_delete_list(&integration).await;
1283-
list_uses_directories_correctly(&integration).await;
1284-
list_with_delimiter(&integration).await;
1285-
rename_and_copy(&integration).await;
1286-
if integration.client.base_url == default_gcs_base_url() {
1287-
// Fake GCS server doesn't currently honor ifGenerationMatch
1288-
// https://github.com/fsouza/fake-gcs-server/issues/994
1289-
copy_if_not_exists(&integration).await;
1290-
// Fake GCS server does not yet implement XML Multipart uploads
1291-
// https://github.com/fsouza/fake-gcs-server/issues/852
1292-
stream_get(&integration).await;
1293-
}
1296+
let (handle, shutdown) = dedicated_tokio();
1297+
1298+
let integration = builder.clone().build().unwrap();
1299+
handle.block_on(test(integration));
1300+
1301+
let integration = builder.with_tokio_runtime(handle).build().unwrap();
1302+
futures::executor::block_on(test(integration));
1303+
1304+
shutdown();
12941305
}
12951306

12961307
#[tokio::test]

object_store/src/http/mod.rs

+13-32
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ mod tests {
283283

284284
use super::*;
285285

286-
#[tokio::test]
287-
async fn http_test() {
286+
#[test]
287+
fn http_test() {
288288
dotenv::dotenv().ok();
289289
let force = std::env::var("TEST_INTEGRATION");
290290
if force.is_err() {
@@ -293,45 +293,26 @@ mod tests {
293293
}
294294
let url = std::env::var("HTTP_URL").expect("HTTP_URL must be set");
295295
let options = ClientOptions::new().with_allow_http(true);
296-
let integration = HttpBuilder::new()
296+
let builder = HttpBuilder::new()
297297
.with_url(url)
298-
.with_client_options(options)
299-
.build()
300-
.unwrap();
301-
302-
put_get_delete_list_opts(&integration, false).await;
303-
list_uses_directories_correctly(&integration).await;
304-
list_with_delimiter(&integration).await;
305-
rename_and_copy(&integration).await;
306-
copy_if_not_exists(&integration).await;
307-
}
298+
.with_client_options(options);
308299

309-
#[test]
310-
fn http_non_tokio() {
311300
let (handle, shutdown) = dedicated_tokio();
312301

313-
dotenv::dotenv().ok();
314-
let force = std::env::var("TEST_INTEGRATION");
315-
if force.is_err() {
316-
eprintln!("skipping HTTP integration test - set TEST_INTEGRATION to run");
317-
return;
318-
}
319-
let url = std::env::var("HTTP_URL").expect("HTTP_URL must be set");
320-
let options = ClientOptions::new().with_allow_http(true);
321-
let integration = HttpBuilder::new()
322-
.with_url(url)
323-
.with_client_options(options)
324-
.with_tokio_runtime(handle)
325-
.build()
326-
.unwrap();
327-
328-
futures::executor::block_on(async move {
302+
let test = |integration| async move {
329303
put_get_delete_list_opts(&integration, false).await;
330304
list_uses_directories_correctly(&integration).await;
331305
list_with_delimiter(&integration).await;
332306
rename_and_copy(&integration).await;
333307
copy_if_not_exists(&integration).await;
334-
});
308+
};
309+
310+
let integration = builder.clone().build().unwrap();
311+
handle.block_on(test(integration));
312+
313+
let integration = builder.with_tokio_runtime(handle).build().unwrap();
314+
futures::executor::block_on(test(integration));
315+
335316
shutdown();
336317
}
337318
}

0 commit comments

Comments
 (0)