Skip to content

Commit 690a406

Browse files
hdchenShannonDing
authored andcommitted
[RIP-10] modify test case StatsItemSetTest's param (alibaba#1053)
1 parent 9cf0979 commit 690a406

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

common/src/test/java/org/apache/rocketmq/common/stats/StatsItemSetTest.java

+10-14
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,19 @@ public class StatsItemSetTest {
3636

3737
@Test
3838
public void test_getAndCreateStatsItem_multiThread() throws InterruptedException {
39-
for (int i = 0; i < 50; i++) {
40-
assertEquals(20000L, test_unit().longValue());
41-
}
39+
assertEquals(20L, test_unit().longValue());
4240
}
4341

4442
@Test
4543
public void test_getAndCreateMomentStatsItem_multiThread() throws InterruptedException {
46-
for (int i = 0; i < 50; i++) {
47-
assertEquals(10, test_unit_moment().longValue());
48-
}
44+
assertEquals(10, test_unit_moment().longValue());
4945
}
5046

5147
private AtomicLong test_unit() throws InterruptedException {
5248
final StatsItemSet statsItemSet = new StatsItemSet("topicTest", scheduler, null);
53-
executor = new ThreadPoolExecutor(100, 200, 10, TimeUnit.SECONDS,
54-
new ArrayBlockingQueue<Runnable>(10000), new ThreadFactoryImpl("testMultiThread"));
55-
for (int i = 0; i < 10000; i++) {
49+
executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
50+
new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
51+
for (int i = 0; i < 10; i++) {
5652
executor.submit(new Runnable() {
5753
@Override
5854
public void run() {
@@ -61,7 +57,7 @@ public void run() {
6157
});
6258
}
6359
while (true) {
64-
if (executor.getCompletedTaskCount() == 10000) {
60+
if (executor.getCompletedTaskCount() == 10) {
6561
break;
6662
}
6763
Thread.sleep(1000);
@@ -71,9 +67,9 @@ public void run() {
7167

7268
private AtomicLong test_unit_moment() throws InterruptedException {
7369
final MomentStatsItemSet statsItemSet = new MomentStatsItemSet("topicTest", scheduler, null);
74-
executor = new ThreadPoolExecutor(100, 200, 10, TimeUnit.SECONDS,
75-
new ArrayBlockingQueue<Runnable>(10000), new ThreadFactoryImpl("testMultiThread"));
76-
for (int i = 0; i < 10000; i++) {
70+
executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
71+
new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
72+
for (int i = 0; i < 10; i++) {
7773
executor.submit(new Runnable() {
7874
@Override
7975
public void run() {
@@ -82,7 +78,7 @@ public void run() {
8278
});
8379
}
8480
while (true) {
85-
if (executor.getCompletedTaskCount() == 10000) {
81+
if (executor.getCompletedTaskCount() == 10) {
8682
break;
8783
}
8884
Thread.sleep(1000);

0 commit comments

Comments
 (0)