Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
58dde9cd
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
Fork自
milvus / milvus
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
58dde9cd
编写于
3月 11, 2020
作者:
J
JinHai-CN
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/milvus-io/milvus
上级
87b6ee6a
6cd77b35
变更
19
展开全部
隐藏空白更改
内联
并排
Showing
19 changed file
with
5166 addition
and
2568 deletion
+5166
-2568
tests/milvus_python_test/conftest.py
tests/milvus_python_test/conftest.py
+50
-50
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
+1001
-98
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
+9
-9
未找到文件。
tests/milvus_python_test/conftest.py
浏览文件 @
58dde9cd
...
...
@@ -90,118 +90,118 @@ def milvus(request):
@
pytest
.
fixture
(
scope
=
"function"
)
def
table
(
request
,
connect
):
ori_
table_name
=
getattr
(
request
.
module
,
"table
_id"
,
"test"
)
table_name
=
gen_unique_str
(
ori_table
_name
)
def
collection
(
request
,
connect
):
ori_
collection_name
=
getattr
(
request
.
module
,
"collection
_id"
,
"test"
)
collection_name
=
gen_unique_str
(
ori_collection
_name
)
dim
=
getattr
(
request
.
module
,
"dim"
,
"128"
)
param
=
{
'
table_name'
:
table
_name
,
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
L2
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_
collection
(
param
)
# logging.getLogger().info(status)
if
not
status
.
OK
():
pytest
.
exit
(
"
Table
can not be created, exit pytest ..."
)
pytest
.
exit
(
"
collection
can not be created, exit pytest ..."
)
def
teardown
():
status
,
table_names
=
connect
.
show_table
s
()
for
table_name
in
table
_names
:
connect
.
d
elete_table
(
table
_name
)
status
,
collection_names
=
connect
.
show_collection
s
()
for
collection_name
in
collection
_names
:
connect
.
d
rop_collection
(
collection
_name
)
request
.
addfinalizer
(
teardown
)
return
table
_name
return
collection
_name
@
pytest
.
fixture
(
scope
=
"function"
)
def
ip_
table
(
request
,
connect
):
ori_
table_name
=
getattr
(
request
.
module
,
"table
_id"
,
"test"
)
table_name
=
gen_unique_str
(
ori_table
_name
)
def
ip_
collection
(
request
,
connect
):
ori_
collection_name
=
getattr
(
request
.
module
,
"collection
_id"
,
"test"
)
collection_name
=
gen_unique_str
(
ori_collection
_name
)
dim
=
getattr
(
request
.
module
,
"dim"
,
"128"
)
param
=
{
'
table_name'
:
table
_name
,
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
IP
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_
collection
(
param
)
# logging.getLogger().info(status)
if
not
status
.
OK
():
pytest
.
exit
(
"
Table
can not be created, exit pytest ..."
)
pytest
.
exit
(
"
collection
can not be created, exit pytest ..."
)
def
teardown
():
status
,
table_names
=
connect
.
show_table
s
()
for
table_name
in
table
_names
:
connect
.
d
elete_table
(
table
_name
)
status
,
collection_names
=
connect
.
show_collection
s
()
for
collection_name
in
collection
_names
:
connect
.
d
rop_collection
(
collection
_name
)
request
.
addfinalizer
(
teardown
)
return
table
_name
return
collection
_name
@
pytest
.
fixture
(
scope
=
"function"
)
def
jac_
table
(
request
,
connect
):
ori_
table_name
=
getattr
(
request
.
module
,
"table
_id"
,
"test"
)
table_name
=
gen_unique_str
(
ori_table
_name
)
def
jac_
collection
(
request
,
connect
):
ori_
collection_name
=
getattr
(
request
.
module
,
"collection
_id"
,
"test"
)
collection_name
=
gen_unique_str
(
ori_collection
_name
)
dim
=
getattr
(
request
.
module
,
"dim"
,
"128"
)
param
=
{
'
table_name'
:
table
_name
,
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
JACCARD
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_
collection
(
param
)
# logging.getLogger().info(status)
if
not
status
.
OK
():
pytest
.
exit
(
"
Table
can not be created, exit pytest ..."
)
pytest
.
exit
(
"
collection
can not be created, exit pytest ..."
)
def
teardown
():
status
,
table_names
=
connect
.
show_table
s
()
for
table_name
in
table
_names
:
connect
.
d
elete_table
(
table
_name
)
status
,
collection_names
=
connect
.
show_collection
s
()
for
collection_name
in
collection
_names
:
connect
.
d
rop_collection
(
collection
_name
)
request
.
addfinalizer
(
teardown
)
return
table
_name
return
collection
_name
@
pytest
.
fixture
(
scope
=
"function"
)
def
ham_
table
(
request
,
connect
):
ori_
table_name
=
getattr
(
request
.
module
,
"table
_id"
,
"test"
)
table_name
=
gen_unique_str
(
ori_table
_name
)
def
ham_
collection
(
request
,
connect
):
ori_
collection_name
=
getattr
(
request
.
module
,
"collection
_id"
,
"test"
)
collection_name
=
gen_unique_str
(
ori_collection
_name
)
dim
=
getattr
(
request
.
module
,
"dim"
,
"128"
)
param
=
{
'
table_name'
:
table
_name
,
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
HAMMING
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_
collection
(
param
)
# logging.getLogger().info(status)
if
not
status
.
OK
():
pytest
.
exit
(
"
Table
can not be created, exit pytest ..."
)
pytest
.
exit
(
"
collection
can not be created, exit pytest ..."
)
def
teardown
():
status
,
table_names
=
connect
.
show_table
s
()
for
table_name
in
table
_names
:
connect
.
d
elete_table
(
table
_name
)
status
,
collection_names
=
connect
.
show_collection
s
()
for
collection_name
in
collection
_names
:
connect
.
d
rop_collection
(
collection
_name
)
request
.
addfinalizer
(
teardown
)
return
table
_name
return
collection
_name
@
pytest
.
fixture
(
scope
=
"function"
)
def
tanimoto_
table
(
request
,
connect
):
ori_
table_name
=
getattr
(
request
.
module
,
"table
_id"
,
"test"
)
table_name
=
gen_unique_str
(
ori_table
_name
)
def
tanimoto_
collection
(
request
,
connect
):
ori_
collection_name
=
getattr
(
request
.
module
,
"collection
_id"
,
"test"
)
collection_name
=
gen_unique_str
(
ori_collection
_name
)
dim
=
getattr
(
request
.
module
,
"dim"
,
"128"
)
param
=
{
'
table_name'
:
table
_name
,
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
TANIMOTO
}
status
=
connect
.
create_
table
(
param
)
status
=
connect
.
create_
collection
(
param
)
# logging.getLogger().info(status)
if
not
status
.
OK
():
pytest
.
exit
(
"
Table
can not be created, exit pytest ..."
)
pytest
.
exit
(
"
collection
can not be created, exit pytest ..."
)
def
teardown
():
status
,
table_names
=
connect
.
show_table
s
()
for
table_name
in
table
_names
:
connect
.
d
elete_table
(
table
_name
)
status
,
collection_names
=
connect
.
show_collection
s
()
for
collection_name
in
collection
_names
:
connect
.
d
rop_collection
(
collection
_name
)
request
.
addfinalizer
(
teardown
)
return
table_name
\ No newline at end of file
return
collection_name
tests/milvus_python_test/test_add_vectors.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
.py
→
tests/milvus_python_test/test_
collection
.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
_count.py
→
tests/milvus_python_test/test_
collection
_count.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_
table
_info.py
→
tests/milvus_python_test/test_
collection
_info.py
浏览文件 @
58dde9cd
...
...
@@ -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
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_config.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_connect.py
浏览文件 @
58dde9cd
...
...
@@ -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
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_flush.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_get_vector_by_id.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_get_vector_ids.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_index.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_mix.py
浏览文件 @
58dde9cd
...
...
@@ -12,7 +12,7 @@ from utils import *
dim
=
128
index_file_size
=
10
table
_id
=
"test_mix"
collection
_id
=
"test_mix"
add_interval_time
=
2
vectors
=
gen_vectors
(
10000
,
dim
)
vectors
=
sklearn
.
preprocessing
.
normalize
(
vectors
,
axis
=
1
,
norm
=
'l2'
)
...
...
@@ -29,35 +29,35 @@ class TestMixBase:
# disable
def
_test_search_during_createIndex
(
self
,
args
):
loops
=
10000
table
=
gen_unique_str
()
collection
=
gen_unique_str
()
query_vecs
=
[
vectors
[
0
],
vectors
[
1
]]
uri
=
"tcp://%s:%s"
%
(
args
[
"ip"
],
args
[
"port"
])
id_0
=
0
;
id_1
=
0
milvus_instance
=
get_milvus
(
args
[
"handler"
])
milvus_instance
.
connect
(
uri
=
uri
)
milvus_instance
.
create_
table
({
'table_name'
:
table
,
milvus_instance
.
create_
collection
({
'collection_name'
:
collection
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
L2
})
for
i
in
range
(
10
):
status
,
ids
=
milvus_instance
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
milvus_instance
.
add_vectors
(
collection
,
vectors
)
# logging.getLogger().info(ids)
if
i
==
0
:
id_0
=
ids
[
0
];
id_1
=
ids
[
1
]
def
create_index
(
milvus_instance
):
logging
.
getLogger
().
info
(
"In create index"
)
status
=
milvus_instance
.
create_index
(
table
,
index_params
)
status
=
milvus_instance
.
create_index
(
collection
,
index_params
)
logging
.
getLogger
().
info
(
status
)
status
,
result
=
milvus_instance
.
describe_index
(
table
)
status
,
result
=
milvus_instance
.
describe_index
(
collection
)
logging
.
getLogger
().
info
(
result
)
def
add_vectors
(
milvus_instance
):
logging
.
getLogger
().
info
(
"In add vectors"
)
status
,
ids
=
milvus_instance
.
add_vectors
(
table
,
vectors
)
status
,
ids
=
milvus_instance
.
add_vectors
(
collection
,
vectors
)
logging
.
getLogger
().
info
(
status
)
def
search
(
milvus_instance
):
logging
.
getLogger
().
info
(
"In search vectors"
)
for
i
in
range
(
loops
):
status
,
result
=
milvus_instance
.
search_vectors
(
table
,
top_k
,
nprobe
,
query_vecs
)
status
,
result
=
milvus_instance
.
search_vectors
(
collection
,
top_k
,
nprobe
,
query_vecs
)
logging
.
getLogger
().
info
(
status
)
assert
result
[
0
][
0
].
id
==
id_0
assert
result
[
1
][
0
].
id
==
id_1
...
...
@@ -72,82 +72,82 @@ class TestMixBase:
p_create
.
join
()
@
pytest
.
mark
.
level
(
2
)
def
test_mix_multi_
table
s
(
self
,
connect
):
def
test_mix_multi_
collection
s
(
self
,
connect
):
'''
target: test functions with multiple
table
s of different metric_types and index_types
method: create 60
table
s which 30 are L2 and the other are IP, add vectors into them
target: test functions with multiple
collection
s of different metric_types and index_types
method: create 60
collection
s which 30 are L2 and the other are IP, add vectors into them
and test describe index and search
expected: status ok
'''
nq
=
10000
table
_list
=
[]
collection
_list
=
[]
idx
=
[]
index_param
=
{
'nlist'
:
nlist
}
#create
table
and add vectors
#create
collection
and add vectors
for
i
in
range
(
30
):
table_name
=
gen_unique_str
(
'test_mix_multi_table
s'
)
table_list
.
append
(
table
_name
)
param
=
{
'
table_name'
:
table
_name
,
collection_name
=
gen_unique_str
(
'test_mix_multi_collection
s'
)
collection_list
.
append
(
collection
_name
)
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
L2
}
connect
.
create_
table
(
param
)
status
,
ids
=
connect
.
add_vectors
(
table_name
=
table
_name
,
records
=
vectors
)
connect
.
create_
collection
(
param
)
status
,
ids
=
connect
.
add_vectors
(
collection_name
=
collection
_name
,
records
=
vectors
)
idx
.
append
(
ids
[
0
])
idx
.
append
(
ids
[
10
])
idx
.
append
(
ids
[
20
])
assert
status
.
OK
()
for
i
in
range
(
30
):
table_name
=
gen_unique_str
(
'test_mix_multi_table
s'
)
table_list
.
append
(
table
_name
)
param
=
{
'
table_name'
:
table
_name
,
collection_name
=
gen_unique_str
(
'test_mix_multi_collection
s'
)
collection_list
.
append
(
collection
_name
)
param
=
{
'
collection_name'
:
collection
_name
,
'dimension'
:
dim
,
'index_file_size'
:
index_file_size
,
'metric_type'
:
MetricType
.
IP
}
connect
.
create_
table
(
param
)
status
,
ids
=
connect
.
add_vectors
(
table_name
=
table
_name
,
records
=
vectors
)
connect
.
create_
collection
(
param
)
status
,
ids
=
connect
.
add_vectors
(
collection_name
=
collection
_name
,
records
=
vectors
)
assert
status
.
OK
()
status
=
connect
.
flush
([
table
_name
])
status
=
connect
.
flush
([
collection
_name
])
assert
status
.
OK
()
idx
.
append
(
ids
[
0
])
idx
.
append
(
ids
[
10
])
idx
.
append
(
ids
[
20
])
assert
status
.
OK
()
for
i
in
range
(
10
):
status
=
connect
.
create_index
(
table
_list
[
i
],
IndexType
.
FLAT
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
i
],
IndexType
.
FLAT
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
_list
[
30
+
i
],
IndexType
.
FLAT
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
30
+
i
],
IndexType
.
FLAT
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
_list
[
10
+
i
],
IndexType
.
IVFLAT
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
10
+
i
],
IndexType
.
IVFLAT
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
_list
[
40
+
i
],
IndexType
.
IVFLAT
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
40
+
i
],
IndexType
.
IVFLAT
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
_list
[
20
+
i
],
IndexType
.
IVF_SQ8
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
20
+
i
],
IndexType
.
IVF_SQ8
,
index_param
)
assert
status
.
OK
()
status
=
connect
.
create_index
(
table
_list
[
50
+
i
],
IndexType
.
IVF_SQ8
,
index_param
)
status
=
connect
.
create_index
(
collection
_list
[
50
+
i
],
IndexType
.
IVF_SQ8
,
index_param
)
assert
status
.
OK
()
#describe index
for
i
in
range
(
10
):
status
,
result
=
connect
.
describe_index
(
table
_list
[
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
i
])
assert
result
.
_index_type
==
IndexType
.
FLAT
status
,
result
=
connect
.
describe_index
(
table
_list
[
10
+
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
10
+
i
])
assert
result
.
_index_type
==
IndexType
.
IVFLAT
status
,
result
=
connect
.
describe_index
(
table
_list
[
20
+
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
20
+
i
])
assert
result
.
_index_type
==
IndexType
.
IVF_SQ8
status
,
result
=
connect
.
describe_index
(
table
_list
[
30
+
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
30
+
i
])
assert
result
.
_index_type
==
IndexType
.
FLAT
status
,
result
=
connect
.
describe_index
(
table
_list
[
40
+
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
40
+
i
])
assert
result
.
_index_type
==
IndexType
.
IVFLAT
status
,
result
=
connect
.
describe_index
(
table
_list
[
50
+
i
])
status
,
result
=
connect
.
describe_index
(
collection
_list
[
50
+
i
])
assert
result
.
_index_type
==
IndexType
.
IVF_SQ8
#search
query_vecs
=
[
vectors
[
0
],
vectors
[
10
],
vectors
[
20
]]
for
i
in
range
(
60
):
table
=
table
_list
[
i
]
status
,
result
=
connect
.
search_vectors
(
table
,
top_k
,
query_records
=
query_vecs
,
params
=
{
"nprobe"
:
1
})
collection
=
collection
_list
[
i
]
status
,
result
=
connect
.
search_vectors
(
collection
,
top_k
,
query_records
=
query_vecs
,
params
=
{
"nprobe"
:
1
})
assert
status
.
OK
()
assert
len
(
result
)
==
len
(
query_vecs
)
logging
.
getLogger
().
info
(
i
)
...
...
tests/milvus_python_test/test_partition.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_search_by_id.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_search_vectors.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/test_wal.py
浏览文件 @
58dde9cd
此差异已折叠。
点击以展开。
tests/milvus_python_test/utils.py
浏览文件 @
58dde9cd
...
...
@@ -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
():
...
...
@@ -588,7 +588,7 @@ def gen_simple_index():
IndexType
.
IVF_SQ8H
,
IndexType
.
IVF_PQ
,
IndexType
.
HNSW
,
#
IndexType.RNSG
IndexType
.
RNSG
]
params
=
[
{
"nlist"
:
1024
},
...
...
@@ -597,7 +597,7 @@ def gen_simple_index():
{
"nlist"
:
1024
},
{
"nlist"
:
1024
,
"m"
:
16
},
{
"M"
:
16
,
"efConstruction"
:
500
},
# {"search_length": 100, "out_degree": 40, "candidate_pool_size": 66, "knng": 10
0}
{
"search_length"
:
50
,
"out_degree"
:
40
,
"candidate_pool_size"
:
100
,
"knng"
:
5
0
}
]
index_params
=
[]
...
...
@@ -611,14 +611,14 @@ def get_search_param(index_type):
return
{
"nprobe"
:
32
}
elif
index_type
==
IndexType
.
HNSW
:
return
{
"ef"
:
64
}
#
elif index_type == IndexType.RNSG:
# return {"search_length": 10
0}
elif
index_type
==
IndexType
.
RNSG
:
return
{
"search_length"
:
5
0
}
else
:
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录