diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 34678ae37..73720fe33 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -24,6 +24,27 @@ env: jobs: rust_ci: runs-on: ubuntu-latest + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres:14.5 + # Provide the password for postgres + env: + POSTGRES_PASSWORD: lakesoul_test + POSTGRES_USER: lakesoul_test + POSTGRES_DB: lakesoul_test + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + --name lakesoul-test-pg + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: - uses: actions/checkout@v3 - uses: actions-rs/toolchain@v1 diff --git a/rust/lakesoul-metadata/src/metadata_client.rs b/rust/lakesoul-metadata/src/metadata_client.rs index 792cc820c..73ce6e06c 100644 --- a/rust/lakesoul-metadata/src/metadata_client.rs +++ b/rust/lakesoul-metadata/src/metadata_client.rs @@ -26,15 +26,15 @@ impl MetaDataClient { let config_map = config.split('\n').filter_map(|property| { property.find('=').map(|idx| property.split_at(idx + 1)) }).collect::>(); - let url = Url::parse(&config_map.get("lakesoul.pg.url=").expect("")[5..]).unwrap(); + let url = Url::parse(&config_map.get("lakesoul.pg.url=").unwrap_or("jdbc:postgresql://127.0.0.1:5432/lakesoul_test?stringtype=unspecified")[5..]).unwrap(); Self::from_config( format!( "host={} port={} dbname={} user={} password={}", url.host_str().unwrap(), url.port().unwrap(), url.path_segments().unwrap().next().unwrap(), - config_map.get("lakesoul.pg.username=").unwrap(), - config_map.get("lakesoul.pg.password=").unwrap()) + config_map.get("lakesoul.pg.username=").unwrap_or("lakesoul_test"), + config_map.get("lakesoul.pg.password=").unwrap_or("lakesoul_test")) ) }