Skip to content

Commit

Permalink
[RocketMQ-58] Add integration test for RocketMQ, also thanks @fenglia…
Browse files Browse the repository at this point in the history
…nghfl for this commit, closes apache#46
  • Loading branch information
dongeforever authored and zhouxinyu committed Jan 20, 2017
1 parent 581039b commit 788771a
Show file tree
Hide file tree
Showing 93 changed files with 8,492 additions and 24 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ script:
- travis_retry mvn -B package jacoco:report coveralls:report

after_success:
- mvn clean install -Pit-test
- mvn sonar:sonar
2 changes: 1 addition & 1 deletion BUILDING
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Then, import to eclipse by specifying the root directory of the project via:

Execute the following command in order to build the tar.gz packages and install JAR to the local repository:

$ mvn clean package install -Prelease-all assembly:assembly -U
$ mvn clean install -Prelease-all assembly:assembly -U
73 changes: 50 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@
<!-- Compiler settings properties -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>

<!-- Overwritten by the test configuration,otherwise the JaCoCo agent cannot be attached.Details see http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html -->
<argLine>-Xms512m -Xmx1024m</argLine>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<!-- URL of the ASF SonarQube server -->
<sonar.host.url>https://builds.apache.org/analysis</sonar.host.url>
Expand All @@ -181,6 +178,7 @@
<module>example</module>
<module>filtersrv</module>
<module>srvutil</module>
<module>test</module>
</modules>

<build>
Expand Down Expand Up @@ -236,25 +234,6 @@
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
Expand Down Expand Up @@ -310,6 +289,7 @@
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
</configuration>
<goals>
<goal>check</goal>
Expand Down Expand Up @@ -352,12 +332,20 @@
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco.exec</destFile>
</configuration>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>default-report</id>
Expand All @@ -373,6 +361,14 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
Expand Down Expand Up @@ -475,6 +471,37 @@
</plugins>
</build>
</profile>
<profile>
<id>it-test</id>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
<argLine>@{failsafeArgLine}</argLine>
<excludes>
<exclude>**/NormalMsgDelayIT.java</exclude>
<exclude>**/BroadCastNormalMsgNotRecvIT.java</exclude>
<exclude>**/TagMessageWithSameGroupConsumerIT.java</exclude>
<exclude>**/AsyncSendWithMessageQueueSelectorIT.java</exclude>
<exclude>**/AsyncSendWithMessageQueueIT.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<dependencies>
Expand Down Expand Up @@ -537,7 +564,7 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-qatest</artifactId>
<artifactId>rocketmq-test</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
52 changes: 52 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>rocketmq-all</artifactId>
<groupId>org.apache.rocketmq</groupId>
<version>4.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>rocketmq-test</artifactId>


<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-broker</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-namesrv</artifactId>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.30</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.rocketmq.test.client.mq;

import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.log4j.Logger;
import org.apache.rocketmq.test.clientinterface.AbstractMQProducer;
import org.apache.rocketmq.test.util.TestUtil;

public class MQAsyncProducer {
private static Logger logger = Logger.getLogger(MQAsyncProducer.class);
private AbstractMQProducer producer = null;
private long msgNum;
private int intervalMills;
private Thread sendT;
private AtomicBoolean bPause = new AtomicBoolean(false);

public MQAsyncProducer(final AbstractMQProducer producer, final long msgNum,
final int intervalMills) {
this.producer = producer;
this.msgNum = msgNum;
this.intervalMills = intervalMills;

sendT = new Thread(new Runnable() {
public void run() {
for (int i = 0; i < msgNum; i++) {
if (!bPause.get()) {
producer.send();
TestUtil.waitForMonment(intervalMills);
} else {
while (true) {
if (bPause.get()) {
TestUtil.waitForMonment(10);
} else
break;
}
}

}
}
});

}

public void start() {
sendT.start();
}

public void waitSendAll(int waitMills) {
long startTime = System.currentTimeMillis();
while ((producer.getAllMsgBody().size() + producer.getSendErrorMsg().size()) < msgNum) {
if (System.currentTimeMillis() - startTime < waitMills) {
TestUtil.waitForMonment(200);
} else {
logger.error(String.format("time elapse:%s, but the message sending has not finished",
System.currentTimeMillis() - startTime));
break;
}
}
}

public void pauseProducer() {
bPause.set(true);
}

public void notifyProducer() {
bPause.set(false);
}

}
Loading

0 comments on commit 788771a

Please sign in to comment.