Skip to content

Commit bd9c72c

Browse files
authored
Merge pull request JanKaul#150 from JanKaul/fix/rest-catalog-test
Fix/rest catalog test
2 parents 4b61a70 + 040d285 commit bd9c72c

6 files changed

Lines changed: 39 additions & 5 deletions

File tree

.github/workflows/rust.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ jobs:
2222
run: make test-iceberg-rust
2323
- name: Run datafusion-iceberg tests
2424
run: make test-datafusion_iceberg
25+
- name: Run iceberg-rest-catalog tests
26+
run: make test-rest-catalog
27+
- name: Run iceberg-file-catalog tests
28+
run: make test-file-catalog
29+
- name: Run iceberg-sql-catalog tests
30+
run: make test-sql-catalog
2531

2632
lint:
2733
runs-on: ubuntu-latest

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ test-iceberg-rust:
77
cargo test -p iceberg-rust --lib
88

99
test-datafusion_iceberg:
10-
cargo test -p datafusion_iceberg --tests -j 2
10+
cargo test -p datafusion_iceberg --tests -j 2 && cargo clean -p datafusion_iceberg
1111

12+
test-rest-catalog:
13+
cargo test -p iceberg-rest-catalog --lib && cargo clean -p iceberg-rest-catalog
14+
15+
test-file-catalog:
16+
cargo test -p iceberg-file-catalog --lib && cargo clean -p iceberg-file-catalog
17+
18+
test-sql-catalog:
19+
cargo test -p iceberg-sql-catalog --lib && cargo clean -p iceberg-sql-catalog
1220
clippy:
1321
cargo clippy --all-targets --all-features -- -D warnings

catalogs/iceberg-rest-catalog/src/catalog.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ impl Catalog for RestCatalog {
215215
.await
216216
})
217217
.await
218-
.map_err(Into::<Error>::into) {
218+
.map_err(Into::<Error>::into)
219+
{
219220
Ok(_) => Ok(true),
220221
Err(Error::NotFound(_)) => Ok(false),
221222
Err(e) => Err(e),
@@ -613,7 +614,7 @@ pub mod tests {
613614
.await
614615
.unwrap();
615616

616-
localstack
617+
let command = localstack
617618
.exec(ExecCommand::new(vec![
618619
"awslocal",
619620
"s3api",
@@ -624,6 +625,10 @@ pub mod tests {
624625
.await
625626
.unwrap();
626627

628+
while command.exit_code().await.unwrap().is_none() {
629+
sleep(Duration::from_millis(100)).await;
630+
}
631+
627632
let localstack_host = localstack.get_host().await.unwrap();
628633
let localstack_port = localstack.get_host_port_ipv4(4566).await.unwrap();
629634

catalogs/iceberg-rest-catalog/src/error.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use iceberg_rust::error::Error;
2+
use reqwest::StatusCode;
23

3-
use crate::apis::{self, catalog_api_api::CreateNamespaceError};
4+
use crate::apis::{self, catalog_api_api::CreateNamespaceError, ResponseContent};
45

56
/**
67
Error conversion
@@ -11,6 +12,11 @@ impl<T> From<apis::Error<T>> for Error {
1112
apis::Error::Reqwest(err) => Error::InvalidFormat(err.to_string()),
1213
apis::Error::Serde(err) => Error::JSONSerde(err),
1314
apis::Error::Io(err) => Error::IO(err),
15+
apis::Error::ResponseError(ResponseContent {
16+
status: StatusCode::NOT_FOUND,
17+
content,
18+
entity: _,
19+
}) => Error::NotFound(content),
1420
apis::Error::ResponseError(err) => Error::InvalidFormat(format!(
1521
"Response status: {}, Response content: {}",
1622
err.status, err.content

catalogs/iceberg-sql-catalog/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,10 @@ pub mod tests {
760760
.await
761761
.unwrap();
762762

763+
while command.exit_code().await.unwrap().is_none() {
764+
sleep(Duration::from_millis(100)).await;
765+
}
766+
763767
let postgres = Postgres::default()
764768
.with_db_name("postgres")
765769
.with_user("postgres")

datafusion_iceberg/tests/integration_trino.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use testcontainers::{
2525
GenericImage, ImageExt,
2626
};
2727
use testcontainers_modules::localstack::LocalStack;
28+
use tokio::time::sleep;
2829

2930
fn configuration(host: &str, port: u16) -> Configuration {
3031
Configuration {
@@ -77,7 +78,7 @@ async fn integration_trino_rest() {
7778
.await
7879
.unwrap();
7980

80-
localstack
81+
let command = localstack
8182
.exec(ExecCommand::new(vec![
8283
"awslocal",
8384
"s3api",
@@ -88,6 +89,10 @@ async fn integration_trino_rest() {
8889
.await
8990
.unwrap();
9091

92+
while command.exit_code().await.unwrap().is_none() {
93+
sleep(Duration::from_millis(100)).await;
94+
}
95+
9196
let localstack_host = localstack.get_host().await.unwrap();
9297
let localstack_port = localstack.get_host_port_ipv4(4566).await.unwrap();
9398

0 commit comments

Comments
 (0)