Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ring optional and cleanup tests #2344

Merged
merged 1 commit into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions object_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ serde = { version = "1.0", default-features = false, features = ["derive"], opti
serde_json = { version = "1.0", default-features = false, optional = true }
quick-xml = { version = "0.23.0", features = ["serialize"], optional = true }
rustls-pemfile = { version = "1.0", default-features = false, optional = true }
ring = { version = "0.16", default-features = false, features = ["std"] }
ring = { version = "0.16", default-features = false, features = ["std"], optional = true }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was purely an oversight in influxdata/object_store_rs#42

base64 = { version = "0.13", default-features = false, optional = true }
rand = { version = "0.8", default-features = false, optional = true, features = ["std", "std_rng"] }
rand = { version = "0.8", default-features = false, features = ["std", "std_rng"], optional = true }
# for rusoto
hyper = { version = "0.14", optional = true, default-features = false }
# for rusoto
Expand All @@ -63,7 +63,7 @@ rusoto_sts = { version = "0.48.0", optional = true, default-features = false, fe
snafu = "0.7"
tokio = { version = "1.18", features = ["sync", "macros", "parking_lot", "rt-multi-thread", "time", "io-util"] }
tracing = { version = "0.1" }
reqwest = { version = "0.11", optional = true, default-features = false, features = ["rustls-tls"] }
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"], optional = true }
parking_lot = { version = "0.12" }
# Filesystem integration
url = "2.2"
Expand All @@ -72,7 +72,7 @@ walkdir = "2"
[features]
azure = ["azure_core", "azure_storage_blobs", "azure_storage", "reqwest"]
azure_test = ["azure", "azure_core/azurite_workaround", "azure_storage/azurite_workaround", "azure_storage_blobs/azurite_workaround"]
gcp = ["serde", "serde_json", "quick-xml", "reqwest", "reqwest/json", "reqwest/stream", "chrono/serde", "rustls-pemfile", "base64", "rand"]
gcp = ["serde", "serde_json", "quick-xml", "reqwest", "reqwest/json", "reqwest/stream", "chrono/serde", "rustls-pemfile", "base64", "rand", "ring"]
aws = ["rusoto_core", "rusoto_credential", "rusoto_s3", "rusoto_sts", "hyper", "hyper-rustls"]

[dev-dependencies] # In alphabetical order
Expand Down
57 changes: 5 additions & 52 deletions object_store/src/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1009,34 +1009,6 @@ where
}
}

impl Error {
#[cfg(test)]
fn s3_error_due_to_credentials(&self) -> bool {
use rusoto_core::RusotoError;
use Error::*;

matches!(
self,
UnableToPutData {
source: RusotoError::Credentials(_),
bucket: _,
path: _,
} | UnableToGetData {
source: RusotoError::Credentials(_),
bucket: _,
path: _,
} | UnableToDeleteData {
source: RusotoError::Credentials(_),
bucket: _,
path: _,
} | UnableToListData {
source: RusotoError::Credentials(_),
bucket: _,
}
)
}
}

struct S3MultiPartUpload {
bucket: String,
key: String,
Expand Down Expand Up @@ -1168,9 +1140,6 @@ mod tests {
use bytes::Bytes;
use std::env;

type TestError = Box<dyn std::error::Error + Send + Sync + 'static>;
type Result<T, E = TestError> = std::result::Result<T, E>;

const NON_EXISTENT_NAME: &str = "nonexistentname";

// Helper macro to skip tests if TEST_INTEGRATION and the AWS
Expand Down Expand Up @@ -1250,32 +1219,16 @@ mod tests {
}};
}

fn check_credentials<T>(r: Result<T>) -> Result<T> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been broken since the move to an object-safe ObjectStore, and isn't really providing meaningful value - lets just remove it

if let Err(e) = &r {
let e = &**e;
if let Some(e) = e.downcast_ref::<Error>() {
if e.s3_error_due_to_credentials() {
eprintln!(
"Try setting the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY \
environment variables"
);
}
}
}

r
}

#[tokio::test]
async fn s3_test() {
let config = maybe_skip_integration!();
let integration = config.build().unwrap();

check_credentials(put_get_delete_list(&integration).await).unwrap();
check_credentials(list_uses_directories_correctly(&integration).await).unwrap();
check_credentials(list_with_delimiter(&integration).await).unwrap();
check_credentials(rename_and_copy(&integration).await).unwrap();
check_credentials(stream_get(&integration).await).unwrap();
put_get_delete_list(&integration).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
stream_get(&integration).await;
}

#[tokio::test]
Expand Down
10 changes: 5 additions & 5 deletions object_store/src/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,10 +857,10 @@ mod tests {
async fn azure_blob_test() {
let integration = maybe_skip_integration!().build().unwrap();

put_get_delete_list(&integration).await.unwrap();
list_uses_directories_correctly(&integration).await.unwrap();
list_with_delimiter(&integration).await.unwrap();
rename_and_copy(&integration).await.unwrap();
copy_if_not_exists(&integration).await.unwrap();
put_get_delete_list(&integration).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
copy_if_not_exists(&integration).await;
}
}
10 changes: 5 additions & 5 deletions object_store/src/gcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,14 +1003,14 @@ mod test {
async fn gcs_test() {
let integration = maybe_skip_integration!().build().unwrap();

put_get_delete_list(&integration).await.unwrap();
list_uses_directories_correctly(&integration).await.unwrap();
list_with_delimiter(&integration).await.unwrap();
rename_and_copy(&integration).await.unwrap();
put_get_delete_list(&integration).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
if integration.client.base_url == default_gcs_base_url() {
// Fake GCS server does not yet implement XML Multipart uploads
// https://github.com/fsouza/fake-gcs-server/issues/852
stream_get(&integration).await.unwrap();
stream_get(&integration).await;
}
}

Expand Down
Loading