You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2023/10/30 03:55:21 UTC

(incubator-opendal) 01/01: chore(test): Compare with digest instead of whole content

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

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

commit a6a26c145b27c0cae27518198fa4897ed6e8cc03
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Mon Oct 30 11:54:50 2023 +0800

    chore(test): Compare with digest instead of whole content
    
    Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
 .github/workflows/ci.yml               | 14 ++++++++------
 core/tests/behavior/blocking_copy.rs   | 16 +++++++++++++---
 core/tests/behavior/blocking_rename.rs | 16 +++++++++++++---
 core/tests/behavior/copy.rs            | 21 +++++++++++++++++----
 core/tests/behavior/rename.rs          | 16 +++++++++++++---
 5 files changed, 64 insertions(+), 19 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2f00b6fdc..134d759e7 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -63,6 +63,7 @@ jobs:
         with:
           need-rocksdb: true
           need-protoc: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Checkout python env
         uses: actions/setup-python@v4
@@ -91,6 +92,7 @@ jobs:
         with:
           need-rocksdb: true
           need-protoc: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Checkout python env
         uses: actions/setup-python@v4
@@ -140,6 +142,8 @@ jobs:
       - uses: actions/checkout@v4
       - name: Setup Rust toolchain
         uses: ./.github/actions/setup
+        with:
+          github-token: ${{ secrets.GITHUB_TOKEN }}
       - name: Build
         run: cargo build -p opendal -p oli -p object_store_opendal
 
@@ -162,6 +166,7 @@ jobs:
         with:
           need-rocksdb: true
           need-protoc: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Build
         run: cargo build --all-features
@@ -190,12 +195,8 @@ jobs:
         uses: ./.github/actions/setup
         with:
           need-rocksdb: true
-
-      - name: Install Protoc
-        uses: arduino/setup-protoc@v2
-        with:
-          version: "23.4"
-          repo-token: ${{ secrets.GITHUB_TOKEN }}
+          need-protoc: true
+          github-token: ${{ secrets.GITHUB_TOKEN }}
 
       - name: Build
         shell: bash
@@ -267,6 +268,7 @@ jobs:
         uses: ./.github/actions/setup
         with:
           need-nextest: true
+
       - name: Test
         run: cargo nextest run --no-fail-fast --features layers-all && cargo test --doc
         env:
diff --git a/core/tests/behavior/blocking_copy.rs b/core/tests/behavior/blocking_copy.rs
index 163c55990..6a6165f26 100644
--- a/core/tests/behavior/blocking_copy.rs
+++ b/core/tests/behavior/blocking_copy.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -50,7 +51,10 @@ pub fn test_blocking_copy_file(op: BlockingOperator) -> Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -137,7 +141,10 @@ pub fn test_blocking_copy_nested(op: BlockingOperator) -> Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -160,7 +167,10 @@ pub fn test_blocking_copy_overwrite(op: BlockingOperator) -> Result<()> {
     op.copy(&source_path, &target_path)?;
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
diff --git a/core/tests/behavior/blocking_rename.rs b/core/tests/behavior/blocking_rename.rs
index 602d59399..f61f9401e 100644
--- a/core/tests/behavior/blocking_rename.rs
+++ b/core/tests/behavior/blocking_rename.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -53,7 +54,10 @@ pub fn test_blocking_rename_file(op: BlockingOperator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -143,7 +147,10 @@ pub fn test_blocking_rename_nested(op: BlockingOperator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
@@ -169,7 +176,10 @@ pub fn test_blocking_rename_overwrite(op: BlockingOperator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).expect("delete must succeed");
     op.delete(&target_path).expect("delete must succeed");
diff --git a/core/tests/behavior/copy.rs b/core/tests/behavior/copy.rs
index bd19a9c38..f5fffd094 100644
--- a/core/tests/behavior/copy.rs
+++ b/core/tests/behavior/copy.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -51,7 +52,10 @@ pub async fn test_copy_file_with_ascii_name(op: Operator) -> Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -68,7 +72,10 @@ pub async fn test_copy_file_with_non_ascii_name(op: Operator) -> Result<()> {
     op.copy(source_path, target_path).await?;
 
     let target_content = op.read(target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(source_path).await.expect("delete must succeed");
     op.delete(target_path).await.expect("delete must succeed");
@@ -159,7 +166,10 @@ pub async fn test_copy_nested(op: Operator) -> Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -182,7 +192,10 @@ pub async fn test_copy_overwrite(op: Operator) -> Result<()> {
     op.copy(&source_path, &target_path).await?;
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
diff --git a/core/tests/behavior/rename.rs b/core/tests/behavior/rename.rs
index 2dc3c1df0..29dd3de6a 100644
--- a/core/tests/behavior/rename.rs
+++ b/core/tests/behavior/rename.rs
@@ -16,6 +16,7 @@
 // under the License.
 
 use anyhow::Result;
+use sha2::{Digest, Sha256};
 
 use crate::*;
 
@@ -53,7 +54,10 @@ pub async fn test_rename_file(op: Operator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -147,7 +151,10 @@ pub async fn test_rename_nested(op: Operator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");
@@ -173,7 +180,10 @@ pub async fn test_rename_overwrite(op: Operator) -> Result<()> {
     assert_eq!(err.kind(), ErrorKind::NotFound);
 
     let target_content = op.read(&target_path).await.expect("read must succeed");
-    assert_eq!(target_content, source_content);
+    assert_eq!(
+        format!("{:x}", Sha256::digest(target_content)),
+        format!("{:x}", Sha256::digest(&source_content)),
+    );
 
     op.delete(&source_path).await.expect("delete must succeed");
     op.delete(&target_path).await.expect("delete must succeed");