Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
a4038d9f
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,发现更多精彩内容 >>
未验证
提交
a4038d9f
编写于
5月 13, 2022
作者:
Y
yongpengli-z
提交者:
GitHub
5月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify index test cases by comment (#16969)
Signed-off-by:
N
yongpengli-z
<
yongpeng.li@zilliz.com
>
上级
168935f4
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
81 addition
and
102 deletion
+81
-102
tests/python_client/testcases/test_index.py
tests/python_client/testcases/test_index.py
+81
-102
未找到文件。
tests/python_client/testcases/test_index.py
浏览文件 @
a4038d9f
...
...
@@ -783,31 +783,6 @@ class TestNewIndexBase(TestcaseBase):
collection_w
.
drop_index
(
index_name
=
index_name
)
assert
len
(
collection_w
.
collection
.
indexes
)
==
0
class
TestIndexBase
:
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
gen_simple_index
()
)
def
get_simple_index
(
self
,
request
,
connect
):
log
.
info
(
request
.
param
)
# if str(connect._cmd("mode")) == "CPU":
# if request.param["index_type"] in index_cpu_not_support():
# pytest.skip("sq8h not support in CPU mode")
return
copy
.
deepcopy
(
request
.
param
)
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
[
1
,
10
,
1111
],
)
def
get_nq
(
self
,
request
):
yield
request
.
param
"""
******************************************************************
The following cases are used to test `drop_index` function
...
...
@@ -815,148 +790,152 @@ class TestIndexBase:
"""
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_drop_index
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_drop_index
(
self
,
get_simple_index
):
"""
target: test drop index interface
method: create collection and add entities in it, create index, call drop index
expected: return code 0, and default index param
"""
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
index
=
connect
.
describe_index
(
collection
,
""
)
assert
not
index
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
data
=
cf
.
gen_default_list_data
()
collection_w
.
insert
(
data
=
data
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
# TODO #7372
def
test_drop_index_repeatedly
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_drop_index_repeatedly
(
self
,
get_simple_index
):
"""
target: test drop index repeatedly
method: create index, call drop index, and drop again
expected: return code 0
"""
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
connect
.
drop_index
(
collection
,
field_name
)
index
=
connect
.
describe_index
(
collection
,
""
)
assert
not
index
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
"Index doesn
\'
t exist."
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_drop_index_without_connect
(
self
,
dis_connect
,
collection
):
def
test_drop_index_without_connect
(
self
):
"""
target: test drop index without connection
method: drop index, and check if drop successfully
expected: raise exception
"""
with
pytest
.
raises
(
Exception
)
as
e
:
dis_connect
.
drop_index
(
collection
,
field_name
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_drop_index_collection_not_existed
(
self
,
connect
):
"""
target: test drop index interface when collection name not existed
method: create collection and add entities in it, create index,
make sure the collection name not in index, and then drop it
expected: return code not equals to 0, drop index failed
"""
collection_name
=
gen_unique_str
(
uid
)
with
pytest
.
raises
(
Exception
)
as
e
:
connect
.
drop_index
(
collection_name
,
field_name
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_drop_index_collection_not_create
(
self
,
connect
,
collection
):
"""
target: test drop index interface when index not created
method: create collection and add entities in it, create index
expected: return code not equals to 0, drop index failed
"""
# no create index
connect
.
drop_index
(
collection
,
field_name
)
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
c_name
)
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
default_index_params
,
index_name
=
ct
.
default_index_name
)
self
.
connection_wrap
.
remove_connection
(
ct
.
default_alias
)
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
"should create connect first."
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_create_drop_index_repeatedly
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_create_drop_index_repeatedly
(
self
,
get_simple_index
):
"""
target: test create / drop index repeatedly, use the same index params
method: create index, drop index, four times
expected: return code 0
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
for
i
in
range
(
4
):
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_drop_index_ip
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_drop_index_ip
(
self
,
get_simple_index
):
"""
target: test drop index interface
method: create collection and add entities in it, create index, call drop index
expected: return code 0, and default index param
"""
# result = connect.insert(collection, entities)
get_simple_index
[
"metric_type"
]
=
"IP"
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
index
=
connect
.
describe_index
(
collection
,
""
)
assert
not
index
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_drop_index_repeatedly_ip
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_drop_index_repeatedly_ip
(
self
,
get_simple_index
):
"""
target: test drop index repeatedly
method: create index, call drop index, and drop again
expected: return code 0
"""
get_simple_index
[
"metric_type"
]
=
"IP"
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
connect
.
drop_index
(
collection
,
field_name
)
index
=
connect
.
describe_index
(
collection
,
""
)
assert
not
index
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
"Index doesn
\'
t exist."
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_drop_index_without_connect_ip
(
self
,
dis_connect
,
collection
):
def
test_drop_index_without_connect_ip
(
self
):
"""
target: test drop index without connection
method: drop index, and check if drop successfully
expected: raise exception
"""
with
pytest
.
raises
(
Exception
)
as
e
:
dis_connect
.
drop_index
(
collection
,
field_name
)
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_drop_index_collection_not_create_ip
(
self
,
connect
,
collection
):
"""
target: test drop index interface when index not created
method: create collection and add entities in it, create index
expected: return code not equals to 0, drop index failed
"""
# result = connect.insert(collection, entities)
# no create index
connect
.
drop_index
(
collection
,
field_name
)
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
c_name
)
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
default_ip_index_params
,
index_name
=
ct
.
default_index_name
)
self
.
connection_wrap
.
remove_connection
(
ct
.
default_alias
)
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
"should create connect first."
})
@
pytest
.
mark
.
tags
(
CaseLabel
.
L2
)
def
test_create_drop_index_repeatedly_ip
(
self
,
connect
,
collection
,
get_simple_index
):
def
test_create_drop_index_repeatedly_ip
(
self
,
get_simple_index
):
"""
target: test create / drop index repeatedly, use the same index params
method: create index, drop index, four times
expected: return code 0
"""
get_simple_index
[
"metric_type"
]
=
"IP"
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
c_name
)
if
get_simple_index
[
"index_type"
]
!=
"FLAT"
:
for
i
in
range
(
4
):
connect
.
create_index
(
collection
,
field_name
,
get_simple_index
)
connect
.
drop_index
(
collection
,
field_name
)
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
get_simple_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
collection_w
.
drop_index
(
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
0
@
pytest
.
mark
.
tags
(
CaseLabel
.
L0
)
def
test_create_PQ_without_nbits
(
self
,
connect
,
collection
):
def
test_create_PQ_without_nbits
(
self
):
"""
target: test create PQ index
method: create PQ index without nbits
expected: create successfully
"""
PQ_index
=
{
"index_type"
:
"IVF_PQ"
,
"params"
:
{
"nlist"
:
128
,
"m"
:
16
},
"metric_type"
:
"L2"
}
result
=
connect
.
insert
(
collection
,
default_entities
)
connect
.
create_index
(
collection
,
field_name
,
PQ_index
)
index
=
connect
.
describe_index
(
collection
,
""
)
create_target_index
(
PQ_index
,
field_name
)
assert
index
==
PQ_index
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
c_name
)
collection_w
.
create_index
(
ct
.
default_float_vec_field_name
,
PQ_index
,
index_name
=
ct
.
default_index_name
)
assert
len
(
collection_w
.
indexes
)
==
1
class
TestIndexBinary
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录