Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
0846c3c6
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
0846c3c6
编写于
6月 23, 2021
作者:
C
chenzlalvin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[RIP-21] submodule test
上级
f3990857
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
1246 addition
and
32 deletion
+1246
-32
test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
.../src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
+5
-4
test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
...src/test/java/org/apache/rocketmq/test/base/BaseConf.java
+69
-26
test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
...va/org/apache/rocketmq/test/base/IntegrationTestBase.java
+2
-2
test/src/test/java/org/apache/rocketmq/test/smoke/LogicalQueueIT.java
...t/java/org/apache/rocketmq/test/smoke/LogicalQueueIT.java
+1170
-0
未找到文件。
test/src/main/java/org/apache/rocketmq/test/util/MQAdmin.java
浏览文件 @
0846c3c6
...
...
@@ -20,6 +20,7 @@ package org.apache.rocketmq.test.util;
import
java.util.HashMap
;
import
java.util.Set
;
import
java.util.UUID
;
import
java.util.concurrent.ForkJoinPool
;
import
org.apache.log4j.Logger
;
import
org.apache.rocketmq.common.admin.TopicStatsTable
;
import
org.apache.rocketmq.common.protocol.body.ClusterInfo
;
...
...
@@ -60,7 +61,7 @@ public class MQAdmin {
}
}
mqAdminExt
.
shutdown
(
);
ForkJoinPool
.
commonPool
().
execute
(
mqAdminExt:
:
shutdown
);
return
createResult
;
}
...
...
@@ -99,7 +100,7 @@ public class MQAdmin {
createResult
=
false
;
e
.
printStackTrace
();
}
mqAdminExt
.
shutdown
(
);
ForkJoinPool
.
commonPool
().
execute
(
mqAdminExt:
:
shutdown
);
return
createResult
;
}
...
...
@@ -113,7 +114,7 @@ public class MQAdmin {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
mqAdminExt
.
shutdown
(
);
ForkJoinPool
.
commonPool
().
execute
(
mqAdminExt:
:
shutdown
);
return
clusterInfo
;
}
...
...
@@ -159,7 +160,7 @@ public class MQAdmin {
createResult
=
false
;
e
.
printStackTrace
();
}
mqAdminExt
.
shutdown
(
);
ForkJoinPool
.
commonPool
().
execute
(
mqAdminExt:
:
shutdown
);
}
}
test/src/test/java/org/apache/rocketmq/test/base/BaseConf.java
浏览文件 @
0846c3c6
...
...
@@ -17,13 +17,23 @@
package
org.apache.rocketmq.test.base
;
import
com.google.common.collect.ImmutableList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ForkJoinPool
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
org.apache.log4j.Logger
;
import
org.apache.rocketmq.broker.BrokerController
;
import
org.apache.rocketmq.client.consumer.MQPullConsumer
;
import
org.apache.rocketmq.client.consumer.MQPushConsumer
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.producer.MQProducer
;
import
org.apache.rocketmq.client.producer.TransactionListener
;
import
org.apache.rocketmq.common.MQVersion
;
import
org.apache.rocketmq.common.protocol.route.BrokerData
;
import
org.apache.rocketmq.namesrv.NamesrvController
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
import
org.apache.rocketmq.test.client.rmq.RMQAsyncSendProducer
;
...
...
@@ -36,21 +46,28 @@ import org.apache.rocketmq.test.factory.ConsumerFactory;
import
org.apache.rocketmq.test.listener.AbstractListener
;
import
org.apache.rocketmq.test.util.MQAdmin
;
import
org.apache.rocketmq.test.util.MQRandomUtils
;
import
org.apache.rocketmq.tools.admin.DefaultMQAdminExt
;
import
org.apache.rocketmq.tools.admin.MQAdminExt
;
import
static
org
.
awaitility
.
Awaitility
.
await
;
public
class
BaseConf
{
public
static
String
nsAddr
;
protected
static
String
broker1Name
;
protected
static
String
broker2Name
;
protected
static
String
clusterName
;
protected
static
int
brokerNum
;
protected
static
int
waitTime
=
5
;
protected
static
int
consumeTime
=
2
*
60
*
1000
;
protected
static
NamesrvController
namesrvController
;
protected
static
BrokerController
brokerController1
;
protected
static
BrokerController
brokerController2
;
protected
static
List
<
Object
>
mqClients
=
new
ArrayList
<
Object
>();
protected
static
boolean
debug
=
false
;
private
static
Logger
log
=
Logger
.
getLogger
(
BaseConf
.
class
);
public
final
static
String
nsAddr
;
protected
final
static
String
broker1Name
;
protected
final
static
String
broker2Name
;
protected
final
static
String
clusterName
;
protected
final
static
int
brokerNum
;
protected
final
static
int
waitTime
=
5
;
protected
final
static
int
consumeTime
=
2
*
60
*
1000
;
protected
final
static
int
QUEUE_NUMBERS
=
8
;
protected
final
static
NamesrvController
namesrvController
;
protected
final
static
BrokerController
brokerController1
;
protected
final
static
BrokerController
brokerController2
;
protected
final
static
List
<
BrokerController
>
brokerControllerList
;
protected
final
static
Map
<
String
,
BrokerController
>
brokerControllerMap
;
protected
final
static
List
<
Object
>
mqClients
=
new
ArrayList
<
Object
>();
protected
final
static
boolean
debug
=
false
;
private
final
static
Logger
log
=
Logger
.
getLogger
(
BaseConf
.
class
);
static
{
System
.
setProperty
(
RemotingCommand
.
REMOTING_VERSION_KEY
,
Integer
.
toString
(
MQVersion
.
CURRENT_VERSION
));
...
...
@@ -62,14 +79,32 @@ public class BaseConf {
broker1Name
=
brokerController1
.
getBrokerConfig
().
getBrokerName
();
broker2Name
=
brokerController2
.
getBrokerConfig
().
getBrokerName
();
brokerNum
=
2
;
brokerControllerList
=
ImmutableList
.
of
(
brokerController1
,
brokerController2
);
brokerControllerMap
=
brokerControllerList
.
stream
().
collect
(
Collectors
.
toMap
(
input
->
input
.
getBrokerConfig
().
getBrokerName
(),
Function
.
identity
()));
}
public
BaseConf
()
{
}
// This method can't be placed in the static block of BaseConf, which seems to lead to a strange dead lock.
public
static
void
waitBrokerRegistered
(
final
String
nsAddr
,
final
String
clusterName
)
{
final
DefaultMQAdminExt
mqAdminExt
=
new
DefaultMQAdminExt
(
500
);
mqAdminExt
.
setNamesrvAddr
(
nsAddr
);
try
{
mqAdminExt
.
start
();
await
().
atMost
(
30
,
TimeUnit
.
SECONDS
).
until
(()
->
{
List
<
BrokerData
>
brokerDatas
=
mqAdminExt
.
examineTopicRouteInfo
(
clusterName
).
getBrokerDatas
();
return
brokerDatas
.
size
()
==
brokerNum
;
});
}
catch
(
MQClientException
e
)
{
log
.
error
(
"init failed, please check BaseConf"
);
}
ForkJoinPool
.
commonPool
().
execute
(
mqAdminExt:
:
shutdown
);
}
public
static
String
initTopic
()
{
String
topic
=
MQRandomUtils
.
getRandomTopic
();
String
topic
=
"tt-"
+
MQRandomUtils
.
getRandomTopic
();
IntegrationTestBase
.
initTopic
(
topic
,
nsAddr
,
clusterName
);
return
topic
;
...
...
@@ -157,18 +192,26 @@ public class BaseConf {
}
public
static
void
shutdown
()
{
try
{
for
(
Object
mqClient
:
mqClients
)
{
if
(
mqClient
instanceof
AbstractMQProducer
)
{
((
AbstractMQProducer
)
mqClient
).
shutdown
();
ImmutableList
<
Object
>
mqClients
=
ImmutableList
.
copyOf
(
BaseConf
.
mqClients
);
BaseConf
.
mqClients
.
clear
();
shutdown
(
mqClients
);
}
}
else
{
((
AbstractMQConsumer
)
mqClient
).
shutdown
();
}
public
static
void
shutdown
(
List
<
Object
>
mqClients
)
{
mqClients
.
forEach
(
mqClient
->
ForkJoinPool
.
commonPool
().
execute
(()
->
{
if
(
mqClient
instanceof
AbstractMQProducer
)
{
((
AbstractMQProducer
)
mqClient
).
shutdown
();
}
else
if
(
mqClient
instanceof
AbstractMQConsumer
)
{
((
AbstractMQConsumer
)
mqClient
).
shutdown
();
}
else
if
(
mqClient
instanceof
MQAdminExt
)
{
((
MQAdminExt
)
mqClient
).
shutdown
();
}
else
if
(
mqClient
instanceof
MQProducer
)
{
((
MQProducer
)
mqClient
).
shutdown
();
}
else
if
(
mqClient
instanceof
MQPullConsumer
)
{
((
MQPullConsumer
)
mqClient
).
shutdown
();
}
else
if
(
mqClient
instanceof
MQPushConsumer
)
{
((
MQPushConsumer
)
mqClient
).
shutdown
();
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}));
}
}
test/src/test/java/org/apache/rocketmq/test/base/IntegrationTestBase.java
浏览文件 @
0846c3c6
...
...
@@ -47,7 +47,7 @@ public class IntegrationTestBase {
protected
static
final
List
<
BrokerController
>
BROKER_CONTROLLERS
=
new
ArrayList
<>();
protected
static
final
List
<
NamesrvController
>
NAMESRV_CONTROLLERS
=
new
ArrayList
<>();
protected
static
int
topicCreateTime
=
30
*
1000
;
p
rotected
static
final
int
COMMIT_LOG_SIZE
=
1024
*
1024
*
100
;
p
ublic
static
volatile
int
COMMIT_LOG_SIZE
=
1024
*
1024
*
100
;
protected
static
final
int
INDEX_NUM
=
1000
;
private
static
final
AtomicInteger
port
=
new
AtomicInteger
(
40000
);
...
...
@@ -183,7 +183,7 @@ public class IntegrationTestBase {
}
public
static
boolean
initTopic
(
String
topic
,
String
nsAddr
,
String
clusterName
)
{
return
initTopic
(
topic
,
nsAddr
,
clusterName
,
8
);
return
initTopic
(
topic
,
nsAddr
,
clusterName
,
BaseConf
.
QUEUE_NUMBERS
);
}
public
static
void
deleteFile
(
File
file
)
{
...
...
test/src/test/java/org/apache/rocketmq/test/smoke/LogicalQueueIT.java
0 → 100644
浏览文件 @
0846c3c6
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录