@@ -36,21 +36,24 @@ use iceberg_test_utils::{
3636use tokio:: time:: sleep;
3737use tracing:: info;
3838
39- async fn get_postgres_catalog ( warehouse_location : & str ) -> impl Catalog {
39+ async fn get_postgres_catalog ( ) -> impl Catalog {
4040 set_up ( ) ;
4141
4242 let postgres_uri = get_postgres_endpoint ( ) ;
43+ let tmp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
44+ let warehouse_location = tmp_dir. path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
45+ let _ = tmp_dir. keep ( ) ;
4346
4447 let mut retries = 0 ;
45- let catalog = loop {
48+ loop {
4649 match SqlCatalogBuilder :: default ( )
4750 . load (
4851 "test_postgres" ,
4952 HashMap :: from ( [
5053 ( SQL_CATALOG_PROP_URI . to_string ( ) , postgres_uri. clone ( ) ) ,
5154 (
5255 SQL_CATALOG_PROP_WAREHOUSE . to_string ( ) ,
53- warehouse_location. to_string ( ) ,
56+ warehouse_location. clone ( ) ,
5457 ) ,
5558 (
5659 SQL_CATALOG_PROP_BIND_STYLE . to_string ( ) ,
@@ -73,26 +76,27 @@ async fn get_postgres_catalog(warehouse_location: &str) -> impl Catalog {
7376 sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) . await ;
7477 }
7578 }
76- } ;
77-
78- catalog
79+ }
7980}
8081
81- async fn get_mysql_catalog ( warehouse_location : & str ) -> impl Catalog {
82+ async fn get_mysql_catalog ( ) -> impl Catalog {
8283 set_up ( ) ;
8384
8485 let mysql_uri = get_mysql_endpoint ( ) ;
86+ let tmp_dir = tempfile:: tempdir ( ) . unwrap ( ) ;
87+ let warehouse_location = tmp_dir. path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
88+ let _ = tmp_dir. keep ( ) ;
8589
8690 let mut retries = 0 ;
87- let catalog = loop {
91+ loop {
8892 match SqlCatalogBuilder :: default ( )
8993 . load (
9094 "test_mysql" ,
9195 HashMap :: from ( [
9296 ( SQL_CATALOG_PROP_URI . to_string ( ) , mysql_uri. clone ( ) ) ,
9397 (
9498 SQL_CATALOG_PROP_WAREHOUSE . to_string ( ) ,
95- warehouse_location. to_string ( ) ,
99+ warehouse_location. clone ( ) ,
96100 ) ,
97101 (
98102 SQL_CATALOG_PROP_BIND_STYLE . to_string ( ) ,
@@ -115,9 +119,7 @@ async fn get_mysql_catalog(warehouse_location: &str) -> impl Catalog {
115119 sleep ( std:: time:: Duration :: from_millis ( 1000 ) ) . await ;
116120 }
117121 }
118- } ;
119-
120- catalog
122+ }
121123}
122124
123125fn simple_table_schema ( ) -> Schema {
@@ -142,8 +144,7 @@ macro_rules! sql_catalog_tests {
142144
143145 #[ tokio:: test]
144146 async fn test_create_namespace( ) {
145- let warehouse = normalize_test_name_with_parts!( "test_create_namespace" ) ;
146- let catalog = $get_catalog( & warehouse) . await ;
147+ let catalog = $get_catalog( ) . await ;
147148 let ns =
148149 NamespaceIdent :: new( normalize_test_name_with_parts!( "test_create_namespace" ) ) ;
149150 cleanup_namespace( & catalog, & ns) . await ;
@@ -156,9 +157,7 @@ macro_rules! sql_catalog_tests {
156157
157158 #[ tokio:: test]
158159 async fn test_create_namespace_with_properties( ) {
159- let warehouse =
160- normalize_test_name_with_parts!( "test_create_namespace_with_properties" ) ;
161- let catalog = $get_catalog( & warehouse) . await ;
160+ let catalog = $get_catalog( ) . await ;
162161 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
163162 "test_create_namespace_with_properties"
164163 ) ) ;
@@ -179,9 +178,7 @@ macro_rules! sql_catalog_tests {
179178
180179 #[ tokio:: test]
181180 async fn test_create_duplicate_namespace_fails( ) {
182- let warehouse =
183- normalize_test_name_with_parts!( "test_create_duplicate_namespace_fails" ) ;
184- let catalog = $get_catalog( & warehouse) . await ;
181+ let catalog = $get_catalog( ) . await ;
185182 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
186183 "test_create_duplicate_namespace_fails"
187184 ) ) ;
@@ -195,8 +192,7 @@ macro_rules! sql_catalog_tests {
195192
196193 #[ tokio:: test]
197194 async fn test_get_namespace( ) {
198- let warehouse = normalize_test_name_with_parts!( "test_get_namespace" ) ;
199- let catalog = $get_catalog( & warehouse) . await ;
195+ let catalog = $get_catalog( ) . await ;
200196 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_get_namespace" ) ) ;
201197 cleanup_namespace( & catalog, & ns) . await ;
202198
@@ -208,9 +204,7 @@ macro_rules! sql_catalog_tests {
208204
209205 #[ tokio:: test]
210206 async fn test_get_non_existent_namespace_fails( ) {
211- let warehouse =
212- normalize_test_name_with_parts!( "test_get_non_existent_namespace_fails" ) ;
213- let catalog = $get_catalog( & warehouse) . await ;
207+ let catalog = $get_catalog( ) . await ;
214208 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
215209 "test_get_non_existent_namespace_fails"
216210 ) ) ;
@@ -222,8 +216,7 @@ macro_rules! sql_catalog_tests {
222216
223217 #[ tokio:: test]
224218 async fn test_namespace_exists( ) {
225- let warehouse = normalize_test_name_with_parts!( "test_namespace_exists" ) ;
226- let catalog = $get_catalog( & warehouse) . await ;
219+ let catalog = $get_catalog( ) . await ;
227220 let ns =
228221 NamespaceIdent :: new( normalize_test_name_with_parts!( "test_namespace_exists" ) ) ;
229222 cleanup_namespace( & catalog, & ns) . await ;
@@ -237,8 +230,7 @@ macro_rules! sql_catalog_tests {
237230
238231 #[ tokio:: test]
239232 async fn test_list_namespaces( ) {
240- let warehouse = normalize_test_name_with_parts!( "test_list_namespaces" ) ;
241- let catalog = $get_catalog( & warehouse) . await ;
233+ let catalog = $get_catalog( ) . await ;
242234 let ns1 = NamespaceIdent :: new( normalize_test_name_with_parts!(
243235 "test_list_namespaces" ,
244236 "ns1"
@@ -266,8 +258,7 @@ macro_rules! sql_catalog_tests {
266258
267259 #[ tokio:: test]
268260 async fn test_list_nested_namespaces( ) {
269- let warehouse = normalize_test_name_with_parts!( "test_list_nested_namespaces" ) ;
270- let catalog = $get_catalog( & warehouse) . await ;
261+ let catalog = $get_catalog( ) . await ;
271262 let parent = NamespaceIdent :: new( normalize_test_name_with_parts!(
272263 "test_list_nested_namespaces" ,
273264 "parent"
@@ -299,8 +290,7 @@ macro_rules! sql_catalog_tests {
299290
300291 #[ tokio:: test]
301292 async fn test_update_namespace( ) {
302- let warehouse = normalize_test_name_with_parts!( "test_update_namespace" ) ;
303- let catalog = $get_catalog( & warehouse) . await ;
293+ let catalog = $get_catalog( ) . await ;
304294 let ns =
305295 NamespaceIdent :: new( normalize_test_name_with_parts!( "test_update_namespace" ) ) ;
306296 cleanup_namespace( & catalog, & ns) . await ;
@@ -324,8 +314,7 @@ macro_rules! sql_catalog_tests {
324314
325315 #[ tokio:: test]
326316 async fn test_drop_namespace( ) {
327- let warehouse = normalize_test_name_with_parts!( "test_drop_namespace" ) ;
328- let catalog = $get_catalog( & warehouse) . await ;
317+ let catalog = $get_catalog( ) . await ;
329318 let ns =
330319 NamespaceIdent :: new( normalize_test_name_with_parts!( "test_drop_namespace" ) ) ;
331320 cleanup_namespace( & catalog, & ns) . await ;
@@ -339,9 +328,7 @@ macro_rules! sql_catalog_tests {
339328
340329 #[ tokio:: test]
341330 async fn test_drop_non_existent_namespace_fails( ) {
342- let warehouse =
343- normalize_test_name_with_parts!( "test_drop_non_existent_namespace_fails" ) ;
344- let catalog = $get_catalog( & warehouse) . await ;
331+ let catalog = $get_catalog( ) . await ;
345332 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
346333 "test_drop_non_existent_namespace_fails"
347334 ) ) ;
@@ -353,8 +340,7 @@ macro_rules! sql_catalog_tests {
353340
354341 #[ tokio:: test]
355342 async fn test_create_table( ) {
356- let warehouse = normalize_test_name_with_parts!( "test_create_table" ) ;
357- let catalog = $get_catalog( & warehouse) . await ;
343+ let catalog = $get_catalog( ) . await ;
358344 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_create_table" ) ) ;
359345 cleanup_namespace( & catalog, & ns) . await ;
360346
@@ -381,9 +367,7 @@ macro_rules! sql_catalog_tests {
381367
382368 #[ tokio:: test]
383369 async fn test_create_duplicate_table_fails( ) {
384- let warehouse =
385- normalize_test_name_with_parts!( "test_create_duplicate_table_fails" ) ;
386- let catalog = $get_catalog( & warehouse) . await ;
370+ let catalog = $get_catalog( ) . await ;
387371 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
388372 "test_create_duplicate_table_fails"
389373 ) ) ;
@@ -409,8 +393,7 @@ macro_rules! sql_catalog_tests {
409393
410394 #[ tokio:: test]
411395 async fn test_list_tables( ) {
412- let warehouse = normalize_test_name_with_parts!( "test_list_tables" ) ;
413- let catalog = $get_catalog( & warehouse) . await ;
396+ let catalog = $get_catalog( ) . await ;
414397 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_list_tables" ) ) ;
415398 cleanup_namespace( & catalog, & ns) . await ;
416399
@@ -436,8 +419,7 @@ macro_rules! sql_catalog_tests {
436419
437420 #[ tokio:: test]
438421 async fn test_list_tables_returns_empty( ) {
439- let warehouse = normalize_test_name_with_parts!( "test_list_tables_returns_empty" ) ;
440- let catalog = $get_catalog( & warehouse) . await ;
422+ let catalog = $get_catalog( ) . await ;
441423 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
442424 "test_list_tables_returns_empty"
443425 ) ) ;
@@ -451,8 +433,7 @@ macro_rules! sql_catalog_tests {
451433
452434 #[ tokio:: test]
453435 async fn test_load_table( ) {
454- let warehouse = normalize_test_name_with_parts!( "test_load_table" ) ;
455- let catalog = $get_catalog( & warehouse) . await ;
436+ let catalog = $get_catalog( ) . await ;
456437 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_load_table" ) ) ;
457438 cleanup_namespace( & catalog, & ns) . await ;
458439
@@ -479,8 +460,7 @@ macro_rules! sql_catalog_tests {
479460
480461 #[ tokio:: test]
481462 async fn test_rename_table( ) {
482- let warehouse = normalize_test_name_with_parts!( "test_rename_table" ) ;
483- let catalog = $get_catalog( & warehouse) . await ;
463+ let catalog = $get_catalog( ) . await ;
484464 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_rename_table" ) ) ;
485465 cleanup_namespace( & catalog, & ns) . await ;
486466
@@ -504,9 +484,7 @@ macro_rules! sql_catalog_tests {
504484
505485 #[ tokio:: test]
506486 async fn test_rename_table_across_namespaces( ) {
507- let warehouse =
508- normalize_test_name_with_parts!( "test_rename_table_across_namespaces" ) ;
509- let catalog = $get_catalog( & warehouse) . await ;
487+ let catalog = $get_catalog( ) . await ;
510488 let ns1 = NamespaceIdent :: new( normalize_test_name_with_parts!(
511489 "test_rename_table_across_namespaces" ,
512490 "ns1"
@@ -545,8 +523,7 @@ macro_rules! sql_catalog_tests {
545523
546524 #[ tokio:: test]
547525 async fn test_drop_table( ) {
548- let warehouse = normalize_test_name_with_parts!( "test_drop_table" ) ;
549- let catalog = $get_catalog( & warehouse) . await ;
526+ let catalog = $get_catalog( ) . await ;
550527 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_drop_table" ) ) ;
551528 cleanup_namespace( & catalog, & ns) . await ;
552529
@@ -567,9 +544,7 @@ macro_rules! sql_catalog_tests {
567544
568545 #[ tokio:: test]
569546 async fn test_drop_non_existent_table_fails( ) {
570- let warehouse =
571- normalize_test_name_with_parts!( "test_drop_non_existent_table_fails" ) ;
572- let catalog = $get_catalog( & warehouse) . await ;
547+ let catalog = $get_catalog( ) . await ;
573548 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!(
574549 "test_drop_non_existent_table_fails"
575550 ) ) ;
@@ -584,8 +559,7 @@ macro_rules! sql_catalog_tests {
584559
585560 #[ tokio:: test]
586561 async fn test_table_exists( ) {
587- let warehouse = normalize_test_name_with_parts!( "test_table_exists" ) ;
588- let catalog = $get_catalog( & warehouse) . await ;
562+ let catalog = $get_catalog( ) . await ;
589563 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_table_exists" ) ) ;
590564 cleanup_namespace( & catalog, & ns) . await ;
591565
@@ -605,8 +579,7 @@ macro_rules! sql_catalog_tests {
605579
606580 #[ tokio:: test]
607581 async fn test_register_table( ) {
608- let warehouse = normalize_test_name_with_parts!( "test_register_table" ) ;
609- let catalog = $get_catalog( & warehouse) . await ;
582+ let catalog = $get_catalog( ) . await ;
610583 let ns =
611584 NamespaceIdent :: new( normalize_test_name_with_parts!( "test_register_table" ) ) ;
612585 cleanup_namespace( & catalog, & ns) . await ;
@@ -638,8 +611,7 @@ macro_rules! sql_catalog_tests {
638611
639612 #[ tokio:: test]
640613 async fn test_update_table( ) {
641- let warehouse = normalize_test_name_with_parts!( "test_update_table" ) ;
642- let catalog = $get_catalog( & warehouse) . await ;
614+ let catalog = $get_catalog( ) . await ;
643615 let ns = NamespaceIdent :: new( normalize_test_name_with_parts!( "test_update_table" ) ) ;
644616 cleanup_namespace( & catalog, & ns) . await ;
645617
0 commit comments