diff --git a/build.gradle.kts b/build.gradle.kts index 100b243b54d..1cfaf99b64e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -546,7 +546,8 @@ tasks.rat { "clients/client-python/tests/unittests/htmlcov/*", "clients/client-python/tests/integration/htmlcov/*", "clients/client-python/docs/build", - "clients/client-python/docs/source/generated" + "clients/client-python/docs/source/generated", + "clients/filesystem-fuse/Cargo.lock" ) // Add .gitignore excludes to the Apache Rat exclusion list. diff --git a/clients/filesystem-fuse/.cargo/config.toml b/clients/filesystem-fuse/.cargo/config.toml new file mode 100644 index 00000000000..37751e880c3 --- /dev/null +++ b/clients/filesystem-fuse/.cargo/config.toml @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[build] +target-dir = "build" + diff --git a/clients/filesystem-fuse/.gitignore b/clients/filesystem-fuse/.gitignore new file mode 100644 index 00000000000..5a44eef09a5 --- /dev/null +++ b/clients/filesystem-fuse/.gitignore @@ -0,0 +1 @@ +/Cargo.lock diff --git a/clients/filesystem-fuse/Cargo.toml b/clients/filesystem-fuse/Cargo.toml new file mode 100644 index 00000000000..1b186d61cb1 --- /dev/null +++ b/clients/filesystem-fuse/Cargo.toml @@ -0,0 +1,37 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[package] +name = "filesystem-fuse" +version = "0.8.0-incubating-SNAPSHOT" +rust-version = "1.75" +edition = "2021" + +homepage = "https://gravitino.apache.org" +license = "Apache-2.0" +repository = "https://github.com/apache/gravitino" + +[[bin]] +name = "gvfs-fuse" +path = "src/main.rs" + +[dependencies] +futures-util = "0.3.30" +libc = "0.2.164" +log = "0.4.22" +tokio = { version = "1.38.0", features = ["full"] } +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } \ No newline at end of file diff --git a/clients/filesystem-fuse/build.gradle.kts b/clients/filesystem-fuse/build.gradle.kts new file mode 100644 index 00000000000..08693ddc5bd --- /dev/null +++ b/clients/filesystem-fuse/build.gradle.kts @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.gradle.api.tasks.Exec + +val checkRustEnvironment by tasks.registering(Exec::class) { + description = "Check if Rust environment." + group = "verification" + commandLine("bash", "-c", "cargo --version") + standardOutput = System.out + errorOutput = System.err + isIgnoreExitValue = false +} + +val buildRustProject by tasks.registering(Exec::class) { + dependsOn(checkRustEnvironment) + description = "Compile the Rust project" + workingDir = file("$projectDir") + commandLine("bash", "-c", "cargo build --release") +} + +val checkRustProject by tasks.registering(Exec::class) { + dependsOn(checkRustEnvironment) + description = "Check the Rust project" + workingDir = file("$projectDir") + + commandLine( + "bash", + "-c", + """ + set -e + echo "Checking the code format" + cargo fmt --all -- --check + + echo "Running clippy" + cargo clippy --all-targets --all-features --workspace -- -D warnings + """.trimIndent() + ) +} + +val testRustProject by tasks.registering(Exec::class) { + dependsOn(checkRustEnvironment) + description = "Run tests in the Rust project" + group = "verification" + workingDir = file("$projectDir") + commandLine("bash", "-c", "cargo test --release") + + standardOutput = System.out + errorOutput = System.err +} + +tasks.named("testRustProject") { + mustRunAfter("checkRustProject") +} +tasks.named("buildRustProject") { + mustRunAfter("testRustProject") +} + +tasks.named("build") { + dependsOn(testRustProject) + dependsOn(buildRustProject) +} + +tasks.named("check") { + dependsOn.clear() + dependsOn(checkRustProject) +} + +tasks.named("test") { + dependsOn(testRustProject) +} diff --git a/clients/filesystem-fuse/check_rust_env.sh b/clients/filesystem-fuse/check_rust_env.sh new file mode 100755 index 00000000000..aef8e165cd8 --- /dev/null +++ b/clients/filesystem-fuse/check_rust_env.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -e + +if ! command -v cargo &> /dev/null; then + echo "Rust is not installed. Installing Rust..." + + if command -v curl &> /dev/null; then + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + elif command -v wget &> /dev/null; then + wget -qO- https://sh.rustup.rs | sh -s -- -y + else + echo "Error: Neither curl nor wget is available. Please install one of them to proceed." + exit 1 + fi + + export PATH="$HOME/.cargo/bin:$PATH" + if command -v cargo &> /dev/null; then + echo "Rust has been installed successfully." + else + echo "Error: Rust installation failed. Please check your setup." + exit 1 + fi +else + echo "Rust is already installed: $(cargo --version)" +fi diff --git a/clients/filesystem-fuse/src/main.rs b/clients/filesystem-fuse/src/main.rs new file mode 100644 index 00000000000..48b6ab5517e --- /dev/null +++ b/clients/filesystem-fuse/src/main.rs @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +use log::debug; +use log::info; +use std::process::exit; + +#[tokio::main] +async fn main() { + tracing_subscriber::fmt().with_env_filter("debug").init(); + info!("Starting filesystem..."); + debug!("Shutdown filesystem..."); + exit(0); +} diff --git a/clients/filesystem-fuse/tests/it.rs b/clients/filesystem-fuse/tests/it.rs new file mode 100644 index 00000000000..989e5f9895e --- /dev/null +++ b/clients/filesystem-fuse/tests/it.rs @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +#[test] +fn test_math_add() { + assert_eq!(1, 1); +} diff --git a/gradle.properties b/gradle.properties index a5ada8fc5e5..cc1b9393018 100644 --- a/gradle.properties +++ b/gradle.properties @@ -41,3 +41,6 @@ pythonVersion = 3.8 # skipDockerTests is used to skip the tests that require Docker to be running. skipDockerTests = true + +# enableFuse is used to enable the fuse module in the build. +enableFuse = false diff --git a/settings.gradle.kts b/settings.gradle.kts index 2cde39c222b..a36fde93cd3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -49,6 +49,11 @@ include( "clients:client-python", "clients:cli" ) +if (gradle.startParameter.projectProperties["enableFuse"]?.toBoolean() ?: false) { + include("clients:filesystem-fuse") +} else { + println("Skipping filesystem-fuse module since enableFuse is set to false") +} include("iceberg:iceberg-common") include("iceberg:iceberg-rest-server") include("authorizations:authorization-ranger")