From e79d89c4bf4ce8c2b8d0f6a3e74efa0306af5e06 Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Fri, 15 Sep 2023 09:33:32 +0800 Subject: [PATCH 1/6] Add a new test case for the disk is full --- Cargo.lock | 4 ++++ Cargo.toml | 1 + core/tests/fs_write_full_disk/Cargo.toml | 5 ++++ core/tests/fs_write_full_disk/src/main.rs | 29 +++++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 core/tests/fs_write_full_disk/Cargo.toml create mode 100644 core/tests/fs_write_full_disk/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 6cf5fc04df6..34149cf09db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1850,6 +1850,10 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs_write_full_disk" +version = "0.1.0" + [[package]] name = "futures" version = "0.3.28" diff --git a/Cargo.toml b/Cargo.toml index 5bc5b746e6d..cdbb468aaab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ exclude = ["examples"] members = [ "core", "core/fuzz", + "core/tests/fs_write_full_disk", "bindings/c", "bindings/nodejs", diff --git a/core/tests/fs_write_full_disk/Cargo.toml b/core/tests/fs_write_full_disk/Cargo.toml new file mode 100644 index 00000000000..a91442db49c --- /dev/null +++ b/core/tests/fs_write_full_disk/Cargo.toml @@ -0,0 +1,5 @@ +[package] +name = "fs_write_full_disk" +version = "0.1.0" + +[dependencies] diff --git a/core/tests/fs_write_full_disk/src/main.rs b/core/tests/fs_write_full_disk/src/main.rs new file mode 100644 index 00000000000..79f2a23f9e6 --- /dev/null +++ b/core/tests/fs_write_full_disk/src/main.rs @@ -0,0 +1,29 @@ +use std::process::Command; +use std::io::Result; + + +#[test] +fn test_fs_write_full_disk() -> Result<()> { + // 执行命令 + Command::new("fallocate") + .args(&["-l", "512K", "disk.img"]) + .output()?; + Command::new("mkfs") + .arg("disk.img") + .output()?; + Command::new("mkdir") + .arg("./td") + .output()?; + Command::new("sudo") + .args(&["mount", "-o", "loop", "disk.img", "./td"]) + .output()?; + Command::new("chmod") + .arg("a+wr") + .arg("./td") + .output()?; + + // 可以添加更多断言 + // ... + + Ok(()) +} From 4c6ad219c336577bbb854cd1b5db52c38438e161 Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Fri, 15 Sep 2023 10:05:28 +0800 Subject: [PATCH 2/6] Revert "Add a new test case for the disk is full" This reverts commit e79d89c4bf4ce8c2b8d0f6a3e74efa0306af5e06. --- Cargo.lock | 4 ---- Cargo.toml | 1 - core/tests/fs_write_full_disk/Cargo.toml | 5 ---- core/tests/fs_write_full_disk/src/main.rs | 29 ----------------------- 4 files changed, 39 deletions(-) delete mode 100644 core/tests/fs_write_full_disk/Cargo.toml delete mode 100644 core/tests/fs_write_full_disk/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index 34149cf09db..6cf5fc04df6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1850,10 +1850,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs_write_full_disk" -version = "0.1.0" - [[package]] name = "futures" version = "0.3.28" diff --git a/Cargo.toml b/Cargo.toml index cdbb468aaab..5bc5b746e6d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ exclude = ["examples"] members = [ "core", "core/fuzz", - "core/tests/fs_write_full_disk", "bindings/c", "bindings/nodejs", diff --git a/core/tests/fs_write_full_disk/Cargo.toml b/core/tests/fs_write_full_disk/Cargo.toml deleted file mode 100644 index a91442db49c..00000000000 --- a/core/tests/fs_write_full_disk/Cargo.toml +++ /dev/null @@ -1,5 +0,0 @@ -[package] -name = "fs_write_full_disk" -version = "0.1.0" - -[dependencies] diff --git a/core/tests/fs_write_full_disk/src/main.rs b/core/tests/fs_write_full_disk/src/main.rs deleted file mode 100644 index 79f2a23f9e6..00000000000 --- a/core/tests/fs_write_full_disk/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -use std::process::Command; -use std::io::Result; - - -#[test] -fn test_fs_write_full_disk() -> Result<()> { - // 执行命令 - Command::new("fallocate") - .args(&["-l", "512K", "disk.img"]) - .output()?; - Command::new("mkfs") - .arg("disk.img") - .output()?; - Command::new("mkdir") - .arg("./td") - .output()?; - Command::new("sudo") - .args(&["mount", "-o", "loop", "disk.img", "./td"]) - .output()?; - Command::new("chmod") - .arg("a+wr") - .arg("./td") - .output()?; - - // 可以添加更多断言 - // ... - - Ok(()) -} From 7c76ab95b27f33318804144c9aecbdc711fdfa34 Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Fri, 15 Sep 2023 10:09:39 +0800 Subject: [PATCH 3/6] Add a new test case for the disk is full# github action --- .github/workflows/fs_write_full_disk.yml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/fs_write_full_disk.yml diff --git a/.github/workflows/fs_write_full_disk.yml b/.github/workflows/fs_write_full_disk.yml new file mode 100644 index 00000000000..f2a577f9d00 --- /dev/null +++ b/.github/workflows/fs_write_full_disk.yml @@ -0,0 +1,35 @@ +name: Fs write full disk + +on: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Create disk image + run: | + fallocate -l 512K disk.img + mkfs disk.img + + - name: Mount disk image + run: | + mkdir ./td + sudo mount -o loop disk.img ./td + + - name: Set permissions + run: chmod a+wr ./td + + # Add more steps for testing as needed + + - name: Clean up + run: | + sudo umount ./td + rm -rf ./td + rm disk.img From 88043915e16c3e0bc267edd7a10880457de08ecc Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Thu, 12 Oct 2023 11:33:04 +0800 Subject: [PATCH 4/6] add rust test code --- core/tests/behavior/file_write_full_disk.rs | 8 ++++++++ core/tests/behavior/main.rs | 1 + 2 files changed, 9 insertions(+) create mode 100644 core/tests/behavior/file_write_full_disk.rs diff --git a/core/tests/behavior/file_write_full_disk.rs b/core/tests/behavior/file_write_full_disk.rs new file mode 100644 index 00000000000..52919fc5b57 --- /dev/null +++ b/core/tests/behavior/file_write_full_disk.rs @@ -0,0 +1,8 @@ +#[cfg(test)] +mod tests { + #[tokio::test] + async fn test_file_write_on_full_disk() { + let data = [96u8; 1024 * 512]; // The writable was smaller than 512KB + op.write("/test", data.to_vec()).await.unwrap(); + } +} diff --git a/core/tests/behavior/main.rs b/core/tests/behavior/main.rs index bc7678407a4..1bc99da0ba4 100644 --- a/core/tests/behavior/main.rs +++ b/core/tests/behavior/main.rs @@ -47,6 +47,7 @@ mod blocking_list; mod blocking_read_only; mod blocking_rename; mod blocking_write; +mod file_write_full_disk; use blocking_copy::behavior_blocking_copy_tests; use blocking_list::behavior_blocking_list_tests; From d8de793385909f83574c08c780721e4aae3014d7 Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Fri, 13 Oct 2023 15:39:02 +0800 Subject: [PATCH 5/6] add ASF License --- core/tests/behavior/file_write_full_disk.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/tests/behavior/file_write_full_disk.rs b/core/tests/behavior/file_write_full_disk.rs index 52919fc5b57..0198af25a8e 100644 --- a/core/tests/behavior/file_write_full_disk.rs +++ b/core/tests/behavior/file_write_full_disk.rs @@ -1,3 +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. + #[cfg(test)] mod tests { #[tokio::test] From f932e9bedcff969bd08dece09717558b51942760 Mon Sep 17 00:00:00 2001 From: sunheyi <1061867552@qq.com> Date: Fri, 13 Oct 2023 15:46:33 +0800 Subject: [PATCH 6/6] add ASF License --- .github/workflows/fs_write_full_disk.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/fs_write_full_disk.yml b/.github/workflows/fs_write_full_disk.yml index f2a577f9d00..862657d497d 100644 --- a/.github/workflows/fs_write_full_disk.yml +++ b/.github/workflows/fs_write_full_disk.yml @@ -1,3 +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. + name: Fs write full disk on: