Skip to content

Commit

Permalink
Export object_store integration tests (#5709)
Browse files Browse the repository at this point in the history
* Export object_store integration tests

* Clippy

* Clippy

* Even more clippy

* Format
  • Loading branch information
tustvold authored May 4, 2024
1 parent 0d0c02e commit 520ad68
Show file tree
Hide file tree
Showing 23 changed files with 1,130 additions and 1,157 deletions.
1 change: 1 addition & 0 deletions object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ gcp = ["cloud", "rustls-pemfile"]
aws = ["cloud", "md-5"]
http = ["cloud"]
tls-webpki-roots = ["reqwest?/rustls-tls-webpki-roots"]
integration = []

[dev-dependencies] # In alphabetical order
futures-test = "0.3"
Expand Down
12 changes: 0 additions & 12 deletions object_store/src/aws/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,9 @@ enum Error {
#[snafu(display("Configuration key: '{}' is not known.", key))]
UnknownConfigurationKey { key: String },

#[snafu(display("Bucket '{}' not found", bucket))]
BucketNotFound { bucket: String },

#[snafu(display("Failed to resolve region for bucket '{}'", bucket))]
ResolveRegion {
bucket: String,
source: reqwest::Error,
},

#[snafu(display("Invalid Zone suffix for bucket '{bucket}'"))]
ZoneSuffix { bucket: String },

#[snafu(display("Failed to parse the region for bucket '{}'", bucket))]
RegionParse { bucket: String },

#[snafu(display("Invalid encryption type: {}. Valid values are \"AES256\", \"sse:kms\", and \"sse:kms:dsse\".", passed))]
InvalidEncryptionType { passed: String },

Expand Down
6 changes: 0 additions & 6 deletions object_store/src/aws/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ const SHA256_CHECKSUM: &str = "x-amz-checksum-sha256";
#[derive(Debug, Snafu)]
#[allow(missing_docs)]
pub(crate) enum Error {
#[snafu(display("Error fetching get response body {}: {}", path, source))]
GetResponseBody {
source: reqwest::Error,
path: String,
},

#[snafu(display("Error performing DeleteObjects request: {}", source))]
DeleteObjectsRequest { source: crate::client::retry::Error },

Expand Down
12 changes: 0 additions & 12 deletions object_store/src/aws/dynamo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,6 @@ struct PutItem<'a> {
return_values_on_condition_check_failure: Option<ReturnValues>,
}

/// A DynamoDB [GetItem] payload
///
/// [GetItem]: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
#[derive(Serialize)]
#[serde(rename_all = "PascalCase")]
struct GetItem<'a> {
/// The table name
table_name: &'a str,
/// The primary key
key: Map<'a, &'a str, AttributeValue<'a>>,
}

#[derive(Deserialize)]
struct ErrorResponse<'a> {
#[serde(rename = "__type")]
Expand Down
18 changes: 10 additions & 8 deletions object_store/src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,16 @@ impl MultipartStore for AmazonS3 {
#[cfg(test)]
mod tests {
use super::*;
use crate::{client::get::GetClient, tests::*};
use crate::client::get::GetClient;
use crate::integration::*;
use crate::tests::*;
use hyper::HeaderMap;

const NON_EXISTENT_NAME: &str = "nonexistentname";

#[tokio::test]
async fn s3_test() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = AmazonS3Builder::from_env();

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

#[tokio::test]
async fn s3_test_get_nonexistent_location() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = AmazonS3Builder::from_env().build().unwrap();

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

#[tokio::test]
async fn s3_test_get_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
let integration = config.build().unwrap();

Expand All @@ -500,7 +502,7 @@ mod tests {

#[tokio::test]
async fn s3_test_put_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
let integration = config.build().unwrap();

Expand All @@ -513,7 +515,7 @@ mod tests {

#[tokio::test]
async fn s3_test_delete_nonexistent_location() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = AmazonS3Builder::from_env().build().unwrap();

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

#[tokio::test]
async fn s3_test_delete_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = AmazonS3Builder::from_env().with_bucket_name(NON_EXISTENT_NAME);
let integration = config.build().unwrap();

Expand Down Expand Up @@ -560,7 +562,7 @@ mod tests {
}

async fn s3_encryption(store: &AmazonS3) {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();

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

Expand Down
5 changes: 0 additions & 5 deletions object_store/src/azure/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ enum Error {

#[snafu(display("Configuration key: '{}' is not known.", key))]
UnknownConfigurationKey { key: String },

#[snafu(display("Unable to extract metadata from headers: {}", source))]
Metadata {
source: crate::client::header::Error,
},
}

impl From<Error> for crate::Error {
Expand Down
11 changes: 0 additions & 11 deletions object_store/src/azure/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ pub(crate) enum Error {
path: String,
},

#[snafu(display("Error getting get response body {}: {}", path, source))]
GetResponseBody {
source: reqwest::Error,
path: String,
},

#[snafu(display("Error performing put request {}: {}", path, source))]
PutRequest {
source: crate::client::retry::Error,
Expand All @@ -94,11 +88,6 @@ pub(crate) enum Error {
#[snafu(display("Got invalid list response: {}", source))]
InvalidListResponse { source: quick_xml::de::DeError },

#[snafu(display("Error authorizing request: {}", source))]
Authorization {
source: crate::azure::credential::Error,
},

#[snafu(display("Unable to extract metadata from headers: {}", source))]
Metadata {
source: crate::client::header::Error,
Expand Down
3 changes: 2 additions & 1 deletion object_store/src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ impl MultipartStore for MicrosoftAzure {
#[cfg(test)]
mod tests {
use super::*;
use crate::integration::*;
use crate::tests::*;
use bytes::Bytes;

#[tokio::test]
async fn azure_blob_test() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = MicrosoftAzureBuilder::from_env().build().unwrap();

put_get_delete_list(&integration).await;
Expand Down
2 changes: 1 addition & 1 deletion object_store/src/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ impl ObjectStore for ChunkedStore {
mod tests {
use futures::StreamExt;

use crate::integration::*;
use crate::local::LocalFileSystem;
use crate::memory::InMemory;
use crate::path::Path;
use crate::tests::*;

use super::*;

Expand Down
1 change: 1 addition & 0 deletions object_store/src/client/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub trait ListClientExt {

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

#[allow(unused)]
fn list_with_offset(
&self,
prefix: Option<&Path>,
Expand Down
5 changes: 0 additions & 5 deletions object_store/src/gcp/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ enum Error {
#[snafu(display("Configuration key: '{}' is not known.", key))]
UnknownConfigurationKey { key: String },

#[snafu(display("Unable to extract metadata from headers: {}", source))]
Metadata {
source: crate::client::header::Error,
},

#[snafu(display("GCP credential error: {}", source))]
Credential { source: credential::Error },
}
Expand Down
6 changes: 0 additions & 6 deletions object_store/src/gcp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ enum Error {
#[snafu(display("Got invalid put response: {}", source))]
InvalidPutResponse { source: quick_xml::de::DeError },

#[snafu(display("Error performing post request {}: {}", path, source))]
PostRequest {
source: crate::client::retry::Error,
path: String,
},

#[snafu(display("Unable to extract metadata from headers: {}", source))]
Metadata {
source: crate::client::header::Error,
Expand Down
2 changes: 1 addition & 1 deletion object_store/src/gcp/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ impl ApplicationDefaultCredentials {
let path = Path::new(&home).join(Self::CREDENTIALS_PATH);

// It's expected for this file to not exist unless it has been explicitly configured by the user.
if path.try_exists().unwrap_or(false) {
if path.exists() {
return read_credentials_file::<Self>(path).map(Some);
}
}
Expand Down
15 changes: 8 additions & 7 deletions object_store/src/gcp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ mod test {

use credential::DEFAULT_GCS_BASE_URL;

use crate::integration::*;
use crate::tests::*;

use super::*;
Expand All @@ -281,7 +282,7 @@ mod test {

#[tokio::test]
async fn gcs_test() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();

put_get_delete_list(&integration).await;
Expand All @@ -307,7 +308,7 @@ mod test {
#[tokio::test]
#[ignore]
async fn gcs_test_sign() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();

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

#[tokio::test]
async fn gcs_test_get_nonexistent_location() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();

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

#[tokio::test]
async fn gcs_test_get_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = GoogleCloudStorageBuilder::from_env();
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();

Expand All @@ -369,7 +370,7 @@ mod test {

#[tokio::test]
async fn gcs_test_delete_nonexistent_location() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let integration = GoogleCloudStorageBuilder::from_env().build().unwrap();

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

#[tokio::test]
async fn gcs_test_delete_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = GoogleCloudStorageBuilder::from_env();
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();

Expand All @@ -398,7 +399,7 @@ mod test {

#[tokio::test]
async fn gcs_test_put_nonexistent_bucket() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let config = GoogleCloudStorageBuilder::from_env();
let integration = config.with_bucket_name(NON_EXISTENT_NAME).build().unwrap();

Expand Down
6 changes: 2 additions & 4 deletions object_store/src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ enum Error {
Metadata {
source: crate::client::header::Error,
},

#[snafu(display("Request error: {}", source))]
Reqwest { source: reqwest::Error },
}

impl From<Error> for crate::Error {
Expand Down Expand Up @@ -249,13 +246,14 @@ impl HttpBuilder {

#[cfg(test)]
mod tests {
use crate::integration::*;
use crate::tests::*;

use super::*;

#[tokio::test]
async fn http_test() {
crate::test_util::maybe_skip_integration!();
maybe_skip_integration!();
let url = std::env::var("HTTP_URL").expect("HTTP_URL must be set");
let options = ClientOptions::new().with_allow_http(true);
let integration = HttpBuilder::new()
Expand Down
Loading

0 comments on commit 520ad68

Please sign in to comment.