|
19 | 19 |
|
20 | 20 | use crate::config::TestConfigBuilder; |
21 | 21 | use assert_cmd::Command; |
| 22 | +use object_store::{aws::AmazonS3Builder, path::Path, ObjectStore}; |
22 | 23 |
|
23 | 24 | #[test] |
24 | 25 | fn test_custom_config() { |
@@ -50,3 +51,55 @@ fn test_custom_config() { |
50 | 51 | assert!(metadata.len() > 1000); |
51 | 52 | }) |
52 | 53 | } |
| 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