Skip to content

Commit 520ad68

Browse files
authored
Export object_store integration tests (#5709)
* Export object_store integration tests * Clippy * Clippy * Even more clippy * Format
1 parent 0d0c02e commit 520ad68

23 files changed

+1130
-1157
lines changed

object_store/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ gcp = ["cloud", "rustls-pemfile"]
6666
aws = ["cloud", "md-5"]
6767
http = ["cloud"]
6868
tls-webpki-roots = ["reqwest?/rustls-tls-webpki-roots"]
69+
integration = []
6970

7071
[dev-dependencies] # In alphabetical order
7172
futures-test = "0.3"

object_store/src/aws/builder.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,9 @@ enum Error {
7070
#[snafu(display("Configuration key: '{}' is not known.", key))]
7171
UnknownConfigurationKey { key: String },
7272

73-
#[snafu(display("Bucket '{}' not found", bucket))]
74-
BucketNotFound { bucket: String },
75-
76-
#[snafu(display("Failed to resolve region for bucket '{}'", bucket))]
77-
ResolveRegion {
78-
bucket: String,
79-
source: reqwest::Error,
80-
},
81-
8273
#[snafu(display("Invalid Zone suffix for bucket '{bucket}'"))]
8374
ZoneSuffix { bucket: String },
8475

85-
#[snafu(display("Failed to parse the region for bucket '{}'", bucket))]
86-
RegionParse { bucket: String },
87-
8876
#[snafu(display("Invalid encryption type: {}. Valid values are \"AES256\", \"sse:kms\", and \"sse:kms:dsse\".", passed))]
8977
InvalidEncryptionType { passed: String },
9078

object_store/src/aws/client.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ const SHA256_CHECKSUM: &str = "x-amz-checksum-sha256";
6666
#[derive(Debug, Snafu)]
6767
#[allow(missing_docs)]
6868
pub(crate) enum Error {
69-
#[snafu(display("Error fetching get response body {}: {}", path, source))]
70-
GetResponseBody {
71-
source: reqwest::Error,
72-
path: String,
73-
},
74-
7569
#[snafu(display("Error performing DeleteObjects request: {}", source))]
7670
DeleteObjectsRequest { source: crate::client::retry::Error },
7771

object_store/src/aws/dynamo.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -451,18 +451,6 @@ struct PutItem<'a> {
451451
return_values_on_condition_check_failure: Option<ReturnValues>,
452452
}
453453

454-
/// A DynamoDB [GetItem] payload
455-
///
456-
/// [GetItem]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
457-
#[derive(Serialize)]
458-
#[serde(rename_all = "PascalCase")]
459-
struct GetItem<'a> {
460-
/// The table name
461-
table_name: &'a str,
462-
/// The primary key
463-
key: Map<'a, &'a str, AttributeValue<'a>>,
464-
}
465-
466454
#[derive(Deserialize)]
467455
struct ErrorResponse<'a> {
468456
#[serde(rename = "__type")]

object_store/src/aws/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,16 @@ impl MultipartStore for AmazonS3 {
409409
#[cfg(test)]
410410
mod tests {
411411
use super::*;
412-
use crate::{client::get::GetClient, tests::*};
412+
use crate::client::get::GetClient;
413+
use crate::integration::*;
414+
use crate::tests::*;
413415
use hyper::HeaderMap;
414416

415417
const NON_EXISTENT_NAME: &str = "nonexistentname";
416418

417419
#[tokio::test]
418420
async fn s3_test() {
419-
crate::test_util::maybe_skip_integration!();
421+
maybe_skip_integration!();
420422
let config = AmazonS3Builder::from_env();
421423

422424
let integration = config.build().unwrap();
@@ -475,7 +477,7 @@ mod tests {
475477

476478
#[tokio::test]
477479
async fn s3_test_get_nonexistent_location() {
478-
crate::test_util::maybe_skip_integration!();
480+
maybe_skip_integration!();
479481
let integration = AmazonS3Builder::from_env().build().unwrap();
480482

481483
let location = Path::from_iter([NON_EXISTENT_NAME]);
@@ -488,7 +490,7 @@ mod tests {
488490

489491
#[tokio::test]
490492
async fn s3_test_get_nonexistent_bucket() {
491-
crate::test_util::maybe_skip_integration!();
493+
maybe_skip_integration!();
492494
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
493495
let integration = config.build().unwrap();
494496

@@ -500,7 +502,7 @@ mod tests {
500502

501503
#[tokio::test]
502504
async fn s3_test_put_nonexistent_bucket() {
503-
crate::test_util::maybe_skip_integration!();
505+
maybe_skip_integration!();
504506
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
505507
let integration = config.build().unwrap();
506508

@@ -513,7 +515,7 @@ mod tests {
513515

514516
#[tokio::test]
515517
async fn s3_test_delete_nonexistent_location() {
516-
crate::test_util::maybe_skip_integration!();
518+
maybe_skip_integration!();
517519
let integration = AmazonS3Builder::from_env().build().unwrap();
518520

519521
let location = Path::from_iter([NON_EXISTENT_NAME]);
@@ -523,7 +525,7 @@ mod tests {
523525

524526
#[tokio::test]
525527
async fn s3_test_delete_nonexistent_bucket() {
526-
crate::test_util::maybe_skip_integration!();
528+
maybe_skip_integration!();
527529
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
528530
let integration = config.build().unwrap();
529531

@@ -560,7 +562,7 @@ mod tests {
560562
}
561563

562564
async fn s3_encryption(store: &AmazonS3) {
563-
crate::test_util::maybe_skip_integration!();
565+
maybe_skip_integration!();
564566

565567
let data = PutPayload::from(vec![3u8; 1024]);
566568

object_store/src/azure/builder.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,6 @@ enum Error {
8989

9090
#[snafu(display("Configuration key: '{}' is not known.", key))]
9191
UnknownConfigurationKey { key: String },
92-
93-
#[snafu(display("Unable to extract metadata from headers: {}", source))]
94-
Metadata {
95-
source: crate::client::header::Error,
96-
},
9792
}
9893

9994
impl From<Error> for crate::Error {

object_store/src/azure/client.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ pub(crate) enum Error {
6767
path: String,
6868
},
6969

70-
#[snafu(display("Error getting get response body {}: {}", path, source))]
71-
GetResponseBody {
72-
source: reqwest::Error,
73-
path: String,
74-
},
75-
7670
#[snafu(display("Error performing put request {}: {}", path, source))]
7771
PutRequest {
7872
source: crate::client::retry::Error,
@@ -94,11 +88,6 @@ pub(crate) enum Error {
9488
#[snafu(display("Got invalid list response: {}", source))]
9589
InvalidListResponse { source: quick_xml::de::DeError },
9690

97-
#[snafu(display("Error authorizing request: {}", source))]
98-
Authorization {
99-
source: crate::azure::credential::Error,
100-
},
101-
10291
#[snafu(display("Unable to extract metadata from headers: {}", source))]
10392
Metadata {
10493
source: crate::client::header::Error,

object_store/src/azure/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,13 @@ impl MultipartStore for MicrosoftAzure {
276276
#[cfg(test)]
277277
mod tests {
278278
use super::*;
279+
use crate::integration::*;
279280
use crate::tests::*;
280281
use bytes::Bytes;
281282

282283
#[tokio::test]
283284
async fn azure_blob_test() {
284-
crate::test_util::maybe_skip_integration!();
285+
maybe_skip_integration!();
285286
let integration = MicrosoftAzureBuilder::from_env().build().unwrap();
286287

287288
put_get_delete_list(&integration).await;

object_store/src/chunked.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ impl ObjectStore for ChunkedStore {
178178
mod tests {
179179
use futures::StreamExt;
180180

181+
use crate::integration::*;
181182
use crate::local::LocalFileSystem;
182183
use crate::memory::InMemory;
183184
use crate::path::Path;
184-
use crate::tests::*;
185185

186186
use super::*;
187187

object_store/src/client/list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub trait ListClientExt {
4848

4949
fn list(&self, prefix: Option<&Path>) -> BoxStream<'_, Result<ObjectMeta>>;
5050

51+
#[allow(unused)]
5152
fn list_with_offset(
5253
&self,
5354
prefix: Option<&Path>,

object_store/src/gcp/builder.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ enum Error {
6060
#[snafu(display("Configuration key: '{}' is not known.", key))]
6161
UnknownConfigurationKey { key: String },
6262

63-
#[snafu(display("Unable to extract metadata from headers: {}", source))]
64-
Metadata {
65-
source: crate::client::header::Error,
66-
},
67-
6863
#[snafu(display("GCP credential error: {}", source))]
6964
Credential { source: credential::Error },
7065
}

object_store/src/gcp/client.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ enum Error {
8181
#[snafu(display("Got invalid put response: {}", source))]
8282
InvalidPutResponse { source: quick_xml::de::DeError },
8383

84-
#[snafu(display("Error performing post request {}: {}", path, source))]
85-
PostRequest {
86-
source: crate::client::retry::Error,
87-
path: String,
88-
},
89-
9084
#[snafu(display("Unable to extract metadata from headers: {}", source))]
9185
Metadata {
9286
source: crate::client::header::Error,

object_store/src/gcp/credential.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl ApplicationDefaultCredentials {
536536
let path = Path::new(&home).join(Self::CREDENTIALS_PATH);
537537

538538
// It's expected for this file to not exist unless it has been explicitly configured by the user.
539-
if path.try_exists().unwrap_or(false) {
539+
if path.exists() {
540540
return read_credentials_file::<Self>(path).map(Some);
541541
}
542542
}

object_store/src/gcp/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ mod test {
273273

274274
use credential::DEFAULT_GCS_BASE_URL;
275275

276+
use crate::integration::*;
276277
use crate::tests::*;
277278

278279
use super::*;
@@ -281,7 +282,7 @@ mod test {
281282

282283
#[tokio::test]
283284
async fn gcs_test() {
284-
crate::test_util::maybe_skip_integration!();
285+
maybe_skip_integration!();
285286
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();
286287

287288
put_get_delete_list(&integration).await;
@@ -307,7 +308,7 @@ mod test {
307308
#[tokio::test]
308309
#[ignore]
309310
async fn gcs_test_sign() {
310-
crate::test_util::maybe_skip_integration!();
311+
maybe_skip_integration!();
311312
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();
312313

313314
let client = reqwest::Client::new();
@@ -336,7 +337,7 @@ mod test {
336337

337338
#[tokio::test]
338339
async fn gcs_test_get_nonexistent_location() {
339-
crate::test_util::maybe_skip_integration!();
340+
maybe_skip_integration!();
340341
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();
341342

342343
let location = Path::from_iter([NON_EXISTENT_NAME]);
@@ -351,7 +352,7 @@ mod test {
351352

352353
#[tokio::test]
353354
async fn gcs_test_get_nonexistent_bucket() {
354-
crate::test_util::maybe_skip_integration!();
355+
maybe_skip_integration!();
355356
let config = GoogleCloudStorageBuilder::from_env();
356357
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();
357358

@@ -369,7 +370,7 @@ mod test {
369370

370371
#[tokio::test]
371372
async fn gcs_test_delete_nonexistent_location() {
372-
crate::test_util::maybe_skip_integration!();
373+
maybe_skip_integration!();
373374
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();
374375

375376
let location = Path::from_iter([NON_EXISTENT_NAME]);
@@ -383,7 +384,7 @@ mod test {
383384

384385
#[tokio::test]
385386
async fn gcs_test_delete_nonexistent_bucket() {
386-
crate::test_util::maybe_skip_integration!();
387+
maybe_skip_integration!();
387388
let config = GoogleCloudStorageBuilder::from_env();
388389
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();
389390

@@ -398,7 +399,7 @@ mod test {
398399

399400
#[tokio::test]
400401
async fn gcs_test_put_nonexistent_bucket() {
401-
crate::test_util::maybe_skip_integration!();
402+
maybe_skip_integration!();
402403
let config = GoogleCloudStorageBuilder::from_env();
403404
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();
404405

object_store/src/http/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@ enum Error {
6464
Metadata {
6565
source: crate::client::header::Error,
6666
},
67-
68-
#[snafu(display("Request error: {}", source))]
69-
Reqwest { source: reqwest::Error },
7067
}
7168

7269
impl From<Error> for crate::Error {
@@ -249,13 +246,14 @@ impl HttpBuilder {
249246

250247
#[cfg(test)]
251248
mod tests {
249+
use crate::integration::*;
252250
use crate::tests::*;
253251

254252
use super::*;
255253

256254
#[tokio::test]
257255
async fn http_test() {
258-
crate::test_util::maybe_skip_integration!();
256+
maybe_skip_integration!();
259257
let url = std::env::var("HTTP_URL").expect("HTTP_URL must be set");
260258
let options = ClientOptions::new().with_allow_http(true);
261259
let integration = HttpBuilder::new()

0 commit comments

Comments
 (0)