forked from apache/rocketmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RocketMQ-58] Add integration test for RocketMQ, also thanks @fenglia…
- Loading branch information
1 parent
581039b
commit 788771a
Showing
93 changed files
with
8,492 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
85 changes: 85 additions & 0 deletions
85
test/src/main/java/org/apache/rocketmq/test/client/mq/MQAsyncProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
Oops, something went wrong.