()
| 46 | } |
| 47 | |
| 48 | async fn setup_minio_container() -> Result<ContainerAsync<minio::MinIO>, String> { |
| 49 | const MINIO_ROOT_USER: &str = "TEST-DataFusionLogin"; |
| 50 | const MINIO_ROOT_PASSWORD: &str = "TEST-DataFusionPassword"; |
| 51 | |
| 52 | let data_path = |
| 53 | PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../datafusion/core/tests/data"); |
| 54 | |
| 55 | let absolute_data_path = data_path |
| 56 | .canonicalize() |
| 57 | .expect("Failed to get absolute path for test data"); |
| 58 | |
| 59 | let container = minio::MinIO::default() |
| 60 | .with_env_var("MINIO_ROOT_USER", MINIO_ROOT_USER) |
| 61 | .with_env_var("MINIO_ROOT_PASSWORD", MINIO_ROOT_PASSWORD) |
| 62 | .with_mount(Mount::bind_mount( |
| 63 | absolute_data_path.to_str().unwrap(), |
| 64 | "/source", |
| 65 | )) |
| 66 | .start() |
| 67 | .await; |
| 68 | |
| 69 | match container { |
| 70 | Ok(container) => { |
| 71 | // We wait for MinIO to be healthy and prepare test files. We do it via CLI to avoid s3 dependency |
| 72 | let commands = [ |
| 73 | ExecCommand::new(["/usr/bin/mc", "ready", "local"]), |
| 74 | ExecCommand::new([ |
| 75 | "/usr/bin/mc", |
| 76 | "alias", |
| 77 | "set", |
| 78 | "localminio", |
| 79 | "http://localhost:9000", |
| 80 | MINIO_ROOT_USER, |
| 81 | MINIO_ROOT_PASSWORD, |
| 82 | ]), |
| 83 | ExecCommand::new(["/usr/bin/mc", "mb", "localminio/data"]), |
| 84 | ExecCommand::new([ |
| 85 | "/usr/bin/mc", |
| 86 | "cp", |
| 87 | "-r", |
| 88 | "/source/", |
| 89 | "localminio/data/", |
| 90 | ]), |
| 91 | ]; |
| 92 | |
| 93 | for command in commands { |
| 94 | let command = |
| 95 | command.with_cmd_ready_condition(CmdWaitFor::Exit { code: Some(0) }); |
| 96 | |
| 97 | let cmd_ref = format!("{command:?}"); |
| 98 | |
| 99 | if let Err(e) = container.exec(command).await { |
| 100 | let stdout = container.stdout_to_vec().await.unwrap_or_default(); |
| 101 | let stderr = container.stderr_to_vec().await.unwrap_or_default(); |
| 102 | |
| 103 | return Err(format!( |
| 104 | "Failed to execute command: {}\nError: {}\nStdout: {:?}\nStderr: {:?}", |
| 105 | cmd_ref, |
no test coverage detected
searching dependent graphs…