From 0dba143404bbc1a30fafcd040625a4978a9a98e6 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Fri, 29 Dec 2023 21:55:44 +0000 Subject: [PATCH] Fix command_filesystem_check --- .../tests/command_filesystem_check.rs | 77 ++----------------- 1 file changed, 8 insertions(+), 69 deletions(-) diff --git a/crates/deltalake-core/tests/command_filesystem_check.rs b/crates/deltalake-core/tests/command_filesystem_check.rs index f27fcc2f85..8d0eee6ac6 100644 --- a/crates/deltalake-core/tests/command_filesystem_check.rs +++ b/crates/deltalake-core/tests/command_filesystem_check.rs @@ -1,50 +1,19 @@ #![cfg(feature = "integration_test")] -use deltalake_core::test_utils::{ - set_env_if_not_set, IntegrationContext, StorageIntegration, TestResult, TestTables, -}; use deltalake_core::Path; use deltalake_core::{errors::DeltaTableError, DeltaOps}; +use deltalake_test::utils::*; use serial_test::serial; #[tokio::test] #[serial] async fn test_filesystem_check_local() -> TestResult { - test_filesystem_check(StorageIntegration::Local).await -} - -#[cfg(any(feature = "s3", feature = "s3-native-tls"))] -#[tokio::test] -#[serial] -async fn test_filesystem_check_aws() -> TestResult { - set_env_if_not_set("AWS_S3_ALLOW_UNSAFE_RENAME", "true"); - set_env_if_not_set("AWS_S3_LOCKING_PROVIDER", "none"); - test_filesystem_check(StorageIntegration::Amazon).await -} - -#[cfg(feature = "azure")] -#[tokio::test] -#[serial] -async fn test_filesystem_check_azure() -> TestResult { - test_filesystem_check(StorageIntegration::Microsoft).await -} - -#[cfg(feature = "gcs")] -#[tokio::test] -#[serial] -async fn test_filesystem_check_gcp() -> TestResult { - test_filesystem_check(StorageIntegration::Google).await -} - -#[cfg(feature = "hdfs")] -#[tokio::test] -#[serial] -async fn test_filesystem_check_hdfs() -> TestResult { - Ok(test_filesystem_check(StorageIntegration::Hdfs).await?) + let storage = Box::new(LocalStorageIntegration::default()); + let context = IntegrationContext::new(storage)?; + test_filesystem_check(&context).await } -async fn test_filesystem_check(storage: StorageIntegration) -> TestResult { - let context = IntegrationContext::new(storage)?; +async fn test_filesystem_check(context: &IntegrationContext) -> TestResult { context.load_table(TestTables::Simple).await?; let file = "part-00000-2befed33-c358-4768-a43c-3eda0d2a499d-c000.snappy.parquet"; let path = Path::from_iter([&TestTables::Simple.as_name(), file]); @@ -86,7 +55,7 @@ async fn test_filesystem_check(storage: StorageIntegration) -> TestResult { #[tokio::test] #[serial] async fn test_filesystem_check_partitioned() -> TestResult { - let storage = StorageIntegration::Local; + let storage = Box::new(LocalStorageIntegration::default()); let context = IntegrationContext::new(storage)?; context .load_table(TestTables::Delta0_8_0Partitioned) @@ -120,7 +89,8 @@ async fn test_filesystem_check_partitioned() -> TestResult { #[serial] async fn test_filesystem_check_fails_for_concurrent_delete() -> TestResult { // Validate failure when a non dry only executes on the latest version - let context = IntegrationContext::new(StorageIntegration::Local)?; + let storage = Box::new(LocalStorageIntegration::default()); + let context = IntegrationContext::new(storage)?; context.load_table(TestTables::Simple).await?; let file = "part-00003-53f42606-6cda-4f13-8d07-599a21197296-c000.snappy.parquet"; let path = Path::from_iter([&TestTables::Simple.as_name(), file]); @@ -142,34 +112,3 @@ async fn test_filesystem_check_fails_for_concurrent_delete() -> TestResult { Ok(()) } - -#[tokio::test] -#[serial] -#[ignore = "should this actually fail? with conflict resolution, we are re-trying again."] -async fn test_filesystem_check_outdated() -> TestResult { - // Validate failure when a non dry only executes on the latest version - let context = IntegrationContext::new(StorageIntegration::Local)?; - context.load_table(TestTables::Simple).await?; - let file = "part-00007-3a0e4727-de0d-41b6-81ef-5223cf40f025-c000.snappy.parquet"; - let path = Path::from_iter([&TestTables::Simple.as_name(), file]); - - // Delete an active file from underlying storage without an update to the log to simulate an external fault - context.object_store().delete(&path).await?; - - let table = context - .table_builder(TestTables::Simple) - .with_version(2) - .load() - .await?; - - let op = DeltaOps::from(table); - let res = op.filesystem_check().with_dry_run(false).await; - println!("{:?}", res); - if let Err(DeltaTableError::VersionAlreadyExists(version)) = res { - assert!(version == 3); - } else { - panic!(); - } - - Ok(()) -}