Skip to content

Commit 6e559d7

Browse files
committed
Fix LocalStack S3 bucket setup in parquet test
1 parent ec18888 commit 6e559d7

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

volga_stream/src/runtime/functions/source/parquet/integration_tests.rs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,15 +350,16 @@ async fn parquet_sink_bounded_concurrency_backpressure() {
350350
#[ignore]
351351
async fn parquet_s3_roundtrip_localstack() {
352352
let docker = Cli::default();
353-
let image = GenericImage::new("localstack/localstack", "latest")
353+
let image = GenericImage::new("localstack/localstack", "3.0")
354354
.with_env_var("SERVICES", "s3")
355355
.with_env_var("DEFAULT_REGION", "us-east-1")
356-
.with_env_var("DEFAULT_BUCKETS", "volga-test")
357356
.with_exposed_port(4566)
358-
.with_wait_for(WaitFor::seconds(5));
359-
let runnable = RunnableImage::from(image);
357+
.with_wait_for(WaitFor::seconds(3));
358+
let runnable = RunnableImage::from(image).with_mapped_port((4566, 4566));
360359
let container = docker.run(runnable);
361360
let endpoint = format!("http://127.0.0.1:{}", container.get_host_port_ipv4(4566));
361+
wait_for_localstack_ready("127.0.0.1:4566").await;
362+
create_localstack_bucket(&endpoint, "volga-test").await;
362363

363364
let schema = test_schema();
364365
let opts = HashMap::from([
@@ -376,3 +377,28 @@ async fn parquet_s3_roundtrip_localstack() {
376377
)
377378
.await;
378379
}
380+
381+
async fn wait_for_localstack_ready(addr: &str) {
382+
for _ in 0..40 {
383+
if tokio::net::TcpStream::connect(addr).await.is_ok() {
384+
return;
385+
}
386+
tokio::time::sleep(std::time::Duration::from_millis(250)).await;
387+
}
388+
panic!("LocalStack did not become ready at {}", addr);
389+
}
390+
391+
async fn create_localstack_bucket(endpoint: &str, bucket: &str) {
392+
let url = format!("{}/{}", endpoint, bucket);
393+
let client = reqwest::Client::new();
394+
for _ in 0..10 {
395+
match client.put(&url).send().await {
396+
Ok(resp) if resp.status().is_success() || resp.status().as_u16() == 409 => {
397+
return;
398+
}
399+
_ => {}
400+
}
401+
tokio::time::sleep(std::time::Duration::from_millis(250)).await;
402+
}
403+
panic!("Failed to create LocalStack bucket at {}", url);
404+
}

0 commit comments

Comments
 (0)