Skip to content

Commit 7cde26a

Browse files
fix(tests): resolve flaky catalog tests by waiting for S3 bucket creation (#1599)
## Which issue does this PR close? - Closes #1581 ## What changes are included in this PR? This ensures tests only run after the complete test environment is initialized correctly, eliminating the timing-based failures. - Wait for both the catalog service and the MinIO service to be ready - Verify S3 bucket existence before proceeding with tests - Add proper retry logic with clear logging for bucket readiness ## Are these changes tested? Yes Co-authored-by: Renjie Liu <[email protected]>
1 parent 41a418c commit 7cde26a

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

crates/catalog/glue/tests/glue_catalog_test.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ async fn get_catalog() -> GlueCatalog {
7373
sleep(std::time::Duration::from_millis(1000)).await;
7474
}
7575

76+
while !scan_port_addr(minio_socket_addr) {
77+
info!("Waiting for 1s minio to ready...");
78+
sleep(std::time::Duration::from_millis(1000)).await;
79+
}
80+
7681
let props = HashMap::from([
7782
(AWS_ACCESS_KEY_ID.to_string(), "my_access_id".to_string()),
7883
(
@@ -89,6 +94,24 @@ async fn get_catalog() -> GlueCatalog {
8994
(S3_REGION.to_string(), "us-east-1".to_string()),
9095
]);
9196

97+
// Wait for bucket to actually exist
98+
let file_io = iceberg::io::FileIO::from_path("s3a://")
99+
.unwrap()
100+
.with_props(props.clone())
101+
.build()
102+
.unwrap();
103+
104+
let mut retries = 0;
105+
while retries < 30 {
106+
if file_io.exists("s3a://warehouse/").await.unwrap_or(false) {
107+
info!("S3 bucket 'warehouse' is ready");
108+
break;
109+
}
110+
info!("Waiting for bucket creation... (attempt {})", retries + 1);
111+
sleep(std::time::Duration::from_millis(1000)).await;
112+
retries += 1;
113+
}
114+
92115
let config = GlueCatalogConfig::builder()
93116
.uri(format!("http://{}", glue_socket_addr))
94117
.warehouse("s3a://warehouse/hive".to_string())

crates/catalog/hms/tests/hms_catalog_test.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ async fn get_catalog() -> HmsCatalog {
7373
sleep(std::time::Duration::from_millis(1000)).await;
7474
}
7575

76+
while !scan_port_addr(minio_socket_addr) {
77+
info!("Waiting for 1s minio to ready...");
78+
sleep(std::time::Duration::from_millis(1000)).await;
79+
}
80+
7681
let props = HashMap::from([
7782
(
7883
S3_ENDPOINT.to_string(),
@@ -83,6 +88,24 @@ async fn get_catalog() -> HmsCatalog {
8388
(S3_REGION.to_string(), "us-east-1".to_string()),
8489
]);
8590

91+
// Wait for bucket to actually exist
92+
let file_io = iceberg::io::FileIO::from_path("s3a://")
93+
.unwrap()
94+
.with_props(props.clone())
95+
.build()
96+
.unwrap();
97+
98+
let mut retries = 0;
99+
while retries < 30 {
100+
if file_io.exists("s3a://warehouse/").await.unwrap_or(false) {
101+
info!("S3 bucket 'warehouse' is ready");
102+
break;
103+
}
104+
info!("Waiting for bucket creation... (attempt {})", retries + 1);
105+
sleep(std::time::Duration::from_millis(1000)).await;
106+
retries += 1;
107+
}
108+
86109
let config = HmsCatalogConfig::builder()
87110
.address(hms_socket_addr.to_string())
88111
.thrift_transport(HmsThriftTransport::Buffered)

0 commit comments

Comments
 (0)