Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
65bb336f
M
milvus
项目概览
milvus
/
milvus
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
65bb336f
编写于
6月 21, 2021
作者:
D
dragondriver
提交者:
GitHub
6月 21, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update auto-id-related test cases (#5915)
Signed-off-by:
N
dragondriver
<
jiquan.long@zilliz.com
>
上级
0300b682
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
33 addition
and
23 deletion
+33
-23
tests/python_test/entity/test_insert.py
tests/python_test/entity/test_insert.py
+29
-21
tests/python_test/utils.py
tests/python_test/utils.py
+4
-2
未找到文件。
tests/python_test/entity/test_insert.py
浏览文件 @
65bb336f
...
@@ -187,7 +187,6 @@ class TestInsertBase:
...
@@ -187,7 +187,6 @@ class TestInsertBase:
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_ids
(
self
,
connect
,
id_collection
,
insert_count
):
def
test_insert_ids
(
self
,
connect
,
id_collection
,
insert_count
):
'''
'''
target: test insert entities in collection, use customize ids
target: test insert entities in collection, use customize ids
...
@@ -196,7 +195,9 @@ class TestInsertBase:
...
@@ -196,7 +195,9 @@ class TestInsertBase:
'''
'''
nb
=
insert_count
nb
=
insert_count
ids
=
[
i
for
i
in
range
(
nb
)]
ids
=
[
i
for
i
in
range
(
nb
)]
res_ids
=
connect
.
insert
(
id_collection
,
gen_entities
(
nb
))
entities
=
gen_entities
(
nb
)
entities
[
0
][
"values"
]
=
ids
res_ids
=
connect
.
insert
(
id_collection
,
entities
)
connect
.
flush
([
id_collection
])
connect
.
flush
([
id_collection
])
assert
len
(
res_ids
)
==
nb
assert
len
(
res_ids
)
==
nb
assert
res_ids
==
ids
assert
res_ids
==
ids
...
@@ -204,7 +205,6 @@ class TestInsertBase:
...
@@ -204,7 +205,6 @@ class TestInsertBase:
assert
stats
[
row_count
]
==
nb
assert
stats
[
row_count
]
==
nb
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_the_same_ids
(
self
,
connect
,
id_collection
,
insert_count
):
def
test_insert_the_same_ids
(
self
,
connect
,
id_collection
,
insert_count
):
'''
'''
target: test insert vectors in collection, use customize the same ids
target: test insert vectors in collection, use customize the same ids
...
@@ -213,7 +213,9 @@ class TestInsertBase:
...
@@ -213,7 +213,9 @@ class TestInsertBase:
'''
'''
nb
=
insert_count
nb
=
insert_count
ids
=
[
1
for
i
in
range
(
nb
)]
ids
=
[
1
for
i
in
range
(
nb
)]
res_ids
=
connect
.
insert
(
id_collection
,
gen_entities
(
nb
),
ids
)
entities
=
gen_entities
(
nb
)
entities
[
0
][
"values"
]
=
ids
res_ids
=
connect
.
insert
(
id_collection
,
entities
)
connect
.
flush
([
id_collection
])
connect
.
flush
([
id_collection
])
assert
len
(
res_ids
)
==
nb
assert
len
(
res_ids
)
==
nb
assert
res_ids
==
ids
assert
res_ids
==
ids
...
@@ -222,7 +224,6 @@ class TestInsertBase:
...
@@ -222,7 +224,6 @@ class TestInsertBase:
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_ids_fields
(
self
,
connect
,
get_filter_field
,
get_vector_field
):
def
test_insert_ids_fields
(
self
,
connect
,
get_filter_field
,
get_vector_field
):
'''
'''
target: test create normal collection with different fields, insert entities into id with ids
target: test create normal collection with different fields, insert entities into id with ids
...
@@ -234,21 +235,20 @@ class TestInsertBase:
...
@@ -234,21 +235,20 @@ class TestInsertBase:
vector_field
=
get_vector_field
vector_field
=
get_vector_field
collection_name
=
gen_unique_str
(
"test_collection"
)
collection_name
=
gen_unique_str
(
"test_collection"
)
fields
=
{
fields
=
{
"fields"
:
[
filter_field
,
vector_field
],
"fields"
:
[
gen_primary_field
(),
filter_field
,
vector_field
],
"auto_id"
:
False
"auto_id"
:
False
}
}
connect
.
create_collection
(
collection_name
,
fields
)
connect
.
create_collection
(
collection_name
,
fields
)
ids
=
[
i
for
i
in
range
(
nb
)]
ids
=
[
i
for
i
in
range
(
nb
)]
entities
=
gen_entities_by_fields
(
fields
[
"fields"
],
nb
,
default_dim
)
entities
=
gen_entities_by_fields
(
fields
[
"fields"
],
nb
,
default_dim
,
ids
)
logging
.
getLogger
().
info
(
entities
)
logging
.
getLogger
().
info
(
entities
)
res_ids
=
connect
.
insert
(
collection_name
,
entities
,
ids
)
res_ids
=
connect
.
insert
(
collection_name
,
entities
)
assert
res_ids
==
ids
assert
res_ids
==
ids
connect
.
flush
([
collection_name
])
connect
.
flush
([
collection_name
])
stats
=
connect
.
get_collection_stats
(
collection_name
)
stats
=
connect
.
get_collection_stats
(
collection_name
)
assert
stats
[
row_count
]
==
nb
assert
stats
[
row_count
]
==
nb
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_ids_not_match
(
self
,
connect
,
id_collection
,
insert_count
):
def
test_insert_ids_not_match
(
self
,
connect
,
id_collection
,
insert_count
):
'''
'''
target: test insert entities in collection without ids
target: test insert entities in collection without ids
...
@@ -257,12 +257,13 @@ class TestInsertBase:
...
@@ -257,12 +257,13 @@ class TestInsertBase:
'''
'''
nb
=
insert_count
nb
=
insert_count
with
pytest
.
raises
(
Exception
)
as
e
:
with
pytest
.
raises
(
Exception
)
as
e
:
connect
.
insert
(
id_collection
,
gen_entities
(
nb
))
entities
=
gen_entities
(
nb
)
del
entities
[
0
]
connect
.
insert
(
id_collection
,
entities
)
# TODO
# TODO
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_twice_ids_no_ids
(
self
,
connect
,
id_collection
):
def
test_insert_twice_ids_no_ids
(
self
,
connect
,
id_collection
):
'''
'''
target: check the result of insert, with params ids and no ids
target: check the result of insert, with params ids and no ids
...
@@ -270,24 +271,27 @@ class TestInsertBase:
...
@@ -270,24 +271,27 @@ class TestInsertBase:
expected: BaseException raised
expected: BaseException raised
'''
'''
ids
=
[
i
for
i
in
range
(
default_nb
)]
ids
=
[
i
for
i
in
range
(
default_nb
)]
connect
.
insert
(
id_collection
,
default_entities
,
ids
)
entities
=
copy
.
deepcopy
(
default_entities
)
entities
[
0
][
"values"
]
=
ids
connect
.
insert
(
id_collection
,
entities
)
with
pytest
.
raises
(
Exception
)
as
e
:
with
pytest
.
raises
(
Exception
)
as
e
:
connect
.
insert
(
id_collection
,
default_entities
)
del
entities
[
0
]
connect
.
insert
(
id_collection
,
entities
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_not_ids
(
self
,
connect
,
id_collection
):
def
test_insert_not_ids
(
self
,
connect
,
id_collection
):
'''
'''
target: check the result of insert, with params ids and no ids
target: check the result of insert, with params ids and no ids
method: test insert vectors twice, use not ids first, and then use customize ids
method: test insert vectors twice, use not ids first, and then use customize ids
expected: error raised
expected: error raised
'''
'''
entities
=
copy
.
deepcopy
(
default_entities
)
del
entities
[
0
]
with
pytest
.
raises
(
Exception
)
as
e
:
with
pytest
.
raises
(
Exception
)
as
e
:
connect
.
insert
(
id_collection
,
default_
entities
)
connect
.
insert
(
id_collection
,
entities
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_ids_length_not_match_batch
(
self
,
connect
,
id_collection
):
def
test_insert_ids_length_not_match_batch
(
self
,
connect
,
id_collection
):
'''
'''
target: test insert vectors in collection, use customize ids, len(ids) != len(vectors)
target: test insert vectors in collection, use customize ids, len(ids) != len(vectors)
...
@@ -296,11 +300,12 @@ class TestInsertBase:
...
@@ -296,11 +300,12 @@ class TestInsertBase:
'''
'''
ids
=
[
i
for
i
in
range
(
1
,
default_nb
)]
ids
=
[
i
for
i
in
range
(
1
,
default_nb
)]
logging
.
getLogger
().
info
(
len
(
ids
))
logging
.
getLogger
().
info
(
len
(
ids
))
entities
=
copy
.
deepcopy
(
default_entities
)
entities
[
0
][
"values"
]
=
ids
with
pytest
.
raises
(
Exception
)
as
e
:
with
pytest
.
raises
(
Exception
)
as
e
:
connect
.
insert
(
id_collection
,
default_entities
,
id
s
)
connect
.
insert
(
id_collection
,
entitie
s
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_ids_length_not_match_single
(
self
,
connect
,
id_collection
):
def
test_insert_ids_length_not_match_single
(
self
,
connect
,
id_collection
):
'''
'''
target: test insert vectors in collection, use customize ids, len(ids) != len(vectors)
target: test insert vectors in collection, use customize ids, len(ids) != len(vectors)
...
@@ -309,8 +314,10 @@ class TestInsertBase:
...
@@ -309,8 +314,10 @@ class TestInsertBase:
'''
'''
ids
=
[
i
for
i
in
range
(
1
,
default_nb
)]
ids
=
[
i
for
i
in
range
(
1
,
default_nb
)]
logging
.
getLogger
().
info
(
len
(
ids
))
logging
.
getLogger
().
info
(
len
(
ids
))
entity
=
copy
.
deepcopy
(
default_entity
)
entity
[
0
][
"values"
]
=
ids
with
pytest
.
raises
(
BaseException
)
as
e
:
with
pytest
.
raises
(
BaseException
)
as
e
:
connect
.
insert
(
id_collection
,
default_entity
,
ids
)
connect
.
insert
(
id_collection
,
entity
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
...
@@ -331,7 +338,6 @@ class TestInsertBase:
...
@@ -331,7 +338,6 @@ class TestInsertBase:
# TODO
# TODO
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
timeout
(
ADD_TIMEOUT
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
tags_smoke
)
@
pytest
.
mark
.
skip
(
"TODO: change these cases to use ids in primary field"
)
def
test_insert_partition_with_ids
(
self
,
connect
,
id_collection
):
def
test_insert_partition_with_ids
(
self
,
connect
,
id_collection
):
'''
'''
target: test insert entities in collection created before, insert with ids
target: test insert entities in collection created before, insert with ids
...
@@ -340,7 +346,9 @@ class TestInsertBase:
...
@@ -340,7 +346,9 @@ class TestInsertBase:
'''
'''
connect
.
create_partition
(
id_collection
,
default_tag
)
connect
.
create_partition
(
id_collection
,
default_tag
)
ids
=
[
i
for
i
in
range
(
default_nb
)]
ids
=
[
i
for
i
in
range
(
default_nb
)]
res_ids
=
connect
.
insert
(
id_collection
,
gen_entities
(
default_nb
),
ids
=
ids
,
partition_name
=
default_tag
)
entities
=
gen_entities
(
default_nb
)
entities
[
0
][
"values"
]
=
ids
res_ids
=
connect
.
insert
(
id_collection
,
entities
,
partition_name
=
default_tag
)
assert
res_ids
==
ids
assert
res_ids
==
ids
logging
.
getLogger
().
info
(
connect
.
describe_collection
(
id_collection
))
logging
.
getLogger
().
info
(
connect
.
describe_collection
(
id_collection
))
...
...
tests/python_test/utils.py
浏览文件 @
65bb336f
...
@@ -361,10 +361,12 @@ def gen_binary_entities_rows(nb, _id=True):
...
@@ -361,10 +361,12 @@ def gen_binary_entities_rows(nb, _id=True):
return
raw_vectors
,
entities
return
raw_vectors
,
entities
def
gen_entities_by_fields
(
fields
,
nb
,
dim
):
def
gen_entities_by_fields
(
fields
,
nb
,
dim
,
ids
=
None
):
entities
=
[]
entities
=
[]
for
field
in
fields
:
for
field
in
fields
:
if
field
[
"type"
]
in
[
DataType
.
INT32
,
DataType
.
INT64
]:
if
field
.
get
(
"is_primary"
,
False
)
and
ids
:
field_value
=
ids
elif
field
[
"type"
]
in
[
DataType
.
INT32
,
DataType
.
INT64
]:
field_value
=
[
1
for
i
in
range
(
nb
)]
field_value
=
[
1
for
i
in
range
(
nb
)]
elif
field
[
"type"
]
in
[
DataType
.
FLOAT
,
DataType
.
DOUBLE
]:
elif
field
[
"type"
]
in
[
DataType
.
FLOAT
,
DataType
.
DOUBLE
]:
field_value
=
[
3.0
for
i
in
range
(
nb
)]
field_value
=
[
3.0
for
i
in
range
(
nb
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录