Skip to content

Commit

Permalink
chore: rust integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ion-elgreco committed Jan 8, 2025
1 parent a65f72c commit 7d10625
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 8 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,40 @@ jobs:
- name: Run tests with native-tls
run: |
cargo test --no-default-features --features integration_test,s3-native-tls,datafusion
integration_test_lakefs:
name: Integration Tests (LakeFS v1.48)
runs-on: ubuntu-latest
env:
CARGO_INCREMENTAL: 0
# Disable full debug symbol generation to speed up CI build and keep memory down
# <https://doc.rust-lang.org/cargo/reference/profiles.html>
RUSTFLAGS: "-C debuginfo=line-tables-only"
# https://github.com/rust-lang/cargo/issues/10280
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
RUST_BACKTRACE: "1"
RUST_LOG: debug

steps:
- uses: actions/checkout@v3

- name: Install minimal stable with clippy and rustfmt
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: '1.81'
override: true

- name: Download Lakectl
run: |
wget -q https://github.com/treeverse/lakeFS/releases/download/v1.48.0/lakeFS_1.48.0_Linux_x86_64.tar.gz
tar -xf lakeFS_1.48.0_Linux_x86_64.tar.gz -C $GITHUB_WORKSPACE
echo "$GITHUB_WORKSPACE/lakectl" >> $GITHUB_PATH
- name: Start emulated services
run: docker compose -f docker-compose-lakefs.yml up -d

- name: Run tests with rustls (default)
run: |
cargo test --features integration_test,lakefs,datafusion
1 change: 1 addition & 0 deletions crates/lakefs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ serial_test = "3"
deltalake-test = { path = "../test" }
pretty_env_logger = "0.5.0"
rand = "0.8"
which = "7"


[features]
Expand Down
45 changes: 37 additions & 8 deletions crates/lakefs/tests/context.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// #![cfg(feature = "integration_test")]
use deltalake_lakefs::register_handlers;
use deltalake_test::utils::*;
use std::{
collections::HashSet,
process::{Command, ExitStatus},
};
use std::process::{Command, ExitStatus};

use which::which;

Expand All @@ -25,21 +22,53 @@ impl StorageIntegration for LakeFSIntegration {
set_env_if_not_set("access_key_id", "LAKEFSID");
set_env_if_not_set("secret_access_key", "LAKEFSKEY");
set_env_if_not_set("allow_http", "true");

set_env_if_not_set("LAKECTL_CREDENTIALS_ACCESS_KEY_ID", "LAKEFSID");
set_env_if_not_set("LAKECTL_CREDENTIALS_SECRET_ACCESS_KEY", "LAKEFSKEY");
set_env_if_not_set("LAKECTL_SERVER_ENDPOINT_URL", "http://127.0.0.1:8000");
}

fn create_bucket(&self) -> std::io::Result<ExitStatus> {
Ok(())
// Bucket is already created in docker-compose
Ok(ExitStatus::default())
}

fn bucket_name(&self) -> String {
"bronze"
"bronze".to_string()
}

fn root_uri(&self) -> String {
// Default branch is always main
format!("lakefs://{}/main", self.bucket_name())
}

fn copy_directory(&self, source: &str, destination: &str) -> std::io::Result<ExitStatus> {

println!(
"Copy directory called with {} {}",
source,
&format!("{}/{}", self.root_uri(), destination)
);
let lakectl = which("lakectl").expect("Failed to find lakectl executable");

// Upload files to branch
Command::new(lakectl.clone())
.args([
"fs",
"upload",
"-r",
"--source",
&format!("{}/", source),
&format!("{}/{}/", self.root_uri(), destination),
])
.status()?;

// Commit changes
Command::new(lakectl)
.args([
"commit",
&format!("{}/", self.root_uri()),
"--allow-empty-message",
])
.status()
}
}
}
16 changes: 16 additions & 0 deletions crates/lakefs/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// #![cfg(feature = "integration_test")]
use deltalake_test::{test_read_tables, IntegrationContext, TestResult};
use serial_test::serial;

mod context;
use context::*;
//
#[tokio::test]
#[serial]
async fn test_read_tables_lakefs() -> TestResult {
let context = IntegrationContext::new(Box::<LakeFSIntegration>::default())?;

test_read_tables(&context).await?;

Ok(())
}

0 comments on commit 7d10625

Please sign in to comment.