From 690a406ec1a1d08abe6bfdaa95aff2c432d8d44d Mon Sep 17 00:00:00 2001 From: hdchen <14106312@qq.com> Date: Wed, 6 Mar 2019 21:27:53 +0800 Subject: [PATCH] [RIP-10] modify test case StatsItemSetTest's param (#1053) --- .../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 6ac1c66a..bd6550d7 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(10000), new ThreadFactoryImpl("testMultiThread")); - for (int i = 0; i < 10000; i++) { + executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS, + new ArrayBlockingQueue(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(10000), new ThreadFactoryImpl("testMultiThread")); - for (int i = 0; i < 10000; i++) { + executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS, + new ArrayBlockingQueue(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); -- GitLab