Skip to content

Commit

Permalink
test: added two azure integration tests to check if storage_options g…
Browse files Browse the repository at this point in the history
…et forwarded to ListingSchemaProvider correctly
  • Loading branch information
Nordalf authored and rtyler committed Oct 7, 2024
1 parent 274f608 commit 374d355
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/azure/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ repository.workspace = true
rust-version.workspace = true

[dependencies]
deltalake-core = { version = "0.21.0", path = "../core" }
deltalake-core = { version = "0.21.0", path = "../core", features = [
"datafusion",
] }
lazy_static = "1"

# workspace depenndecies
async-trait = { workspace = true }
bytes = { workspace = true }
futures = { workspace = true }
tracing = { workspace = true }
object_store = { workspace = true, features = ["azure"]}
object_store = { workspace = true, features = ["azure"] }
thiserror = { workspace = true }
tokio = { workspace = true }
regex = { workspace = true }
Expand Down
43 changes: 43 additions & 0 deletions crates/azure/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#![cfg(feature = "integration_test")]

use std::assert_eq;
use std::collections::HashMap;

use bytes::Bytes;
use deltalake_core::data_catalog::storage::ListingSchemaProvider;
use deltalake_core::DeltaTableBuilder;
use deltalake_test::read::read_table_paths;
use deltalake_test::{test_concurrent_writes, test_read_tables, IntegrationContext, TestResult};
Expand Down Expand Up @@ -89,3 +93,42 @@ async fn read_write_test_onelake(context: &IntegrationContext, path: &Path) -> T

Ok(())
}

#[test]
#[serial]
fn list_delta_tables_using_listing_provider_with_missing_account_name() -> TestResult {
let context = IntegrationContext::new(Box::new(MsftIntegration::default()))?;
// Removing the the envs set by the `IntegrationContext (az_cli::prepare_env())` to illustrate the issue if e.g. account_name is not set from custom `storage_options`, but still preserving the use of the `IntegrationContext`
std::env::remove_var("AZURE_STORAGE_USE_EMULATOR");
std::env::remove_var("AZURE_STORAGE_ACCOUNT_NAME");
std::env::remove_var("AZURE_STORAGE_TOKEN");
std::env::remove_var("AZURE_STORAGE_ACCOUNT_KEY");

let storage_options = HashMap::<String, String>::new();
if let Err(read_error) =
ListingSchemaProvider::try_new(&context.root_uri(), Some(storage_options))
{
assert_eq!(read_error.to_string(), "Failed to read delta log object: Generic MicrosoftAzure error: Account must be specified".to_string());
};
Ok(())
}

#[tokio::test]
#[serial]
async fn list_delta_tables_using_listing_provider_with_account_name() -> TestResult {
let context = IntegrationContext::new(Box::new(MsftIntegration::default()))?;
// Removing the the envs set by the `IntegrationContext (az_cli::prepare_env())` to illustrate the issue if e.g. account_name is not set from custom `storage_options`, but still preserving the use of the `IntegrationContext`
std::env::remove_var("AZURE_STORAGE_USE_EMULATOR");
std::env::remove_var("AZURE_STORAGE_ACCOUNT_NAME");
std::env::remove_var("AZURE_STORAGE_TOKEN");
std::env::remove_var("AZURE_STORAGE_ACCOUNT_KEY");

let mut storage_options = HashMap::<String, String>::new();
storage_options.insert("account_name".to_string(), "test_account".to_string());
let schema = ListingSchemaProvider::try_new(&context.root_uri(), Some(storage_options));
assert!(
schema.is_ok(),
"Capable of reading the storage options. Fails if e.g. `account_name` is missing"
);
Ok(())
}

0 comments on commit 374d355

Please sign in to comment.