rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dongefore...@apache.org
Subject [11/51] [abbrv] incubator-rocketmq git commit: [ROCKETMQ-76] Expose IntegrationTestBase to be used by other integration projects closes apache/incubator-rocketmq#52
Date Tue, 06 Jun 2017 03:38:31 GMT
[ROCKETMQ-76] Expose IntegrationTestBase to be used by other integration projects closes apache/incubator-rocketmq#52


Project: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/commit/34012960
Tree: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/tree/34012960
Diff: http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/diff/34012960

Branch: refs/heads/master
Commit: 34012960717fb28168cd8eed2ba18a3dd2e6b4aa
Parents: e0d4a50
Author: shtykh_roman <rshtykh@yahoo.com>
Authored: Wed Mar 29 16:13:51 2017 +0800
Committer: dongeforever <zhendongliu92@yeah.net>
Committed: Tue Jun 6 11:37:29 2017 +0800

----------------------------------------------------------------------
 test/pom.xml                                    | 16 +++++++++++
 .../org/apache/rocketmq/test/util/MQAdmin.java  |  2 +-
 .../apache/rocketmq/test/util/TestUtils.java    |  2 +-
 .../org/apache/rocketmq/test/base/BaseConf.java | 17 +-----------
 .../rocketmq/test/base/IntegrationTestBase.java | 28 +++++++++++++++++++-
 .../tag/TagMessageWithSameGroupConsumerIT.java  |  8 +++---
 .../producer/async/AsyncSendExceptionIT.java    |  4 +--
 .../producer/querymsg/QueryMsgByIdIT.java       |  2 +-
 .../producer/querymsg/QueryMsgByKeyIT.java      |  4 +--
 9 files changed, 55 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index 42ebea7..adb51fd 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -47,4 +47,20 @@
             <version>0.30</version>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java b/test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
index c3e0572..680780a 100644
--- a/test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
+++ b/test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
@@ -52,7 +52,7 @@ public class MQAdmin {
         while (!createResult) {
             createResult = checkTopicExist(mqAdminExt, topic);
             if (System.currentTimeMillis() - startTime < waitTimeSec * 1000) {
-                TestUtils.waitForMonment(100);
+                TestUtils.waitForMoment(100);
             } else {
                 log.error(String.format("timeout,but create topic[%s] failed!", topic));
                 break;

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java b/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java
index 6326d46..3eb1f7d 100644
--- a/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java
+++ b/test/src/main/java/org/apache/rocketmq/test/util/TestUtils.java
@@ -20,7 +20,7 @@ package org.apache.rocketmq.test.util;
 import java.util.concurrent.TimeUnit;
 
 public class TestUtils {
-    public static void waitForMonment(long time) {
+    public static void waitForMoment(long time) {
         try {
             Thread.sleep(time);
         } catch (InterruptedException var3) {

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java b/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
index 57462a2..92f77b8 100644
--- a/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
+++ b/test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
@@ -42,7 +42,6 @@ public class BaseConf {
     protected static int brokerNum;
     protected static int waitTime = 5;
     protected static int consumeTime = 1 * 60 * 1000;
-    protected static int topicCreateTime = 30 * 1000;
     protected static NamesrvController namesrvController;
     protected static BrokerController brokerController1;
     protected static BrokerController brokerController2;
@@ -66,22 +65,8 @@ public class BaseConf {
     }
 
     public static String initTopic() {
-        long startTime = System.currentTimeMillis();
         String topic = MQRandomUtils.getRandomTopic();
-        boolean createResult = false;
-        while (true) {
-            createResult = MQAdmin.createTopic(nsAddr, clusterName, topic, 8);
-            if (createResult) {
-                break;
-            } else if (System.currentTimeMillis() - startTime > topicCreateTime) {
-                Assert.fail(String.format("topic[%s] is created failed after:%d ms", topic,
-                    System.currentTimeMillis() - startTime));
-                break;
-            } else {
-                TestUtils.waitForMonment(500);
-                continue;
-            }
-        }
+        IntegrationTestBase.initTopic(topic, nsAddr, clusterName);
 
         return topic;
     }

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java b/test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
index ff9996d..5329991 100644
--- a/test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
+++ b/test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
@@ -30,18 +30,23 @@ import org.apache.rocketmq.namesrv.NamesrvController;
 import org.apache.rocketmq.remoting.netty.NettyClientConfig;
 import org.apache.rocketmq.remoting.netty.NettyServerConfig;
 import org.apache.rocketmq.store.config.MessageStoreConfig;
+import org.apache.rocketmq.test.util.MQAdmin;
+import org.apache.rocketmq.test.util.TestUtils;
 import org.junit.Assert;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class IntegrationTestBase {
+    public static Logger logger = LoggerFactory.getLogger(IntegrationTestBase.class);
+
     protected static final String SEP = File.separator;
     protected static final String BROKER_NAME_PREFIX = "TestBrokerName_";
     protected static final AtomicInteger BROKER_INDEX = new AtomicInteger(0);
     protected static final List<File> TMPE_FILES = new ArrayList<>();
     protected static final List<BrokerController> BROKER_CONTROLLERS = new ArrayList<>();
     protected static final List<NamesrvController> NAMESRV_CONTROLLERS = new ArrayList<>();
-    public static Logger logger = LoggerFactory.getLogger(IntegrationTestBase.class);
+    protected static int topicCreateTime = 30 * 1000;
+
     protected static Random random = new Random();
 
     static {
@@ -125,6 +130,27 @@ public class IntegrationTestBase {
         return brokerController;
     }
 
+    public static boolean initTopic(String topic, String nsAddr, String clusterName) {
+        long startTime = System.currentTimeMillis();
+        boolean createResult;
+
+        while (true) {
+            createResult = MQAdmin.createTopic(nsAddr, clusterName, topic, 8);
+            if (createResult) {
+                break;
+            } else if (System.currentTimeMillis() - startTime > topicCreateTime) {
+                Assert.fail(String.format("topic[%s] is created failed after:%d ms", topic,
+                    System.currentTimeMillis() - startTime));
+                break;
+            } else {
+                TestUtils.waitForMoment(500);
+                continue;
+            }
+        }
+
+        return createResult;
+    }
+
     public static void deleteFile(File file) {
         if (!file.exists()) {
             return;

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/client/consumer/tag/TagMessageWithSameGroupConsumerIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/client/consumer/tag/TagMessageWithSameGroupConsumerIT.java
b/test/src/test/java/org/apache/rocketmq/test/client/consumer/tag/TagMessageWithSameGroupConsumerIT.java
index 03e81eb..4cf8161 100644
--- a/test/src/test/java/org/apache/rocketmq/test/client/consumer/tag/TagMessageWithSameGroupConsumerIT.java
+++ b/test/src/test/java/org/apache/rocketmq/test/client/consumer/tag/TagMessageWithSameGroupConsumerIT.java
@@ -78,10 +78,10 @@ public class TagMessageWithSameGroupConsumerIT extends BaseConf {
         RMQNormalConsumer consumer1 = getConsumer(nsAddr, topic, tag,
             new RMQNormalListner(originMsgDCName, msgBodyDCName));
         producer.send(tag, msgSize, 100);
-        TestUtils.waitForMonment(5);
+        TestUtils.waitForMoment(5);
         RMQNormalConsumer consumer2 = getConsumer(nsAddr, consumer1.getConsumerGroup(), tag,
             new RMQNormalListner(originMsgDCName, msgBodyDCName));
-        TestUtils.waitForMonment(5);
+        TestUtils.waitForMoment(5);
 
         consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
         assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),
@@ -102,10 +102,10 @@ public class TagMessageWithSameGroupConsumerIT extends BaseConf {
             new RMQNormalListner(originMsgDCName, msgBodyDCName));
 
         producer.send(tag, msgSize, 100);
-        TestUtils.waitForMonment(5);
+        TestUtils.waitForMoment(5);
         consumer2.shutdown();
         mqClients.remove(1);
-        TestUtils.waitForMonment(5);
+        TestUtils.waitForMoment(5);
 
         consumer1.getListner().waitForMessageConsume(producer.getAllMsgBody(), consumeTime);
         assertThat(VerifyUtils.getFilterdMessage(producer.getAllMsgBody(),

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/client/producer/async/AsyncSendExceptionIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/client/producer/async/AsyncSendExceptionIT.java
b/test/src/test/java/org/apache/rocketmq/test/client/producer/async/AsyncSendExceptionIT.java
index 4125433..b3d258f 100644
--- a/test/src/test/java/org/apache/rocketmq/test/client/producer/async/AsyncSendExceptionIT.java
+++ b/test/src/test/java/org/apache/rocketmq/test/client/producer/async/AsyncSendExceptionIT.java
@@ -112,7 +112,7 @@ public class AsyncSendExceptionIT extends BaseConf {
         int checkNum = 50;
         while (!sendFail && checkNum > 0) {
             checkNum--;
-            TestUtils.waitForMonment(100);
+            TestUtils.waitForMoment(100);
         }
         producer.shutdown();
         assertThat(sendFail).isEqualTo(true);
@@ -141,7 +141,7 @@ public class AsyncSendExceptionIT extends BaseConf {
         int checkNum = 50;
         while (sendFail && checkNum > 0) {
             checkNum--;
-            TestUtils.waitForMonment(100);
+            TestUtils.waitForMoment(100);
         }
         producer.shutdown();
         assertThat(sendFail).isEqualTo(false);

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByIdIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByIdIT.java
b/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByIdIT.java
index 92c40c7..2cdd66c 100644
--- a/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByIdIT.java
+++ b/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByIdIT.java
@@ -64,7 +64,7 @@ public class QueryMsgByIdIT extends BaseConf {
         MessageExt recvMsg = (MessageExt) consumer.getListner().getFirstMsg();
         MessageExt queryMsg = null;
         try {
-            TestUtils.waitForMonment(3000);
+            TestUtils.waitForMoment(3000);
             queryMsg = producer.getProducer().viewMessage(((MessageClientExt) recvMsg).getOffsetMsgId());
         } catch (Exception e) {
         }

http://git-wip-us.apache.org/repos/asf/incubator-rocketmq/blob/34012960/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByKeyIT.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByKeyIT.java
b/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByKeyIT.java
index ec45a29..68dd8db 100644
--- a/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByKeyIT.java
+++ b/test/src/test/java/org/apache/rocketmq/test/client/producer/querymsg/QueryMsgByKeyIT.java
@@ -59,7 +59,7 @@ public class QueryMsgByKeyIT extends BaseConf {
 
         List<MessageExt> queryMsgs = null;
         try {
-            TestUtils.waitForMonment(500 * 3);
+            TestUtils.waitForMoment(500 * 3);
             queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin -
5000,
                 System.currentTimeMillis() + 5000).getMessageList();
         } catch (Exception e) {
@@ -89,7 +89,7 @@ public class QueryMsgByKeyIT extends BaseConf {
                 i--;
                 queryMsgs = producer.getProducer().queryMessage(topic, key, msgSize, begin
- 15000,
                     System.currentTimeMillis() + 15000).getMessageList();
-                TestUtils.waitForMonment(1000);
+                TestUtils.waitForMoment(1000);
 
                 if (i == 0 || (queryMsgs != null && queryMsgs.size() == max)) {
                     break;


Mime
View raw message