You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2021/10/25 03:36:07 UTC

[rocketmq-client-cpp] branch main updated: Optimize SchedulerTest

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

lizhanhui pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new 8f45618  Optimize SchedulerTest
8f45618 is described below

commit 8f45618660c8b2f44883165c376c8c8ea6bb8cdd
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Mon Oct 25 11:35:58 2021 +0800

    Optimize SchedulerTest
---
 src/test/cpp/ut/scheduler/SchedulerTest.cpp | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/src/test/cpp/ut/scheduler/SchedulerTest.cpp b/src/test/cpp/ut/scheduler/SchedulerTest.cpp
index 87b2753..19a3dae 100644
--- a/src/test/cpp/ut/scheduler/SchedulerTest.cpp
+++ b/src/test/cpp/ut/scheduler/SchedulerTest.cpp
@@ -76,9 +76,9 @@ TEST_F(SchedulerTest, testCancel) {
   };
 
   std::uint32_t task_id =
-      scheduler->schedule(callback, "test-cancel", std::chrono::seconds(1), std::chrono::seconds(1));
+      scheduler->schedule(callback, "test-cancel", std::chrono::milliseconds(100), std::chrono::milliseconds(100));
   scheduler->cancel(task_id);
-  std::this_thread::sleep_for(std::chrono::seconds(2));
+  std::this_thread::sleep_for(std::chrono::milliseconds(200));
   ASSERT_EQ(0, callback_fire_count);
 }
 
@@ -93,9 +93,9 @@ TEST_F(SchedulerTest, testPeriodicShot) {
   };
 
   std::uintptr_t task_id =
-      scheduler->schedule(callback, "periodic-task", std::chrono::milliseconds(10), std::chrono::seconds(1));
+      scheduler->schedule(callback, "periodic-task", std::chrono::milliseconds(10), std::chrono::milliseconds(100));
   // Wait till callback is executed.
-  std::this_thread::sleep_for(std::chrono::seconds(5));
+  std::this_thread::sleep_for(std::chrono::milliseconds(600));
   ASSERT_TRUE(callback_fire_count >= 4);
   scheduler->cancel(task_id);
 }
@@ -145,13 +145,5 @@ TEST_F(SchedulerTest, testException) {
       cv.Wait(&mtx);
     }
   }
-
-  std::this_thread::sleep_for(std::chrono::seconds(3));
-}
-
-TEST(SchedulerLifeCycleTest, testLifeCycle) {
-  auto scheduler = std::make_shared<SchedulerImpl>();
-  scheduler->start();
 }
-
 ROCKETMQ_NAMESPACE_END
\ No newline at end of file