diff --git a/icechunk/Cargo.toml b/icechunk/Cargo.toml index 971685edb..a3cbd6c8b 100644 --- a/icechunk/Cargo.toml +++ b/icechunk/Cargo.toml @@ -79,6 +79,7 @@ reqwest = { version = "0.12.26", default-features = false, features = [ "http2", "system-proxy", ] } +tempfile = "3.23.0" [dev-dependencies] fs_extra = "1.3.0" icechunk-macros = { path = "../icechunk-macros", version = "0.1.0" } diff --git a/icechunk/src/change_set.rs b/icechunk/src/change_set.rs index 6958ed09e..87572009e 100644 --- a/icechunk/src/change_set.rs +++ b/icechunk/src/change_set.rs @@ -965,4 +965,6 @@ mod tests { &Path::new("/other").unwrap(), ); } + + // roundtrip_serialization_tests!(serialize_and_deserialize_change_sets - change_sets); } diff --git a/icechunk/src/config.rs b/icechunk/src/config.rs index a5f80bda0..04e2c16d4 100644 --- a/icechunk/src/config.rs +++ b/icechunk/src/config.rs @@ -632,25 +632,17 @@ pub enum Credentials { Azure(AzureCredentials), } -#[cfg(test)] -#[allow(clippy::panic, clippy::unwrap_used, clippy::expect_used)] -mod tests { - use crate::strategies::{ - azure_credentials, gcs_static_credentials, repository_config, - s3_static_credentials, - }; - - use proptest::prelude::*; - - // This macro is used for creating property tests - // which check that serializing and deserializing - // an instance of a type T is equivalent to the - // identity function - // Given pairs of test names and arbitraries to be used - // for the tests, e.g., (n1, a1), (n2, a2),... (nx, ax) - // the tests can be created by doing - // roundtrip_serialization_tests!(n1 - a1, n2 - a2, .... nx - ax) - macro_rules! roundtrip_serialization_tests { +// This macro is used for creating property tests +// which check that serializing and deserializing +// an instance of a type T is equivalent to the +// identity function +// Given pairs of test names and arbitraries to be used +// for the tests, e.g., (n1, a1), (n2, a2),... (nx, ax) +// the tests can be created by doing +// roundtrip_serialization_tests!(n1 - a1, n2 - a2, .... nx - ax) +#[allow(unused_macros)] +#[macro_export] +macro_rules! roundtrip_serialization_tests { ($($test_name: ident - $generator: ident), +) => { $( proptest!{ @@ -663,6 +655,16 @@ mod tests { } } +#[cfg(test)] +#[allow(clippy::panic, clippy::unwrap_used, clippy::expect_used)] +mod tests { + use crate::strategies::{ + azure_credentials, gcs_static_credentials, repository_config, + s3_static_credentials, + }; + + use proptest::prelude::*; + roundtrip_serialization_tests!( test_config_roundtrip - repository_config, test_s3_static_credentials_roundtrip - s3_static_credentials, diff --git a/icechunk/src/storage/redirect.rs b/icechunk/src/storage/redirect.rs index 31993ed4a..b84c50d93 100644 --- a/icechunk/src/storage/redirect.rs +++ b/icechunk/src/storage/redirect.rs @@ -55,6 +55,7 @@ impl RedirectStorage { } async fn mk_backend(&self) -> StorageResult> { + println!("\n------Using this function-----\n\n"); let redirect = |attempt: rw::redirect::Attempt| { // TODO: make configurable if attempt.previous().len() > 10 { @@ -77,6 +78,8 @@ impl RedirectStorage { "Cannot build http client for redirect Storage instance: {e}" ))) })?; + + println!(" The URL is {}", self.url.clone()); let req = client.get(self.url.clone()).build().map_err(|e| { StorageError::from(StorageErrorKind::BadRedirect(format!( "Cannot build http request for redirect Storage instance: {e}" @@ -87,6 +90,7 @@ impl RedirectStorage { "Request to redirect url ({}) failed, cannot find target Storage instance: {e}", &self.url ))) })?; + println!("The status: {}, The headers: {:?}", res.status(), res.headers()); let storage_url = res.headers().get("location").ok_or_else(|| { StorageError::from(StorageErrorKind::BadRedirect( "Redirect Storage response must be a redirect, no location header detected".to_string() diff --git a/icechunk/src/strategies.rs b/icechunk/src/strategies.rs index 4361a9f2b..53b542227 100644 --- a/icechunk/src/strategies.rs +++ b/icechunk/src/strategies.rs @@ -456,3 +456,56 @@ pub fn azure_credentials() -> BoxedStrategy { use AzureCredentials::*; prop_oneof![Just(FromEnv), azure_static_credentials().prop_map(Static)].boxed() } + +// pub fn path() -> BoxedStrategy { +// Just(()) +// .prop_filter_map("Could not generate a valid file path", |_| { +// let canon_file_path = NamedTempFile::new() +// .ok() +// .and_then(|file| file.path().canonicalize().ok())?; +// +// canon_file_path.to_str().and_then(|file_name| Path::new(file_name).ok()) +// }) +// .boxed() +// } +// +// type DimensionShapeInfo = (u64, u64); +// +// prop_compose! { +// fn dimension_shape_info()(dim_length in any::(), chunk_length in any::()) -> DimensionShapeInfo { +// (dim_length, chunk_length.get()) +// } +// } +// +// prop_compose! { +// fn array_shape()(dimensions in vec(dimension_shape_info(), 10)) -> ArrayShape { +// ArrayShape::new(dimensions).unwrap() +// } +// } +// +// fn dimension_name() -> BoxedStrategy { +// use DimensionName::*; +// prop_oneof![ +// Just(NotSpecified), +// any::().prop_map(Name) +// ].boxed() +// } +// +// prop_compose! { +// fn bytes()(random_data in any::>()) -> Bytes { +// Bytes::from(random_data) +// } +// } +// +// prop_compose! { +// fn array_data()(shape in array_shape(), +// dimension_names in option::of(vec(dimension_name(), 10)), +// user_data in bytes()) -> ArrayData { +// ArrayData{shape, dimension_names, user_data} +// } +// } +// +// fn node_id() -> BoxedStrategy { +// Just(NodeId::random()).boxed() +// } +// diff --git a/icechunk/tests/test_storage.rs b/icechunk/tests/test_storage.rs index 2d20b19a7..f318e1600 100644 --- a/icechunk/tests/test_storage.rs +++ b/icechunk/tests/test_storage.rs @@ -933,9 +933,13 @@ pub async fn test_redirect_storage() -> Result<(), Box> { let join = tokio::task::spawn(server.run()); let url = format!("http://localhost:{port}"); + println!("Have not errored before reaching this point"); let storage = new_redirect_storage(url.as_str())?; + println!("The value is {storage:?}"); let mut data = Vec::with_capacity(1_024); + println!("Have not errored before reaching the second point"); let settings = storage.default_settings().await?; + println!("Have not errored before reaching the third point"); let mut read = storage.get_object(&settings, "refs/branch.main/ref.json", None).await?.0;