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

(object_store): Instantiate object store from provided url #4077

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
36 changes: 33 additions & 3 deletions object_store/src/aws/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,8 @@ fn profile_credentials(
#[cfg(test)]
mod tests {
use super::*;
use crate::options::StoreOptions;
use crate::parse_url;
use crate::tests::{
get_nonexistent_object, list_uses_directories_correctly, list_with_delimiter,
put_get_delete_list_opts, rename_and_copy, stream_get,
Expand Down Expand Up @@ -1396,26 +1398,29 @@ mod tests {
async fn s3_test() {
let config = maybe_skip_integration!();
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
let integration = config.build().unwrap();
let integration = config.clone().build().unwrap();

// Localstack doesn't support listing with spaces https://github.com/localstack/localstack/issues/6328
put_get_delete_list_opts(&integration, is_local).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
stream_get(&integration).await;
s3_parse_from_url_test(config, is_local).await;

// run integration test with unsigned payload enabled
let config = maybe_skip_integration!().with_unsigned_payload(true);
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
let integration = config.build().unwrap();
let integration = config.clone().build().unwrap();
put_get_delete_list_opts(&integration, is_local).await;
s3_parse_from_url_test(config.clone(), is_local).await;

// run integration test with checksum set to sha256
let config = maybe_skip_integration!().with_checksum_algorithm(Checksum::SHA256);
let is_local = matches!(&config.endpoint, Some(e) if e.starts_with("http://"));
let integration = config.build().unwrap();
let integration = config.clone().build().unwrap();
put_get_delete_list_opts(&integration, is_local).await;
s3_parse_from_url_test(config, is_local).await;
}

#[tokio::test]
Expand Down Expand Up @@ -1562,4 +1567,29 @@ mod tests {
builder.parse_url(case).unwrap_err();
}
}

async fn s3_parse_from_url_test(config: AmazonS3Builder, is_local: bool) {
let store_options = HashMap::from([
("AWS_ACCESS_KEY_ID", config.access_key_id.unwrap()),
("AWS_SECRET_ACCESS_KEY", config.secret_access_key.unwrap()),
("aws_default_region", config.region.unwrap()),
("AWS_ENDPOINT", config.endpoint.clone().unwrap()),
]);

let client_options = ClientOptions::new().with_allow_http(true);

// Create instance of S3 object_store.
let integration = parse_url(
format!("s3://{}/", &config.bucket_name.unwrap()),
Some(StoreOptions::new(store_options, client_options)),
false,
)
.unwrap();

put_get_delete_list_opts(&integration, is_local).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
stream_get(&integration).await;
}
}
31 changes: 30 additions & 1 deletion object_store/src/azure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,8 @@ fn split_sas(sas: &str) -> Result<Vec<(String, String)>, Error> {
#[cfg(test)]
mod tests {
use super::*;
use crate::options::StoreOptions;
use crate::parse_url;
use crate::tests::{
copy_if_not_exists, list_uses_directories_correctly, list_with_delimiter,
put_get_delete_list, put_get_delete_list_opts, rename_and_copy, stream_get,
Expand Down Expand Up @@ -1174,7 +1176,34 @@ mod tests {

#[tokio::test]
async fn azure_blob_test() {
let integration = maybe_skip_integration!().build().unwrap();
let config = maybe_skip_integration!();
let integration = config.clone().build().unwrap();
put_get_delete_list_opts(&integration, false).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
rename_and_copy(&integration).await;
copy_if_not_exists(&integration).await;
stream_get(&integration).await;

azure_parse_from_url_test(config).await;
}

async fn azure_parse_from_url_test(config: MicrosoftAzureBuilder) {
let store_options = HashMap::from([(
"azure_storage_use_emulator",
config.use_emulator.to_string(),
)]);

let client_options = ClientOptions::new().with_allow_http(true);

// Create instance of S3 object_store.
let integration = parse_url(
format!("az://{}/", &config.container_name.unwrap()),
Some(StoreOptions::new(store_options, client_options)),
false,
)
.unwrap();

put_get_delete_list_opts(&integration, false).await;
list_uses_directories_correctly(&integration).await;
list_with_delimiter(&integration).await;
Expand Down
Loading