Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
9ee91b47
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,发现更多精彩内容 >>
提交
9ee91b47
编写于
3月 09, 2020
作者:
X
Xiaohai Xu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change table to collection
Signed-off-by:
N
Xiaohai Xu
<
xiaohaix@student.unimelb.edu.au
>
上级
f3e7e647
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
4252 addition
and
2557 deletion
+4252
-2557
tests/milvus_python_test/conftest.py
tests/milvus_python_test/conftest.py
+5
-5
tests/milvus_python_test/test_add_vectors.py
tests/milvus_python_test/test_add_vectors.py
+404
-404
tests/milvus_python_test/test_collection.py
tests/milvus_python_test/test_collection.py
+1051
-0
tests/milvus_python_test/test_collection_count.py
tests/milvus_python_test/test_collection_count.py
+644
-0
tests/milvus_python_test/test_collection_info.py
tests/milvus_python_test/test_collection_info.py
+82
-82
tests/milvus_python_test/test_compact.py
tests/milvus_python_test/test_compact.py
+384
-384
tests/milvus_python_test/test_config.py
tests/milvus_python_test/test_config.py
+136
-136
tests/milvus_python_test/test_connect.py
tests/milvus_python_test/test_connect.py
+1
-1
tests/milvus_python_test/test_delete_vectors.py
tests/milvus_python_test/test_delete_vectors.py
+139
-139
tests/milvus_python_test/test_flush.py
tests/milvus_python_test/test_flush.py
+74
-74
tests/milvus_python_test/test_get_vector_by_id.py
tests/milvus_python_test/test_get_vector_by_id.py
+95
-95
tests/milvus_python_test/test_get_vector_ids.py
tests/milvus_python_test/test_get_vector_ids.py
+120
-120
tests/milvus_python_test/test_index.py
tests/milvus_python_test/test_index.py
+452
-452
tests/milvus_python_test/test_mix.py
tests/milvus_python_test/test_mix.py
+38
-38
tests/milvus_python_test/test_partition.py
tests/milvus_python_test/test_partition.py
+92
-92
tests/milvus_python_test/test_search_by_id.py
tests/milvus_python_test/test_search_by_id.py
+272
-272
tests/milvus_python_test/test_search_vectors.py
tests/milvus_python_test/test_search_vectors.py
+222
-222
tests/milvus_python_test/test_wal.py
tests/milvus_python_test/test_wal.py
+36
-36
tests/milvus_python_test/utils.py
tests/milvus_python_test/utils.py
+5
-5
未找到文件。
tests/milvus_python_test/conftest.py
浏览文件 @
9ee91b47
...
...
@@ -106,7 +106,7 @@ def table(request, connect):
def
teardown
():
status
,
table_names
=
connect
.
show_tables
()
for
table_name
in
table_names
:
connect
.
d
elete_table
(
table_name
)
connect
.
d
rop_collection
(
table_name
)
request
.
addfinalizer
(
teardown
)
...
...
@@ -130,7 +130,7 @@ def ip_table(request, connect):
def
teardown
():
status
,
table_names
=
connect
.
show_tables
()
for
table_name
in
table_names
:
connect
.
d
elete_table
(
table_name
)
connect
.
d
rop_collection
(
table_name
)
request
.
addfinalizer
(
teardown
)
...
...
@@ -154,7 +154,7 @@ def jac_table(request, connect):
def
teardown
():
status
,
table_names
=
connect
.
show_tables
()
for
table_name
in
table_names
:
connect
.
d
elete_table
(
table_name
)
connect
.
d
rop_collection
(
table_name
)
request
.
addfinalizer
(
teardown
)
...
...
@@ -177,7 +177,7 @@ def ham_table(request, connect):
def
teardown
():
status
,
table_names
=
connect
.
show_tables
()
for
table_name
in
table_names
:
connect
.
d
elete_table
(
table_name
)
connect
.
d
rop_collection
(
table_name
)
request
.
addfinalizer
(
teardown
)
...
...
@@ -200,7 +200,7 @@ def tanimoto_table(request, connect):
def
teardown
():
status
,
table_names
=
connect
.
show_tables
()
for
table_name
in
table_names
:
connect
.
d
elete_table
(
table_name
)
connect
.
d
rop_collection
(
table_name
)
request
.
addfinalizer
(
teardown
)
...
...
tests/milvus_python_test/test_add_vectors.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
.py
→
tests/milvus_python_test/test_
collection
.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
_count.py
→
tests/milvus_python_test/test_
collection
_count.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
_info.py
→
tests/milvus_python_test/test_
collection
_info.py
浏览文件 @
9ee91b47
...
...
@@ -18,7 +18,7 @@ nb = 6000
nlist
=
1024
class
Test
Table
InfoBase
:
class
Test
Collection
InfoBase
:
def
index_string_convert
(
self
,
index_string
,
index_type
):
if
index_string
==
"IDMAP"
and
index_type
==
IndexType
.
FLAT
:
return
True
...
...
@@ -30,87 +30,87 @@ class TestTableInfoBase:
"""
******************************************************************
The following cases are used to test `
table
_info` function
The following cases are used to test `
collection
_info` function
******************************************************************
"""
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_name_None
(
self
,
connect
,
table
):
def
test_get_
collection_info_name_None
(
self
,
connect
,
collection
):
'''
target: get
table info where table
name is None
method: call
table_info with the table
_name: None
target: get
collection info where collection
name is None
method: call
collection_info with the collection
_name: None
expected: status not ok
'''
table
_name
=
None
status
,
info
=
connect
.
table_info
(
table
_name
)
collection
_name
=
None
status
,
info
=
connect
.
collection_info
(
collection
_name
)
assert
not
status
.
OK
()
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_name_not_existed
(
self
,
connect
,
table
):
def
test_get_
collection_info_name_not_existed
(
self
,
connect
,
collection
):
'''
target: get
table info where table
name does not exist
method: call
table_info with a random table
_name, which is not in db
target: get
collection info where collection
name does not exist
method: call
collection_info with a random collection
_name, which is not in db
expected: status not ok
'''
table_name
=
gen_unique_str
(
"not_existed_table
"
)
status
,
info
=
connect
.
table_info
(
table
_name
)
collection_name
=
gen_unique_str
(
"not_existed_collection
"
)
status
,
info
=
connect
.
collection_info
(
collection
_name
)
assert
not
status
.
OK
()
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
gen_invalid_
table
_names
()
params
=
gen_invalid_
collection
_names
()
)
def
get_
table
_name
(
self
,
request
):
def
get_
collection
_name
(
self
,
request
):
yield
request
.
param
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_name_invalid
(
self
,
connect
,
get_table
_name
):
def
test_get_
collection_info_name_invalid
(
self
,
connect
,
get_collection
_name
):
'''
target: get
table info where table
name is invalid
method: call
table_info with invalid table
_name
target: get
collection info where collection
name is invalid
method: call
collection_info with invalid collection
_name
expected: status not ok
'''
table_name
=
get_table
_name
status
,
info
=
connect
.
table_info
(
table
_name
)
collection_name
=
get_collection
_name
status
,
info
=
connect
.
collection_info
(
collection
_name
)
assert
not
status
.
OK
()
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_table_row_count
(
self
,
connect
,
table
):
def
test_get_
collection_info_collection_row_count
(
self
,
connect
,
collection
):
'''
target: get row count with
table
_info
method: add and delete vectors, check count in
table
info
target: get row count with
collection
_info
method: add and delete vectors, check count in
collection
info
expected: status ok, count as expected
'''
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
assert
info
.
count
==
nb
# delete a few vectors
delete_ids
=
[
ids
[
0
],
ids
[
-
1
]]
status
=
connect
.
delete_by_id
(
table
,
delete_ids
)
status
=
connect
.
delete_by_id
(
collection
,
delete_ids
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
assert
info
.
count
==
nb
-
2
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_partition_stats_A
(
self
,
connect
,
table
):
def
test_get_
collection_info_partition_stats_A
(
self
,
connect
,
collection
):
'''
target: get partition info in a
table
method: no partition, call
table
_info and check partition_stats
target: get partition info in a
collection
method: no partition, call
collection
_info and check partition_stats
expected: status ok, "_default" partition is listed
'''
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
assert
len
(
info
.
partitions_stat
)
==
1
...
...
@@ -119,19 +119,19 @@ class TestTableInfoBase:
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_partition_stats_B
(
self
,
connect
,
table
):
def
test_get_
collection_info_partition_stats_B
(
self
,
connect
,
collection
):
'''
target: get partition info in a
table
method: call
table
_info after partition created and check partition_stats
target: get partition info in a
collection
method: call
collection
_info after partition created and check partition_stats
expected: status ok, vectors added to partition
'''
vectors
=
gen_vectors
(
nb
,
dim
)
status
=
connect
.
create_partition
(
table
,
tag
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
partition_tag
=
tag
)
status
=
connect
.
create_partition
(
collection
,
tag
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
partition_tag
=
tag
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
assert
len
(
info
.
partitions_stat
)
==
2
...
...
@@ -139,23 +139,23 @@ class TestTableInfoBase:
assert
info
.
partitions_stat
[
1
].
count
==
nb
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_partition_stats_C
(
self
,
connect
,
table
):
def
test_get_
collection_info_partition_stats_C
(
self
,
connect
,
collection
):
'''
target: get partition info in a
table
method: create two partitions, add vectors in one of the partitions, call
table
_info and check
target: get partition info in a
collection
method: create two partitions, add vectors in one of the partitions, call
collection
_info and check
expected: status ok, vectors added to one partition but not the other
'''
new_tag
=
"new_tag"
vectors
=
gen_vectors
(
nb
,
dim
)
status
=
connect
.
create_partition
(
table
,
tag
)
status
=
connect
.
create_partition
(
collection
,
tag
)
assert
status
.
OK
()
status
=
connect
.
create_partition
(
table
,
new_tag
)
status
=
connect
.
create_partition
(
collection
,
new_tag
)
assert
status
.
OK
()
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
partition_tag
=
tag
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
for
partition
in
info
.
partitions_stat
:
...
...
@@ -165,25 +165,25 @@ class TestTableInfoBase:
assert
partition
.
count
==
0
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_partition_stats_D
(
self
,
connect
,
table
):
def
test_get_
collection_info_partition_stats_D
(
self
,
connect
,
collection
):
'''
target: get partition info in a
table
method: create two partitions, add vectors in both partitions, call
table
_info and check
target: get partition info in a
collection
method: create two partitions, add vectors in both partitions, call
collection
_info and check
expected: status ok, vectors added to both partitions
'''
new_tag
=
"new_tag"
vectors
=
gen_vectors
(
nb
,
dim
)
status
=
connect
.
create_partition
(
table
,
tag
)
status
=
connect
.
create_partition
(
collection
,
tag
)
assert
status
.
OK
()
status
=
connect
.
create_partition
(
table
,
new_tag
)
status
=
connect
.
create_partition
(
collection
,
new_tag
)
assert
status
.
OK
()
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
partition_tag
=
tag
)
assert
status
.
OK
()
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
partition_tag
=
new_tag
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
partition_tag
=
new_tag
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
assert
info
.
count
==
nb
*
2
for
partition
in
info
.
partitions_stat
:
...
...
@@ -205,24 +205,24 @@ class TestTableInfoBase:
return
request
.
param
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_after_index_created
(
self
,
connect
,
table
,
get_simple_index
):
def
test_get_
collection_info_after_index_created
(
self
,
connect
,
collection
,
get_simple_index
):
'''
target: test
table
info after index created
method: create
table, add vectors, create index and call table
_info
target: test
collection
info after index created
method: create
collection, add vectors, create index and call collection
_info
expected: status ok, index created and shown in segments_stat
'''
index_param
=
get_simple_index
[
"index_param"
]
index_type
=
get_simple_index
[
"index_type"
]
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
collection
,
index_type
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
index_string
=
info
.
partitions_stat
[
0
].
segments_stat
[
0
].
index_name
...
...
@@ -231,24 +231,24 @@ class TestTableInfoBase:
assert
nb
==
info
.
partitions_stat
[
0
].
segments_stat
[
0
].
count
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_after_create_same_index_repeatedly
(
self
,
connect
,
table
,
get_simple_index
):
def
test_get_
collection_info_after_create_same_index_repeatedly
(
self
,
connect
,
collection
,
get_simple_index
):
'''
target: test
table
info after index created repeatedly
method: create
table, add vectors, create index and call table
_info multiple times
target: test
collection
info after index created repeatedly
method: create
collection, add vectors, create index and call collection
_info multiple times
expected: status ok, index info shown in segments_stat
'''
index_param
=
get_simple_index
[
"index_param"
]
index_type
=
get_simple_index
[
"index_type"
]
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
table
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
table
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
collection
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
collection
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
collection
,
index_type
,
index_param
)
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
index_string
=
info
.
partitions_stat
[
0
].
segments_stat
[
0
].
index_name
...
...
@@ -257,22 +257,22 @@ class TestTableInfoBase:
assert
nb
==
info
.
partitions_stat
[
0
].
segments_stat
[
0
].
count
@
pytest
.
mark
.
timeout
(
INFO_TIMEOUT
)
def
test_get_
table_info_after_create_different_index_repeatedly
(
self
,
connect
,
table
,
get_simple_index
):
def
test_get_
collection_info_after_create_different_index_repeatedly
(
self
,
connect
,
collection
,
get_simple_index
):
'''
target: test
table
info after index created repeatedly
method: create
table, add vectors, create index and call table
_info multiple times
target: test
collection
info after index created repeatedly
method: create
collection, add vectors, create index and call collection
_info multiple times
expected: status ok, index info shown in segments_stat
'''
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
index_param
=
{
"nlist"
:
nlist
}
for
index_type
in
[
IndexType
.
FLAT
,
IndexType
.
IVFLAT
,
IndexType
.
IVF_SQ8
]:
status
=
connect
.
create_index
(
table
,
index_type
,
index_param
)
status
=
connect
.
create_index
(
collection
,
index_type
,
index_param
)
assert
status
.
OK
()
status
,
info
=
connect
.
table_info
(
table
)
status
,
info
=
connect
.
collection_info
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
info
)
index_string
=
info
.
partitions_stat
[
0
].
segments_stat
[
0
].
index_name
...
...
tests/milvus_python_test/test_compact.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_config.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_connect.py
浏览文件 @
9ee91b47
...
...
@@ -285,7 +285,7 @@ class TestConnect:
b. data_set not too large incase disconnection happens when data is underd-preparing
c. data_set not too small incase disconnection happens when data has already been transferred
d. make sure disconnection happens when data is in-transport
Expected: Failure,
get_table_row_count
== 0
Expected: Failure,
count_collection
== 0
'''
pass
...
...
tests/milvus_python_test/test_delete_vectors.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_flush.py
浏览文件 @
9ee91b47
...
...
@@ -10,7 +10,7 @@ from utils import *
dim
=
128
index_file_size
=
10
table
_id
=
"test_flush"
collection
_id
=
"test_flush"
DELETE_TIMEOUT
=
60
nprobe
=
1
tag
=
"1970-01-01"
...
...
@@ -38,117 +38,117 @@ class TestFlushBase:
pytest
.
skip
(
"Only support CPU mode"
)
return
request
.
param
def
test_flush_
table_not_existed
(
self
,
connect
,
table
):
def
test_flush_
collection_not_existed
(
self
,
connect
,
collection
):
'''
target: test delete vector, params
table
_name not existed
target: test delete vector, params
collection
_name not existed
method: add vector and delete
expected: status not ok
'''
table
_new
=
gen_unique_str
()
status
=
connect
.
flush
([
table
_new
])
collection
_new
=
gen_unique_str
()
status
=
connect
.
flush
([
collection
_new
])
assert
not
status
.
OK
()
def
test_flush_empty_
table
(
self
,
connect
,
table
):
def
test_flush_empty_
collection
(
self
,
connect
,
collection
):
'''
method: flush
table
with no vectors
method: flush
collection
with no vectors
expected: status ok
'''
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
def
test_add_partition_flush
(
self
,
connect
,
table
):
def
test_add_partition_flush
(
self
,
connect
,
collection
):
'''
method: add vectors into partition in
table
, flush serveral times
method: add vectors into partition in
collection
, flush serveral times
expected: status ok
'''
vectors
=
gen_vector
(
nb
,
dim
)
status
=
connect
.
create_partition
(
table
,
tag
)
status
=
connect
.
create_partition
(
collection
,
tag
)
vectors
=
gen_vectors
(
nb
,
dim
)
ids
=
[
i
for
i
in
range
(
nb
)]
status
,
ids
=
connect
.
insert
(
table
,
vectors
,
ids
)
status
=
connect
.
flush
([
table
])
result
,
res
=
connect
.
get_table_row_count
(
table
)
status
,
ids
=
connect
.
insert
(
collection
,
vectors
,
ids
)
status
=
connect
.
flush
([
collection
])
result
,
res
=
connect
.
count_collection
(
collection
)
assert
res
==
nb
status
,
ids
=
connect
.
insert
(
table
,
vectors
,
ids
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
insert
(
collection
,
vectors
,
ids
,
partition_tag
=
tag
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
result
,
res
=
connect
.
get_table_row_count
(
table
)
result
,
res
=
connect
.
count_collection
(
collection
)
assert
res
==
2
*
nb
def
test_add_partitions_flush
(
self
,
connect
,
table
):
def
test_add_partitions_flush
(
self
,
connect
,
collection
):
'''
method: add vectors into partitions in
table
, flush one
method: add vectors into partitions in
collection
, flush one
expected: status ok
'''
vectors
=
gen_vectors
(
nb
,
dim
)
tag_new
=
gen_unique_str
()
status
=
connect
.
create_partition
(
table
,
tag
)
status
=
connect
.
create_partition
(
table
,
tag_new
)
status
=
connect
.
create_partition
(
collection
,
tag
)
status
=
connect
.
create_partition
(
collection
,
tag_new
)
ids
=
[
i
for
i
in
range
(
nb
)]
status
,
ids
=
connect
.
insert
(
table
,
vectors
,
ids
,
partition_tag
=
tag
)
status
=
connect
.
flush
([
table
])
status
,
ids
=
connect
.
insert
(
collection
,
vectors
,
ids
,
partition_tag
=
tag
)
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
ids
=
connect
.
insert
(
table
,
vectors
,
ids
,
partition_tag
=
tag_new
)
status
,
ids
=
connect
.
insert
(
collection
,
vectors
,
ids
,
partition_tag
=
tag_new
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
result
,
res
=
connect
.
get_table_row_count
(
table
)
result
,
res
=
connect
.
count_collection
(
collection
)
assert
res
==
2
*
nb
def
test_add_
tables_flush
(
self
,
connect
,
table
):
def
test_add_
collections_flush
(
self
,
connect
,
collection
):
'''
method: add vectors into
table
s, flush one
method: add vectors into
collection
s, flush one
expected: status ok
'''
vectors
=
gen_vectors
(
nb
,
dim
)
table
_new
=
gen_unique_str
()
param
=
{
'
table_name'
:
table
_new
,
collection
_new
=
gen_unique_str
()
param
=
{
'
collection_name'
:
collection
_new
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
L2
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_partition
(
table
,
tag
)
status
=
connect
.
create_partition
(
table
_new
,
tag
)
status
=
connect
.
create_
collection
(
param
)
status
=
connect
.
create_partition
(
collection
,
tag
)
status
=
connect
.
create_partition
(
collection
_new
,
tag
)
vectors
=
gen_vectors
(
nb
,
dim
)
ids
=
[
i
for
i
in
range
(
nb
)]
status
,
ids
=
connect
.
insert
(
table
,
vectors
,
ids
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
insert
(
table
_new
,
vectors
,
ids
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
insert
(
collection
,
vectors
,
ids
,
partition_tag
=
tag
)
status
,
ids
=
connect
.
insert
(
collection
_new
,
vectors
,
ids
,
partition_tag
=
tag
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
table
_new
])
status
=
connect
.
flush
([
collection
])
status
=
connect
.
flush
([
collection
_new
])
assert
status
.
OK
()
result
,
res
=
connect
.
get_table_row_count
(
table
)
result
,
res
=
connect
.
count_collection
(
collection
)
assert
res
==
nb
result
,
res
=
connect
.
get_table_row_count
(
table
_new
)
result
,
res
=
connect
.
count_collection
(
collection
_new
)
assert
res
==
nb
def
test_add_flush_multiable_times
(
self
,
connect
,
table
):
def
test_add_flush_multiable_times
(
self
,
connect
,
collection
):
'''
method: add vectors, flush serveral times
expected: status ok
'''
vectors
=
gen_vectors
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
for
i
in
range
(
10
):
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
query_vecs
=
[
vectors
[
0
],
vectors
[
1
],
vectors
[
-
1
]]
status
,
res
=
connect
.
search_vectors
(
table
,
top_k
,
query_records
=
query_vecs
)
status
,
res
=
connect
.
search_vectors
(
collection
,
top_k
,
query_records
=
query_vecs
)
assert
status
.
OK
()
def
test_add_flush_auto
(
self
,
connect
,
table
):
def
test_add_flush_auto
(
self
,
connect
,
collection
):
'''
method: add vectors
expected: status ok
'''
vectors
=
gen_vectors
(
nb
,
dim
)
ids
=
[
i
for
i
in
range
(
nb
)]
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
ids
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
ids
)
assert
status
.
OK
()
time
.
sleep
(
2
)
status
,
res
=
connect
.
get_table_row_count
(
table
)
status
,
res
=
connect
.
count_collection
(
collection
)
assert
status
.
OK
()
assert
res
==
nb
...
...
@@ -163,7 +163,7 @@ class TestFlushBase:
yield
request
.
param
# both autoflush / flush
def
test_add_flush_same_ids
(
self
,
connect
,
table
,
same_ids
):
def
test_add_flush_same_ids
(
self
,
connect
,
collection
,
same_ids
):
'''
method: add vectors, with same ids, count(same ids) < 15, > 15
expected: status ok
...
...
@@ -173,79 +173,79 @@ class TestFlushBase:
for
i
,
item
in
enumerate
(
ids
):
if
item
<=
same_ids
:
ids
[
i
]
=
0
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
,
ids
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
,
ids
)
time
.
sleep
(
2
)
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
status
,
res
=
connect
.
get_table_row_count
(
table
)
status
,
res
=
connect
.
count_collection
(
collection
)
assert
status
.
OK
()
assert
res
==
nb
def
test_delete_flush_multiable_times
(
self
,
connect
,
table
):
def
test_delete_flush_multiable_times
(
self
,
connect
,
collection
):
'''
method: delete vectors, flush serveral times
expected: status ok
'''
vectors
=
gen_vectors
(
nb
,
dim
)
status
,
ids
=
connect
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
connect
.
add_vectors
(
collection
,
vectors
)
assert
status
.
OK
()
status
=
connect
.
delete_by_id
(
table
,
[
ids
[
-
1
]])
status
=
connect
.
delete_by_id
(
collection
,
[
ids
[
-
1
]])
assert
status
.
OK
()
for
i
in
range
(
10
):
status
=
connect
.
flush
([
table
])
status
=
connect
.
flush
([
collection
])
assert
status
.
OK
()
query_vecs
=
[
vectors
[
0
],
vectors
[
1
],
vectors
[
-
1
]]
status
,
res
=
connect
.
search_vectors
(
table
,
top_k
,
query_records
=
query_vecs
)
status
,
res
=
connect
.
search_vectors
(
collection
,
top_k
,
query_records
=
query_vecs
)
assert
status
.
OK
()
# TODO: CI fail, LOCAL pass
def
_test_
table
_count_during_flush
(
self
,
connect
,
args
):
def
_test_
collection
_count_during_flush
(
self
,
connect
,
args
):
'''
method: flush
table at background, call `get_table_row_count
`
method: flush
collection at background, call `count_collection
`
expected: status ok
'''
table
=
gen_unique_str
()
collection
=
gen_unique_str
()
uri
=
"tcp://%s:%s"
%
(
args
[
"ip"
],
args
[
"port"
])
param
=
{
'
table_name'
:
table
,
param
=
{
'
collection_name'
:
collection
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
L2
}
milvus
=
get_milvus
()
milvus
.
connect
(
uri
=
uri
)
milvus
.
create_
table
(
param
)
milvus
.
create_
collection
(
param
)
vectors
=
gen_vector
(
nb
,
dim
)
status
,
ids
=
milvus
.
add_vectors
(
table
,
vectors
,
ids
=
[
i
for
i
in
range
(
nb
)])
def
flush
(
table
_name
):
status
,
ids
=
milvus
.
add_vectors
(
collection
,
vectors
,
ids
=
[
i
for
i
in
range
(
nb
)])
def
flush
(
collection
_name
):
milvus
=
get_milvus
()
milvus
.
connect
(
uri
=
uri
)
status
=
milvus
.
delete_by_id
(
table
_name
,
[
i
for
i
in
range
(
nb
)])
status
=
milvus
.
delete_by_id
(
collection
_name
,
[
i
for
i
in
range
(
nb
)])
assert
status
.
OK
()
status
=
milvus
.
flush
([
table
_name
])
status
=
milvus
.
flush
([
collection
_name
])
assert
status
.
OK
()
p
=
Process
(
target
=
flush
,
args
=
(
table
,
))
p
=
Process
(
target
=
flush
,
args
=
(
collection
,
))
p
.
start
()
status
,
res
=
milvus
.
get_table_row_count
(
table
)
status
,
res
=
milvus
.
count_collection
(
collection
)
assert
status
.
OK
()
p
.
join
()
status
,
res
=
milvus
.
get_table_row_count
(
table
)
status
,
res
=
milvus
.
count_collection
(
collection
)
assert
status
.
OK
()
logging
.
getLogger
().
info
(
res
)
assert
res
==
0
class
Test
Table
NameInvalid
(
object
):
class
Test
collection
NameInvalid
(
object
):
"""
Test adding vectors with invalid
table
names
Test adding vectors with invalid
collection
names
"""
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
gen_invalid_
table
_names
()
params
=
gen_invalid_
collection
_names
()
)
def
get_
table
_name
(
self
,
request
):
def
get_
collection
_name
(
self
,
request
):
yield
request
.
param
@
pytest
.
mark
.
level
(
2
)
def
test_flush_with_invalid_
table_name
(
self
,
connect
,
get_table
_name
):
table_name
=
get_table
_name
def
test_flush_with_invalid_
collection_name
(
self
,
connect
,
get_collection
_name
):
collection_name
=
get_collection
_name
with
pytest
.
raises
(
Exception
)
as
e
:
status
,
result
=
connect
.
flush
(
table
_name
)
status
,
result
=
connect
.
flush
(
collection
_name
)
tests/milvus_python_test/test_get_vector_by_id.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_get_vector_ids.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_index.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_mix.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_partition.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_search_by_id.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_search_vectors.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_wal.py
浏览文件 @
9ee91b47
此差异已折叠。
点击以展开。
tests/milvus_python_test/utils.py
浏览文件 @
9ee91b47
...
...
@@ -146,8 +146,8 @@ def gen_invalid_uris():
return
uris
def
gen_invalid_
table
_names
():
table
_names
=
[
def
gen_invalid_
collection
_names
():
collection
_names
=
[
"12-s"
,
"12/s"
,
" "
,
...
...
@@ -166,7 +166,7 @@ def gen_invalid_table_names():
"中文"
,
"a"
.
join
(
"a"
for
i
in
range
(
256
))
]
return
table
_names
return
collection
_names
def
gen_invalid_top_ks
():
...
...
@@ -617,8 +617,8 @@ def get_search_param(index_type):
logging
.
getLogger
().
info
(
"Invalid index_type."
)
def
assert_has_
table
(
conn
,
table
_name
):
status
,
ok
=
conn
.
has_
table
(
table
_name
)
def
assert_has_
collection
(
conn
,
collection
_name
):
status
,
ok
=
conn
.
has_
collection
(
collection
_name
)
return
status
.
OK
()
and
ok
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录