Skip to content

Commit 63a6a63

Browse files
Test for s3
1 parent 33cc8f1 commit 63a6a63

5 files changed

Lines changed: 84 additions & 2 deletions

File tree

.github/actions/setup-rust/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ runs:
3737
shell: bash
3838
run: |
3939
cargo install taplo-cli --locked
40-
cargo install cargo-machete
40+
cargo install cargo-machete just

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,31 @@ jobs:
7272
# test to only be run against the server spun up in that test. With parallelism tests
7373
# can connec to server in different test which breaks determinism.
7474
cargo test --features=flightsql extension_cases::flightsql -- --test-threads=1
75+
test-cli:
76+
name: App / CLI
77+
runs-on: ubuntu-latest
78+
strategy:
79+
matrix:
80+
arch: [amd64]
81+
steps:
82+
- uses: actions/checkout@v3
83+
- name: Setup Rust Toolchain
84+
uses: ./.github/actions/setup-rust
85+
- name: Start LocalStack
86+
uses: LocalStack/setup-localstack@v0.2.3
87+
with:
88+
image-tag: 'latest'
89+
install-awslocal: 'true'
90+
configuration: DEBUG=1
91+
- name: Run Tests against LocalStack
92+
run: |
93+
awslocal s3 mb s3://test
94+
awslocal s3 mv data/aggregate_test_100.csv s3://test/
95+
awslocal s3 mb s3://tpch-db
96+
echo "Test Execution complete!"
97+
- name: Run CLI tests
98+
run: |
99+
cargo test cli_cases
75100
test-s3:
76101
name: Extension / S3
77102
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ url = "2.5.2"
8181

8282
# When addding a new feature, also add it to the features tested list in CI (`.github/workflows/rust.yml`)
8383
[features]
84-
default = ["functions-parquet"]
84+
default = ["functions-parquet", "s3"]
8585
deltalake = ["datafusion-app/deltalake"]
8686
flightsql = [
8787
"datafusion-app/flightsql",

justfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ bench-http-custom file:
3636
echo "Running bench on $custom_bench_path"
3737
echo ""
3838
oha --urls-from-file "$custom_bench_path"
39+
40+
setup-test-env:
41+
localstack start -d
42+
awslocal s3api create-bucket --bucket tmp --acl public-read

tests/cli_cases/tpch.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
2020
use crate::config::TestConfigBuilder;
2121
use assert_cmd::Command;
22+
use object_store::{aws::AmazonS3Builder, path::Path, ObjectStore};
2223

2324
#[test]
2425
fn test_custom_config() {
@@ -50,3 +51,55 @@ fn test_custom_config() {
5051
assert!(metadata.len() > 1000);
5152
})
5253
}
54+
55+
#[tokio::test]
56+
async fn test_custom_config_with_s3() {
57+
let mut config_builder = TestConfigBuilder::default();
58+
config_builder.with_db_path("s3://tpch-db/db/");
59+
let bucket = "tpch-db";
60+
let endpoint = "http://localhost:4566";
61+
let access_key = "LSIAQAAAAAAVNCBMPNSG";
62+
let secret = "5555555555555555555555555555555555555555";
63+
let allow_http = true;
64+
config_builder.with_s3_object_store(
65+
"cli",
66+
"s3",
67+
bucket,
68+
"s3://tpch-db",
69+
endpoint,
70+
access_key,
71+
secret,
72+
allow_http,
73+
);
74+
let config = config_builder.build("my_config.toml");
75+
76+
Command::cargo_bin("dft")
77+
.unwrap()
78+
.arg("--config")
79+
.arg(config.path)
80+
.arg("generate-tpch")
81+
.assert()
82+
.success();
83+
84+
let s3 = AmazonS3Builder::new()
85+
.with_bucket_name(bucket)
86+
.with_endpoint(endpoint)
87+
.with_access_key_id(access_key)
88+
.with_secret_access_key(secret)
89+
.with_allow_http(allow_http)
90+
.build()
91+
.unwrap();
92+
93+
let r = s3
94+
.list_with_delimiter(Some(&Path::parse("db/tables/dft/tpch/").unwrap()))
95+
.await
96+
.unwrap();
97+
98+
let needed_dirs = [
99+
"customer", "orders", "lineitem", "nation", "part", "partsupp", "region", "supplier",
100+
];
101+
102+
for prefix in r.common_prefixes {
103+
assert!(needed_dirs.contains(&prefix.to_string().as_str()));
104+
}
105+
}

0 commit comments

Comments
 (0)