You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pegasus.apache.org by la...@apache.org on 2022/07/06 02:53:48 UTC

[incubator-pegasus] branch master updated: fix: fix flaky unit test (#1030)

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

laiyingchun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git


The following commit(s) were added to refs/heads/master by this push:
     new c7633c4ce fix: fix flaky unit test (#1030)
c7633c4ce is described below

commit c7633c4cecc07664eb8cb31e5776baf2063846fc
Author: Dan Wang <em...@126.com>
AuthorDate: Wed Jul 6 10:53:44 2022 +0800

    fix: fix flaky unit test (#1030)
---
 .github/workflows/lint_and_test_rdsn.yaml         | 24 +++++++++++------------
 rdsn/include/dsn/utility/metrics.h                |  9 ++++++++-
 rdsn/src/block_service/test/hdfs_service_test.cpp | 12 ------------
 rdsn/src/meta/meta_bulk_load_service.cpp          |  1 +
 rdsn/src/replica/test/mutation_log_test.cpp       |  1 +
 5 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/.github/workflows/lint_and_test_rdsn.yaml b/.github/workflows/lint_and_test_rdsn.yaml
index 25f491548..051449505 100644
--- a/.github/workflows/lint_and_test_rdsn.yaml
+++ b/.github/workflows/lint_and_test_rdsn.yaml
@@ -67,7 +67,7 @@ jobs:
   test:
     name: Test
     needs: lint
-    runs-on: self-hosted
+    runs-on: ubuntu-latest
     container:
       image: apache/pegasus:thirdparties-bin-ubuntu1804
       env:
@@ -99,18 +99,18 @@ jobs:
           cmake --build build/ -j $(($(nproc)/2+1))
       - name: Compilation
         working-directory: rdsn
-        run: ./run.sh build -c --skip_thirdparty
+        run: ./run.sh build -c --skip_thirdparty -j $(($(nproc)/2+1))
       - name: Unit Testing
         working-directory: rdsn
         run: |
           export LD_LIBRARY_PATH=`pwd`/thirdparty/output/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server          
           ulimit -s unlimited
-          ./run.sh test --skip_thirdparty
+          ./run.sh test --skip_thirdparty -j $(($(nproc)/2+1))
 
   test-with-sanitizer-address:
     name: Test With Sanitizer Address
     needs: lint
-    runs-on: self-hosted
+    runs-on: ubuntu-latest
     container:
       image: apache/pegasus:thirdparties-bin-ubuntu1804
       env:
@@ -142,18 +142,18 @@ jobs:
           cmake --build build/ -j $(($(nproc)/2+1))
       - name: Compilation
         working-directory: rdsn
-        run: ./run.sh build -c --sanitizer address --skip_thirdparty --disable_gperf
+        run: ./run.sh build -c --sanitizer address --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
       - name: Unit Testing
         working-directory: rdsn
         run: |
           export LD_LIBRARY_PATH=`pwd`/thirdparty/output/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server          
           ulimit -s unlimited
-          ./run.sh test --sanitizer address --skip_thirdparty --disable_gperf
+          ./run.sh test --sanitizer address --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
 
   test-with-sanitizer-leak:
     name: Test With Sanitizer Leak
     needs: lint
-    runs-on: self-hosted
+    runs-on: ubuntu-latest
     container:
       image: apache/pegasus:thirdparties-bin-ubuntu1804
       env:
@@ -185,18 +185,18 @@ jobs:
           cmake --build build/ -j $(($(nproc)/2+1))
       - name: Compilation
         working-directory: rdsn
-        run: ./run.sh build -c --sanitizer leak --skip_thirdparty --disable_gperf
+        run: ./run.sh build -c --sanitizer leak --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
       - name: Unit Testing
         working-directory: rdsn
         run: |
           export LD_LIBRARY_PATH=`pwd`/thirdparty/output/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server          
           ulimit -s unlimited
-          ./run.sh test --sanitizer leak --skip_thirdparty --disable_gperf
+          ./run.sh test --sanitizer leak --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
 
   test-with-sanitizer-undefined:
     name: Test With Sanitizer Undefined
     needs: lint
-    runs-on: self-hosted
+    runs-on: ubuntu-latest
     container:
       image: apache/pegasus:thirdparties-bin-ubuntu1804
       env:
@@ -228,10 +228,10 @@ jobs:
           cmake --build build/ -j $(($(nproc)/2+1))
       - name: Compilation
         working-directory: rdsn
-        run: ./run.sh build -c --sanitizer undefined --skip_thirdparty --disable_gperf
+        run: ./run.sh build -c --sanitizer undefined --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
       - name: Unit Testing
         working-directory: rdsn
         run: |
           export LD_LIBRARY_PATH=`pwd`/thirdparty/output/lib:/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/server          
           ulimit -s unlimited
-          ./run.sh test --sanitizer undefined --skip_thirdparty --disable_gperf
+          ./run.sh test --sanitizer undefined --skip_thirdparty --disable_gperf -j $(($(nproc)/2+1))
diff --git a/rdsn/include/dsn/utility/metrics.h b/rdsn/include/dsn/utility/metrics.h
index 095123393..72fff6285 100644
--- a/rdsn/include/dsn/utility/metrics.h
+++ b/rdsn/include/dsn/utility/metrics.h
@@ -544,6 +544,8 @@ public:
     percentile_timer(uint64_t interval_ms, exec_fn exec);
     ~percentile_timer() = default;
 
+    void cancel() { _timer->cancel(); }
+
     // Get the initial delay that is randomly generated by `generate_initial_delay_ms()`.
     uint64_t get_initial_delay_ms() const { return _initial_delay_ms; }
 
@@ -653,7 +655,12 @@ protected:
             std::bind(&percentile<value_type, NthElementFinder>::find_nth_elements, this)));
     }
 
-    virtual ~percentile() = default;
+    virtual ~percentile()
+    {
+        if (_timer) {
+            _timer->cancel();
+        }
+    }
 
 private:
     using nth_container_type = typename NthElementFinder::nth_container_type;
diff --git a/rdsn/src/block_service/test/hdfs_service_test.cpp b/rdsn/src/block_service/test/hdfs_service_test.cpp
index 565242d40..e54ad9a47 100644
--- a/rdsn/src/block_service/test/hdfs_service_test.cpp
+++ b/rdsn/src/block_service/test/hdfs_service_test.cpp
@@ -376,15 +376,3 @@ TEST_F(HDFSClientTest, test_rename_path_while_writing)
     ASSERT_TRUE(dsn::utils::filesystem::rename_path(local_test_dir, rename_dir));
     tracker.cancel_outstanding_tasks();
 }
-
-#ifndef SANITIZER
-TEST_F(HDFSClientTest, test_remove_path_while_writing)
-{
-    task_tracker tracker;
-    write_test_files_async(&tracker);
-    usleep(100);
-    // couldn't remove the directory while writing files in it.
-    ASSERT_FALSE(dsn::utils::filesystem::remove_path(local_test_dir));
-    tracker.cancel_outstanding_tasks();
-}
-#endif
diff --git a/rdsn/src/meta/meta_bulk_load_service.cpp b/rdsn/src/meta/meta_bulk_load_service.cpp
index 6bc9cedea..cc47ec206 100644
--- a/rdsn/src/meta/meta_bulk_load_service.cpp
+++ b/rdsn/src/meta/meta_bulk_load_service.cpp
@@ -1701,6 +1701,7 @@ void bulk_load_service::do_sync_partition(const gpid &pid, std::string &partitio
 void bulk_load_service::try_to_continue_bulk_load()
 {
     FAIL_POINT_INJECT_F("meta_try_to_continue_bulk_load", [](dsn::string_view) {});
+    zauto_read_lock l(_lock);
     for (const auto app_id : _bulk_load_app_id) {
         app_bulk_load_info ainfo = _app_bulk_load_info[app_id];
         // <partition_index, partition_bulk_load_info>
diff --git a/rdsn/src/replica/test/mutation_log_test.cpp b/rdsn/src/replica/test/mutation_log_test.cpp
index 6886662e9..2b04294b8 100644
--- a/rdsn/src/replica/test/mutation_log_test.cpp
+++ b/rdsn/src/replica/test/mutation_log_test.cpp
@@ -362,6 +362,7 @@ public:
                 mutations.push_back(mu);
                 mlog->append(mu, LPC_AIO_IMMEDIATE_CALLBACK, nullptr, nullptr, 0);
             }
+            mlog->tracker()->wait_outstanding_tasks();
         }
 
         { // replaying logs


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pegasus.apache.org
For additional commands, e-mail: commits-help@pegasus.apache.org