Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
b74c48b3
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看板
提交
b74c48b3
编写于
7月 02, 2021
作者:
L
lizhiboo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add trace data format test case
上级
70295453
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
103 addition
and
1 deletion
+103
-1
client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java
...rg/apache/rocketmq/client/trace/TraceDataEncoderTest.java
+103
-1
未找到文件。
client/src/test/java/org/apache/rocketmq/client/trace/TraceDataEncoderTest.java
浏览文件 @
b74c48b3
...
...
@@ -60,7 +60,6 @@ public class TraceDataEncoderTest {
Assert
.
assertEquals
(
contexts
.
get
(
0
).
getTraceType
(),
TraceType
.
Pub
);
}
@Test
public
void
testEncoderFromContextBean
()
{
TraceContext
context
=
new
TraceContext
();
...
...
@@ -130,4 +129,107 @@ public class TraceDataEncoderTest {
Assert
.
assertEquals
(
before
.
getTransactionState
(),
after
.
getTransactionState
());
Assert
.
assertEquals
(
before
.
isFromTransactionCheck
(),
after
.
isFromTransactionCheck
());
}
@Test
public
void
testPubTraceDataFormatTest
()
{
TraceContext
pubContext
=
new
TraceContext
();
pubContext
.
setTraceType
(
TraceType
.
Pub
);
pubContext
.
setTimeStamp
(
time
);
pubContext
.
setRegionId
(
"Default-region"
);
pubContext
.
setGroupName
(
"GroupName-test"
);
pubContext
.
setCostTime
(
34
);
pubContext
.
setSuccess
(
true
);
TraceBean
bean
=
new
TraceBean
();
bean
.
setTopic
(
"topic-test"
);
bean
.
setMsgId
(
"AC1415116D1418B4AAC217FE1B4E0000"
);
bean
.
setTags
(
"tags"
);
bean
.
setKeys
(
"keys"
);
bean
.
setStoreHost
(
"127.0.0.1:10911"
);
bean
.
setBodyLength
(
100
);
bean
.
setMsgType
(
MessageType
.
Normal_Msg
);
bean
.
setOffsetMsgId
(
"AC1415116D1418B4AAC217FE1B4E0000"
);
pubContext
.
setTraceBeans
(
new
ArrayList
<
TraceBean
>(
1
));
pubContext
.
getTraceBeans
().
add
(
bean
);
TraceTransferBean
traceTransferBean
=
TraceDataEncoder
.
encoderFromContextBean
(
pubContext
);
String
transData
=
traceTransferBean
.
getTransData
();
Assert
.
assertNotNull
(
transData
);
String
[]
items
=
transData
.
split
(
String
.
valueOf
(
TraceConstants
.
CONTENT_SPLITOR
));
Assert
.
assertEquals
(
14
,
items
.
length
);
}
@Test
public
void
testSubBeforeTraceDataFormatTest
()
{
TraceContext
subBeforeContext
=
new
TraceContext
();
subBeforeContext
.
setTraceType
(
TraceType
.
SubBefore
);
subBeforeContext
.
setTimeStamp
(
time
);
subBeforeContext
.
setRegionId
(
"Default-region"
);
subBeforeContext
.
setGroupName
(
"GroupName-test"
);
subBeforeContext
.
setRequestId
(
"3455848576927"
);
TraceBean
bean
=
new
TraceBean
();
bean
.
setMsgId
(
"AC1415116D1418B4AAC217FE1B4E0000"
);
bean
.
setRetryTimes
(
0
);
bean
.
setKeys
(
"keys"
);
subBeforeContext
.
setTraceBeans
(
new
ArrayList
<
TraceBean
>(
1
));
subBeforeContext
.
getTraceBeans
().
add
(
bean
);
TraceTransferBean
traceTransferBean
=
TraceDataEncoder
.
encoderFromContextBean
(
subBeforeContext
);
String
transData
=
traceTransferBean
.
getTransData
();
Assert
.
assertNotNull
(
transData
);
String
[]
items
=
transData
.
split
(
String
.
valueOf
(
TraceConstants
.
CONTENT_SPLITOR
));
Assert
.
assertEquals
(
8
,
items
.
length
);
}
@Test
public
void
testSubAfterTraceDataFormatTest
()
{
TraceContext
subAfterContext
=
new
TraceContext
();
subAfterContext
.
setTraceType
(
TraceType
.
SubAfter
);
subAfterContext
.
setRequestId
(
"3455848576927"
);
subAfterContext
.
setCostTime
(
20
);
subAfterContext
.
setSuccess
(
true
);
subAfterContext
.
setContextCode
(
98623046
);
TraceBean
bean
=
new
TraceBean
();
bean
.
setMsgId
(
"AC1415116D1418B4AAC217FE1B4E0000"
);
bean
.
setKeys
(
"keys"
);
subAfterContext
.
setTraceBeans
(
new
ArrayList
<
TraceBean
>(
1
));
subAfterContext
.
getTraceBeans
().
add
(
bean
);
TraceTransferBean
traceTransferBean
=
TraceDataEncoder
.
encoderFromContextBean
(
subAfterContext
);
String
transData
=
traceTransferBean
.
getTransData
();
Assert
.
assertNotNull
(
transData
);
String
[]
items
=
transData
.
split
(
String
.
valueOf
(
TraceConstants
.
CONTENT_SPLITOR
));
Assert
.
assertEquals
(
7
,
items
.
length
);
}
@Test
public
void
testEndTrxTraceDataFormatTest
()
{
TraceContext
endTrxContext
=
new
TraceContext
();
endTrxContext
.
setTraceType
(
TraceType
.
EndTransaction
);
endTrxContext
.
setGroupName
(
"PID-test"
);
endTrxContext
.
setRegionId
(
"DefaultRegion"
);
endTrxContext
.
setTimeStamp
(
time
);
TraceBean
endTrxTraceBean
=
new
TraceBean
();
endTrxTraceBean
.
setTopic
(
"topic-test"
);
endTrxTraceBean
.
setKeys
(
"Keys"
);
endTrxTraceBean
.
setTags
(
"Tags"
);
endTrxTraceBean
.
setMsgId
(
"AC1415116D1418B4AAC217FE1B4E0000"
);
endTrxTraceBean
.
setStoreHost
(
"127.0.0.1:10911"
);
endTrxTraceBean
.
setMsgType
(
MessageType
.
Trans_msg_Commit
);
endTrxTraceBean
.
setTransactionId
(
"transactionId"
);
endTrxTraceBean
.
setTransactionState
(
LocalTransactionState
.
COMMIT_MESSAGE
);
endTrxTraceBean
.
setFromTransactionCheck
(
false
);
List
<
TraceBean
>
traceBeans
=
new
ArrayList
<
TraceBean
>();
traceBeans
.
add
(
endTrxTraceBean
);
endTrxContext
.
setTraceBeans
(
traceBeans
);
TraceTransferBean
traceTransferBean
=
TraceDataEncoder
.
encoderFromContextBean
(
endTrxContext
);
String
transData
=
traceTransferBean
.
getTransData
();
Assert
.
assertNotNull
(
transData
);
String
[]
items
=
transData
.
split
(
String
.
valueOf
(
TraceConstants
.
CONTENT_SPLITOR
));
Assert
.
assertEquals
(
13
,
items
.
length
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录