This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 652f223ee feat: Add edge test cases for OpenDAL Core (#3274)
652f223ee is described below

commit 652f223eea0f794514d18ead21f7aab6f5f9cac8
Author: Xuanwo <[email protected]>
AuthorDate: Fri Oct 13 16:51:08 2023 +0800

    feat: Add edge test cases for OpenDAL Core (#3274)
    
    * feat: Add edge test cases for OpenDAL Core
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix typo
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Fix license
    
    Signed-off-by: Xuanwo <[email protected]>
    
    * Use checkout v4
    
    Signed-off-by: Xuanwo <[email protected]>
    
    ---------
    
    Signed-off-by: Xuanwo <[email protected]>
---
 .../{fs_write_full_disk.yml => edge_test.yml}      | 32 +++++++++------
 Cargo.lock                                         | 10 +++++
 Cargo.toml                                         |  1 +
 core/edge/README.md                                |  3 ++
 .../edge/file_write_on_full_disk/Cargo.toml        | 46 ++++++----------------
 core/edge/file_write_on_full_disk/README.md        | 14 +++++++
 core/edge/file_write_on_full_disk/src/main.rs      | 42 ++++++++++++++++++++
 7 files changed, 101 insertions(+), 47 deletions(-)

diff --git a/.github/workflows/fs_write_full_disk.yml 
b/.github/workflows/edge_test.yml
similarity index 65%
copy from .github/workflows/fs_write_full_disk.yml
copy to .github/workflows/edge_test.yml
index 862657d49..1d89afccb 100644
--- a/.github/workflows/fs_write_full_disk.yml
+++ b/.github/workflows/edge_test.yml
@@ -15,20 +15,29 @@
 # specific language governing permissions and limitations
 # under the License.
 
-name: Fs write full disk
+name: Edge Test
 
 on:
   push:
     branches:
       - main
+  pull_request:
+    branches:
+      - main
+    paths:
+      - "core/src/**"
+      - "!core/src/docs/**"
+      - "!core/src/services/**"
+      - "core/src/services/fs/**"
+      - ".github/workflows/edge_test.yml"
 
 jobs:
-  test:
+  test_file_write_on_full_disk:
     runs-on: ubuntu-latest
 
     steps:
       - name: Checkout code
-        uses: actions/checkout@v2
+        uses: actions/checkout@v4
 
       - name: Create disk image
         run: |
@@ -37,16 +46,15 @@ jobs:
 
       - name: Mount disk image
         run: |
-          mkdir ./td
-          sudo mount -o loop disk.img ./td
+          mkdir /tmp/test_dir
+          sudo mount -o loop disk.img /tmp/test_dir
 
       - name: Set permissions
-        run: chmod a+wr ./td
+        run: sudo chmod a+wr /tmp/test_dir
 
-      # Add more steps for testing as needed
+      - name: Test
+        working-directory: core/edge/file_write_on_full_disk
+        run: cargo run
+        env:
+          OPENDAL_FS_ROOT: /tmp/test_dir
 
-      - name: Clean up
-        run: |
-          sudo umount ./td
-          rm -rf ./td
-          rm disk.img
diff --git a/Cargo.lock b/Cargo.lock
index d5f269a7b..d1a0bcc01 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1771,6 +1771,16 @@ version = "1.0.9"
 source = "registry+https://github.com/rust-lang/crates.io-index";
 checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653"
 
+[[package]]
+name = "edge_test_file_write_on_full_disk"
+version = "0.0.0"
+dependencies = [
+ "futures",
+ "opendal",
+ "rand 0.8.5",
+ "tokio",
+]
+
 [[package]]
 name = "either"
 version = "1.8.1"
diff --git a/Cargo.toml b/Cargo.toml
index 062126880..1d83e191b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,7 @@ exclude = ["examples"]
 members = [
   "core",
   "core/fuzz",
+  "core/edge/*",
 
   "bindings/c",
   "bindings/nodejs",
diff --git a/core/edge/README.md b/core/edge/README.md
new file mode 100644
index 000000000..44c59f06e
--- /dev/null
+++ b/core/edge/README.md
@@ -0,0 +1,3 @@
+# OpenDAL Edge Tests
+
+OpenDAL edge tests served as edge tests for the OpenDAL project. They will 
have pre-set data and will test the functionality of the OpenDAL project.
diff --git a/.github/workflows/fs_write_full_disk.yml 
b/core/edge/file_write_on_full_disk/Cargo.toml
similarity index 56%
rename from .github/workflows/fs_write_full_disk.yml
rename to core/edge/file_write_on_full_disk/Cargo.toml
index 862657d49..aefee22d4 100644
--- a/.github/workflows/fs_write_full_disk.yml
+++ b/core/edge/file_write_on_full_disk/Cargo.toml
@@ -15,38 +15,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
-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
+[package]
+name = "edge_test_file_write_on_full_disk"
+edition = "2021"
+version = "0.0.0"
+publish = false
+
+[dependencies]
+futures = "0.3"
+opendal = { workspace = true }
+tokio = { version = "1", features = ["full"] }
+rand = "0.8"
diff --git a/core/edge/file_write_on_full_disk/README.md 
b/core/edge/file_write_on_full_disk/README.md
new file mode 100644
index 000000000..682057da6
--- /dev/null
+++ b/core/edge/file_write_on_full_disk/README.md
@@ -0,0 +1,14 @@
+# File Write on Fill Disk
+
+Reported by [The `FsBackend` only writes partial bytes and doesn't raise any 
errors](https://github.com/apache/incubator-opendal/issues/3052).
+
+Setup:
+
+```shell
+fallocate -l 512K disk.img 
+mkfs disk.img 
+mkdir ./td
+sudo mount -o loop td.img ./td
+chmod a+wr ./td
+```
+
diff --git a/core/edge/file_write_on_full_disk/src/main.rs 
b/core/edge/file_write_on_full_disk/src/main.rs
new file mode 100644
index 000000000..63cfe6cf0
--- /dev/null
+++ b/core/edge/file_write_on_full_disk/src/main.rs
@@ -0,0 +1,42 @@
+// 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 opendal::services::Fs;
+use opendal::Operator;
+use opendal::Result;
+use rand::prelude::*;
+use std::env;
+
+#[tokio::main]
+async fn main() -> Result<()> {
+    let mut builder = Fs::default();
+    builder.root(&env::var("OPENDAL_FS_ROOT").expect("root must be set for 
this test"));
+    let op = Operator::new(builder)?.finish();
+
+    let size = thread_rng().gen_range(512 * 1024 + 1..4 * 1024 * 1024);
+    let mut bs = vec![0; size];
+    thread_rng().fill_bytes(&mut bs);
+
+    let result = op.write("/test", bs).await;
+    // Write file with size > 512KB should fail
+    assert!(
+        result.is_err(),
+        "write file on full disk should return error"
+    );
+
+    Ok(())
+}

Reply via email to