You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2019/03/06 13:28:02 UTC

[rocketmq] branch develop updated: [RIP-10] modify test case StatsItemSetTest's param (#1053)

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

dinglei pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/develop by this push:
     new 690a406  [RIP-10] modify test case  StatsItemSetTest's param (#1053)
690a406 is described below

commit 690a406ec1a1d08abe6bfdaa95aff2c432d8d44d
Author: hdchen <14...@qq.com>
AuthorDate: Wed Mar 6 21:27:53 2019 +0800

    [RIP-10] modify test case  StatsItemSetTest's param (#1053)
---
 .../rocketmq/common/stats/StatsItemSetTest.java    | 24 +++++++++-------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java b/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java
index 6ac1c66..bd6550d 100644
--- a/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java
+++ b/common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java
@@ -36,23 +36,19 @@ public class StatsItemSetTest {
 
     @Test
     public void test_getAndCreateStatsItem_multiThread() throws InterruptedException {
-        for (int i = 0; i < 50; i++) {
-            assertEquals(20000L, test_unit().longValue());
-        }
+        assertEquals(20L, test_unit().longValue());
     }
 
     @Test
     public void test_getAndCreateMomentStatsItem_multiThread() throws InterruptedException {
-        for (int i = 0; i < 50; i++) {
-            assertEquals(10, test_unit_moment().longValue());
-        }
+        assertEquals(10, test_unit_moment().longValue());
     }
 
     private AtomicLong test_unit() throws InterruptedException {
         final StatsItemSet statsItemSet = new StatsItemSet("topicTest", scheduler, null);
-        executor = new ThreadPoolExecutor(100, 200, 10, TimeUnit.SECONDS,
-            new ArrayBlockingQueue<Runnable>(10000), new ThreadFactoryImpl("testMultiThread"));
-        for (int i = 0; i < 10000; i++) {
+        executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
+            new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
+        for (int i = 0; i < 10; i++) {
             executor.submit(new Runnable() {
                 @Override
                 public void run() {
@@ -61,7 +57,7 @@ public class StatsItemSetTest {
             });
         }
         while (true) {
-            if (executor.getCompletedTaskCount() == 10000) {
+            if (executor.getCompletedTaskCount() == 10) {
                 break;
             }
             Thread.sleep(1000);
@@ -71,9 +67,9 @@ public class StatsItemSetTest {
 
     private AtomicLong test_unit_moment() throws InterruptedException {
         final MomentStatsItemSet statsItemSet = new MomentStatsItemSet("topicTest", scheduler, null);
-        executor = new ThreadPoolExecutor(100, 200, 10, TimeUnit.SECONDS,
-            new ArrayBlockingQueue<Runnable>(10000), new ThreadFactoryImpl("testMultiThread"));
-        for (int i = 0; i < 10000; i++) {
+        executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
+            new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
+        for (int i = 0; i < 10; i++) {
             executor.submit(new Runnable() {
                 @Override
                 public void run() {
@@ -82,7 +78,7 @@ public class StatsItemSetTest {
             });
         }
         while (true) {
-            if (executor.getCompletedTaskCount() == 10000) {
+            if (executor.getCompletedTaskCount() == 10) {
                 break;
             }
             Thread.sleep(1000);