Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
03ca388f
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
03ca388f
编写于
9月 26, 2021
作者:
G
groot
提交者:
GitHub
9月 26, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce go unittest time cost (#8490)
Signed-off-by:
N
yhmo
<
yihua.mo@zilliz.com
>
上级
28d30514
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
22 addition
and
22 deletion
+22
-22
internal/proxy/segment_test.go
internal/proxy/segment_test.go
+22
-22
未找到文件。
internal/proxy/segment_test.go
浏览文件 @
03ca388f
...
...
@@ -94,7 +94,7 @@ func TestSegmentAllocator1(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
total
:=
uint32
(
0
)
...
...
@@ -117,20 +117,20 @@ func TestSegmentAllocator1(t *testing.T) {
}
var
curLastTick2
=
Timestamp
(
200
0
)
var
curLastTick2
=
Timestamp
(
200
)
var
curLastTIck2Lock
sync
.
Mutex
func
getLastTick2
()
Timestamp
{
curLastTIck2Lock
.
Lock
()
defer
curLastTIck2Lock
.
Unlock
()
curLastTick2
+=
100
0
curLastTick2
+=
100
return
curLastTick2
}
func
TestSegmentAllocator2
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
dataCoord
:=
&
mockDataCoord
{}
dataCoord
.
expireTime
=
Timestamp
(
2
500
)
dataCoord
.
expireTime
=
Timestamp
(
500
)
segAllocator
,
err
:=
NewSegIDAssigner
(
ctx
,
dataCoord
,
getLastTick2
)
assert
.
Nil
(
t
,
err
)
wg
:=
&
sync
.
WaitGroup
{}
...
...
@@ -139,17 +139,17 @@ func TestSegmentAllocator2(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
total
:=
uint32
(
0
)
for
i
:=
0
;
i
<
10
;
i
++
{
ret
,
err
:=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
1
,
200
0
)
ret
,
err
:=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
1
,
200
)
assert
.
Nil
(
t
,
err
)
total
+=
ret
[
1
]
}
assert
.
Equal
(
t
,
uint32
(
10
),
total
)
time
.
Sleep
(
time
.
S
econd
)
time
.
Sleep
(
50
*
time
.
Millis
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
SegCountPerRPC
-
10
,
getLastTick2
())
assert
.
NotNil
(
t
,
err
)
wg
.
Wait
()
...
...
@@ -159,7 +159,7 @@ func TestSegmentAllocator2(t *testing.T) {
func
TestSegmentAllocator3
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
dataCoord
:=
&
mockDataCoord2
{}
dataCoord
.
expireTime
=
Timestamp
(
2
500
)
dataCoord
.
expireTime
=
Timestamp
(
500
)
segAllocator
,
err
:=
NewSegIDAssigner
(
ctx
,
dataCoord
,
getLastTick2
)
assert
.
Nil
(
t
,
err
)
wg
:=
&
sync
.
WaitGroup
{}
...
...
@@ -168,11 +168,11 @@ func TestSegmentAllocator3(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
time
.
Sleep
(
time
.
S
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
0
)
time
.
Sleep
(
50
*
time
.
Millis
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
)
assert
.
NotNil
(
t
,
err
)
wg
.
Wait
()
}
...
...
@@ -217,7 +217,7 @@ func (mockD *mockDataCoord3) AssignSegmentID(ctx context.Context, req *datapb.As
func
TestSegmentAllocator4
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
dataCoord
:=
&
mockDataCoord3
{}
dataCoord
.
expireTime
=
Timestamp
(
2
500
)
dataCoord
.
expireTime
=
Timestamp
(
500
)
segAllocator
,
err
:=
NewSegIDAssigner
(
ctx
,
dataCoord
,
getLastTick2
)
assert
.
Nil
(
t
,
err
)
wg
:=
&
sync
.
WaitGroup
{}
...
...
@@ -226,11 +226,11 @@ func TestSegmentAllocator4(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
time
.
Sleep
(
time
.
S
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
0
)
time
.
Sleep
(
50
*
time
.
Millis
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
)
assert
.
NotNil
(
t
,
err
)
wg
.
Wait
()
}
...
...
@@ -252,7 +252,7 @@ func (mockD *mockDataCoord5) AssignSegmentID(ctx context.Context, req *datapb.As
func
TestSegmentAllocator5
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
dataCoord
:=
&
mockDataCoord5
{}
dataCoord
.
expireTime
=
Timestamp
(
2
500
)
dataCoord
.
expireTime
=
Timestamp
(
500
)
segAllocator
,
err
:=
NewSegIDAssigner
(
ctx
,
dataCoord
,
getLastTick2
)
assert
.
Nil
(
t
,
err
)
wg
:=
&
sync
.
WaitGroup
{}
...
...
@@ -261,11 +261,11 @@ func TestSegmentAllocator5(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
time
.
Sleep
(
time
.
S
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
0
)
time
.
Sleep
(
50
*
time
.
Millis
econd
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
"abc"
,
10
,
100
)
assert
.
NotNil
(
t
,
err
)
wg
.
Wait
()
}
...
...
@@ -273,7 +273,7 @@ func TestSegmentAllocator5(t *testing.T) {
func
TestSegmentAllocator6
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
dataCoord
:=
&
mockDataCoord
{}
dataCoord
.
expireTime
=
Timestamp
(
2
500
)
dataCoord
.
expireTime
=
Timestamp
(
500
)
segAllocator
,
err
:=
NewSegIDAssigner
(
ctx
,
dataCoord
,
getLastTick2
)
assert
.
Nil
(
t
,
err
)
wg
:=
&
sync
.
WaitGroup
{}
...
...
@@ -282,7 +282,7 @@ func TestSegmentAllocator6(t *testing.T) {
wg
.
Add
(
1
)
go
func
(
group
*
sync
.
WaitGroup
)
{
defer
group
.
Done
()
time
.
Sleep
(
2
*
time
.
S
econd
)
time
.
Sleep
(
100
*
time
.
Millis
econd
)
segAllocator
.
Close
()
}(
wg
)
success
:=
true
...
...
@@ -300,7 +300,7 @@ func TestSegmentAllocator6(t *testing.T) {
if
i
==
0
{
count
=
0
}
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
colName
,
count
,
100
0
)
_
,
err
=
segAllocator
.
GetSegmentID
(
1
,
1
,
colName
,
count
,
100
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
success
=
false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录