Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
494600c3
M
milvus
项目概览
milvus
/
milvus
11 个月 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
494600c3
编写于
9月 10, 2021
作者:
X
Xiangyu Wang
提交者:
GitHub
9月 10, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add unit tests for msg.go (#7691)
Signed-off-by:
N
Xiangyu Wang
<
xiangyu.wang@zilliz.com
>
上级
9b2fd0f7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
177 addition
and
0 deletion
+177
-0
internal/msgstream/msg_test.go
internal/msgstream/msg_test.go
+177
-0
未找到文件。
internal/msgstream/msg_test.go
浏览文件 @
494600c3
...
...
@@ -16,6 +16,7 @@ import (
"testing"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/proto/schemapb"
"github.com/stretchr/testify/assert"
...
...
@@ -362,6 +363,93 @@ func TestRetrieveResultMsg_Unmarshal_IllegalParameter(t *testing.T) {
assert
.
Nil
(
t
,
tsMsg
)
}
func
TestTimeTickMsg
(
t
*
testing
.
T
)
{
timeTickMsg
:=
&
TimeTickMsg
{
BaseMsg
:
generateBaseMsg
(),
TimeTickMsg
:
internalpb
.
TimeTickMsg
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_TimeTick
,
MsgID
:
1
,
Timestamp
:
2
,
SourceID
:
3
,
},
},
}
assert
.
NotNil
(
t
,
timeTickMsg
.
TraceCtx
())
ctx
:=
context
.
Background
()
timeTickMsg
.
SetTraceCtx
(
ctx
)
assert
.
Equal
(
t
,
ctx
,
timeTickMsg
.
TraceCtx
())
assert
.
Equal
(
t
,
int64
(
1
),
timeTickMsg
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_TimeTick
,
timeTickMsg
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
timeTickMsg
.
SourceID
())
bytes
,
err
:=
timeTickMsg
.
Marshal
(
timeTickMsg
)
assert
.
Nil
(
t
,
err
)
tsMsg
,
err
:=
timeTickMsg
.
Unmarshal
(
bytes
)
assert
.
Nil
(
t
,
err
)
timeTickMsg2
,
ok
:=
tsMsg
.
(
*
TimeTickMsg
)
assert
.
True
(
t
,
ok
)
assert
.
Equal
(
t
,
int64
(
1
),
timeTickMsg2
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_TimeTick
,
timeTickMsg2
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
timeTickMsg2
.
SourceID
())
}
func
TestTimeTickMsg_Unmarshal_IllegalParameter
(
t
*
testing
.
T
)
{
timeTickMsg
:=
&
TimeTickMsg
{}
tsMsg
,
err
:=
timeTickMsg
.
Unmarshal
(
10
)
assert
.
NotNil
(
t
,
err
)
assert
.
Nil
(
t
,
tsMsg
)
}
func
TestSegmentStatisticsMsg
(
t
*
testing
.
T
)
{
segmentStatisticsMsg
:=
&
SegmentStatisticsMsg
{
BaseMsg
:
generateBaseMsg
(),
SegmentStatistics
:
internalpb
.
SegmentStatistics
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_SegmentStatistics
,
MsgID
:
1
,
Timestamp
:
2
,
SourceID
:
3
,
},
SegStats
:
[]
*
internalpb
.
SegmentStatisticsUpdates
{},
},
}
assert
.
NotNil
(
t
,
segmentStatisticsMsg
.
TraceCtx
())
ctx
:=
context
.
Background
()
segmentStatisticsMsg
.
SetTraceCtx
(
ctx
)
assert
.
Equal
(
t
,
ctx
,
segmentStatisticsMsg
.
TraceCtx
())
assert
.
Equal
(
t
,
int64
(
1
),
segmentStatisticsMsg
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_SegmentStatistics
,
segmentStatisticsMsg
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
segmentStatisticsMsg
.
SourceID
())
bytes
,
err
:=
segmentStatisticsMsg
.
Marshal
(
segmentStatisticsMsg
)
assert
.
Nil
(
t
,
err
)
tsMsg
,
err
:=
segmentStatisticsMsg
.
Unmarshal
(
bytes
)
assert
.
Nil
(
t
,
err
)
segmentStatisticsMsg2
,
ok
:=
tsMsg
.
(
*
SegmentStatisticsMsg
)
assert
.
True
(
t
,
ok
)
assert
.
Equal
(
t
,
int64
(
1
),
segmentStatisticsMsg2
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_SegmentStatistics
,
segmentStatisticsMsg2
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
segmentStatisticsMsg2
.
SourceID
())
}
func
TestSegmentStatisticsMsg_Unmarshal_IllegalParameter
(
t
*
testing
.
T
)
{
segmentStatisticsMsg
:=
&
SegmentStatisticsMsg
{}
tsMsg
,
err
:=
segmentStatisticsMsg
.
Unmarshal
(
10
)
assert
.
NotNil
(
t
,
err
)
assert
.
Nil
(
t
,
tsMsg
)
}
func
TestCreateCollectionMsg
(
t
*
testing
.
T
)
{
createCollectionMsg
:=
&
CreateCollectionMsg
{
BaseMsg
:
generateBaseMsg
(),
...
...
@@ -558,3 +646,92 @@ func TestDropPartitionMsg_Unmarshal_IllegalParameter(t *testing.T) {
assert
.
NotNil
(
t
,
err
)
assert
.
Nil
(
t
,
tsMsg
)
}
func
TestLoadBalanceSegmentsMsg
(
t
*
testing
.
T
)
{
loadBalanceSegmentsMsg
:=
&
LoadBalanceSegmentsMsg
{
BaseMsg
:
generateBaseMsg
(),
LoadBalanceSegmentsRequest
:
internalpb
.
LoadBalanceSegmentsRequest
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_LoadBalanceSegments
,
MsgID
:
1
,
Timestamp
:
2
,
SourceID
:
3
,
},
SegmentIDs
:
[]
int64
{},
},
}
assert
.
NotNil
(
t
,
loadBalanceSegmentsMsg
.
TraceCtx
())
ctx
:=
context
.
Background
()
loadBalanceSegmentsMsg
.
SetTraceCtx
(
ctx
)
assert
.
Equal
(
t
,
ctx
,
loadBalanceSegmentsMsg
.
TraceCtx
())
assert
.
Equal
(
t
,
int64
(
1
),
loadBalanceSegmentsMsg
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_LoadBalanceSegments
,
loadBalanceSegmentsMsg
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
loadBalanceSegmentsMsg
.
SourceID
())
bytes
,
err
:=
loadBalanceSegmentsMsg
.
Marshal
(
loadBalanceSegmentsMsg
)
assert
.
Nil
(
t
,
err
)
tsMsg
,
err
:=
loadBalanceSegmentsMsg
.
Unmarshal
(
bytes
)
assert
.
Nil
(
t
,
err
)
loadBalanceSegmentsMsg2
,
ok
:=
tsMsg
.
(
*
LoadBalanceSegmentsMsg
)
assert
.
True
(
t
,
ok
)
assert
.
Equal
(
t
,
int64
(
1
),
loadBalanceSegmentsMsg2
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_LoadBalanceSegments
,
loadBalanceSegmentsMsg2
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
loadBalanceSegmentsMsg2
.
SourceID
())
}
func
TestLoadBalanceSegmentsMsg_Unmarshal_IllegalParameter
(
t
*
testing
.
T
)
{
loadBalanceSegmentsMsg
:=
&
LoadBalanceSegmentsMsg
{}
tsMsg
,
err
:=
loadBalanceSegmentsMsg
.
Unmarshal
(
10
)
assert
.
NotNil
(
t
,
err
)
assert
.
Nil
(
t
,
tsMsg
)
}
func
TestDataNodeTtMsg
(
t
*
testing
.
T
)
{
dataNodeTtMsg
:=
&
DataNodeTtMsg
{
BaseMsg
:
generateBaseMsg
(),
DataNodeTtMsg
:
datapb
.
DataNodeTtMsg
{
Base
:
&
commonpb
.
MsgBase
{
MsgType
:
commonpb
.
MsgType_DataNodeTt
,
MsgID
:
1
,
Timestamp
:
2
,
SourceID
:
3
,
},
ChannelName
:
"test-channel"
,
Timestamp
:
4
,
},
}
assert
.
NotNil
(
t
,
dataNodeTtMsg
.
TraceCtx
())
ctx
:=
context
.
Background
()
dataNodeTtMsg
.
SetTraceCtx
(
ctx
)
assert
.
Equal
(
t
,
ctx
,
dataNodeTtMsg
.
TraceCtx
())
assert
.
Equal
(
t
,
int64
(
1
),
dataNodeTtMsg
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_DataNodeTt
,
dataNodeTtMsg
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
dataNodeTtMsg
.
SourceID
())
bytes
,
err
:=
dataNodeTtMsg
.
Marshal
(
dataNodeTtMsg
)
assert
.
Nil
(
t
,
err
)
tsMsg
,
err
:=
dataNodeTtMsg
.
Unmarshal
(
bytes
)
assert
.
Nil
(
t
,
err
)
dataNodeTtMsg2
,
ok
:=
tsMsg
.
(
*
DataNodeTtMsg
)
assert
.
True
(
t
,
ok
)
assert
.
Equal
(
t
,
int64
(
1
),
dataNodeTtMsg2
.
ID
())
assert
.
Equal
(
t
,
commonpb
.
MsgType_DataNodeTt
,
dataNodeTtMsg2
.
Type
())
assert
.
Equal
(
t
,
int64
(
3
),
dataNodeTtMsg2
.
SourceID
())
}
func
TestDataNodeTtMsg_Unmarshal_IllegalParameter
(
t
*
testing
.
T
)
{
dataNodeTtMsg
:=
&
DataNodeTtMsg
{}
tsMsg
,
err
:=
dataNodeTtMsg
.
Unmarshal
(
10
)
assert
.
NotNil
(
t
,
err
)
assert
.
Nil
(
t
,
tsMsg
)
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录