MCPcopy Create free account
hub / github.com/apache/datafusion / setup_minio_container

Function setup_minio_container

datafusion-cli/tests/cli_integration.rs:48–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

46}
47
48async 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,

Callers 4

test_cliFunction · 0.85
test_aws_optionsFunction · 0.85
test_s3_url_fallbackFunction · 0.85

Calls 3

newFunction · 0.85
joinMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…