Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
e2dcbf53
M
milvus
项目概览
milvus
/
milvus
10 个月 前同步成功
通知
260
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
e2dcbf53
编写于
6月 25, 2021
作者:
紫
紫晴
提交者:
GitHub
6月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[skip ci] Verify connection interface issues (#6095)
Signed-off-by:
N
wangting0128
<
ting.wang@zilliz.com
>
上级
fffdb348
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
83 addition
and
69 deletion
+83
-69
tests20/python_client/base/client_base.py
tests20/python_client/base/client_base.py
+13
-11
tests20/python_client/common/code_mapping.py
tests20/python_client/common/code_mapping.py
+2
-7
tests20/python_client/common/common_type.py
tests20/python_client/common/common_type.py
+12
-0
tests20/python_client/requirements.txt
tests20/python_client/requirements.txt
+1
-1
tests20/python_client/testcases/test_connection.py
tests20/python_client/testcases/test_connection.py
+35
-41
tests20/python_client/testcases/test_query.py
tests20/python_client/testcases/test_query.py
+20
-9
未找到文件。
tests20/python_client/base/client_base.py
浏览文件 @
e2dcbf53
...
...
@@ -63,8 +63,14 @@ class Base:
try
:
""" Drop collection before disconnect """
if
self
.
collection_wrap
is
not
None
and
self
.
collection_wrap
.
collection
is
not
None
:
self
.
collection_wrap
.
drop
()
# if self.collection_wrap is not None and self.collection_wrap.collection is not None:
# self.collection_wrap.drop()
if
self
.
collection_wrap
is
not
None
:
collection_list
=
self
.
utility_wrap
.
list_collections
()[
0
]
for
i
in
collection_list
:
collection_wrap
=
ApiCollectionWrapper
()
collection_wrap
.
init_collection
(
name
=
i
)
collection_wrap
.
drop
()
except
Exception
as
e
:
pass
...
...
@@ -115,21 +121,17 @@ class TestcaseBase(Base):
def
_connect
(
self
):
""" Add an connection and create the connect """
self
.
connection_wrap
.
add_connection
(
default
=
{
"host"
:
param_info
.
param_host
,
"port"
:
param_info
.
param_port
})
res
,
is_succ
=
self
.
connection_wrap
.
connect
(
alias
=
'default'
)
if
not
is_succ
:
raise
res
log
.
info
(
"_connect: Connected"
)
res
,
is_succ
=
self
.
connection_wrap
.
connect
(
alias
=
DefaultConfig
.
DEFAULT_USING
,
host
=
param_info
.
param_host
,
port
=
param_info
.
param_port
)
return
res
def
init_collection_wrap
(
self
,
name
=
None
,
schema
=
None
,
check_task
=
None
,
**
kwargs
):
def
init_collection_wrap
(
self
,
name
=
None
,
schema
=
None
,
check_task
=
None
,
check_items
=
None
,
**
kwargs
):
name
=
cf
.
gen_unique_str
(
'coll_'
)
if
name
is
None
else
name
schema
=
cf
.
gen_default_collection_schema
()
if
schema
is
None
else
schema
if
self
.
connection_wrap
.
get_connection
(
alias
=
'default'
)[
0
]
is
None
:
if
self
.
connection_wrap
.
get_connection
(
alias
=
DefaultConfig
.
DEFAULT_USING
)[
0
]
is
None
:
self
.
_connect
()
collection_w
=
ApiCollectionWrapper
()
collection_w
.
init_collection
(
name
=
name
,
schema
=
schema
,
check_task
=
check_task
,
**
kwargs
)
collection_w
.
init_collection
(
name
=
name
,
schema
=
schema
,
check_task
=
check_task
,
check_items
=
check_items
,
**
kwargs
)
return
collection_w
def
init_partition_wrap
(
self
,
collection_wrap
=
None
,
name
=
None
,
description
=
None
,
...
...
tests20/python_client/common/code_mapping.py
浏览文件 @
e2dcbf53
from
enum
import
Enum
from
pymilvus_orm.exceptions
import
ExceptionsMessage
class
ErrorCode
(
Enum
):
...
...
@@ -10,12 +11,6 @@ ErrorMessage = {ErrorCode.ErrorOk: "",
ErrorCode
.
Error
:
"is illegal"
}
class
ConnectionErrorMessage
:
NoHostPort
=
"connection configuration must contain 'host' and 'port'"
HostType
=
"Type of 'host' must be str!"
PortType
=
"Type of port type must be str or int!"
NotHostPort
=
"Connection configuration must be contained host and port"
AliasExist
=
"alias of '%s' already creating connections, but the configure is not the same as passed in."
AliasNotExist
=
"You need to pass in the configuration of the connection named '%s'"
class
ConnectionErrorMessage
(
ExceptionsMessage
):
FailConnect
=
"Fail connecting to server on %s:%s. Timeout"
ConnectExist
=
"The connection named %s already creating, but passed parameters don't match the configured parameters"
tests20/python_client/common/common_type.py
浏览文件 @
e2dcbf53
...
...
@@ -63,6 +63,18 @@ get_invalid_strs = [
"%$#"
,
"a"
.
join
(
"a"
for
i
in
range
(
256
))]
get_not_string
=
[
[],
{},
None
,
(
1
,
),
1
,
1.0
,
[
1
,
"2"
,
3
]
]
get_dict_without_host_port
=
[
{
"host"
:
"host"
},
{
"port"
:
"port"
},
...
...
tests20/python_client/requirements.txt
浏览文件 @
e2dcbf53
...
...
@@ -12,7 +12,7 @@ pytest-print==0.2.1
pytest-level==0.1.1
pytest-xdist==2.2.1
pytest-parallel
pymilvus-orm==2.0a1.dev
33
pymilvus-orm==2.0a1.dev
57
pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient
...
...
tests20/python_client/testcases/test_connection.py
浏览文件 @
e2dcbf53
import
pytest
import
os
from
pymilvus_orm.default_config
import
DefaultConfig
from
base.client_base
import
TestcaseBase
from
utils.util_log
import
test_log
as
log
import
common.common_type
as
ct
...
...
@@ -26,7 +25,7 @@ class TestConnectionParams(TestcaseBase):
# check param of **kwargs
self
.
connection_wrap
.
add_connection
(
_kwargs
=
data
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
cem
.
NoHostPort
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
NoHostPort
})
# get addr of default alias
self
.
connection_wrap
.
get_connection_addr
(
alias
=
DefaultConfig
.
DEFAULT_USING
,
check_task
=
ct
.
CheckTasks
.
ccr
,
...
...
@@ -50,11 +49,10 @@ class TestConnectionParams(TestcaseBase):
# No check for **kwargs
self
.
connection_wrap
.
connect
(
alias
=
DefaultConfig
.
DEFAULT_USING
,
_kwargs
=
[
1
,
2
],
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
cem
.
Not
HostPort
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
No
HostPort
})
@
pytest
.
mark
.
xfail
(
reason
=
"Feature #5725"
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_
invalid_strs
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_
not_string
)
def
test_connection_connect_alias_param_check
(
self
,
alias
):
"""
target: test connect passes wrong params of alias
...
...
@@ -62,13 +60,12 @@ class TestConnectionParams(TestcaseBase):
expected: assert response is error
"""
#
No
check for alias
res
=
self
.
connection_wrap
.
connect
(
alias
=
alias
)
log
.
info
(
res
[
0
]
)
# check for alias
self
.
connection_wrap
.
connect
(
alias
=
alias
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
AliasType
%
type
(
alias
)}
)
@
pytest
.
mark
.
xfail
(
reason
=
"Feature #5725"
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_invalid_strs
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_not_string
)
def
test_connection_get_alias_param_check
(
self
,
alias
):
"""
target: test get connection passes wrong params of alias
...
...
@@ -76,13 +73,12 @@ class TestConnectionParams(TestcaseBase):
expected: assert response is error
"""
#
not
check for alias
res
=
self
.
connection_wrap
.
get_connection
(
alias
=
alias
)
log
.
info
(
res
[
0
]
)
# check for alias
self
.
connection_wrap
.
get_connection
(
alias
=
alias
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
AliasType
%
type
(
alias
)}
)
@
pytest
.
mark
.
xfail
(
reason
=
"Feature #5725"
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_invalid_strs
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_not_string
)
def
test_connection_get_addr_alias_param_check
(
self
,
alias
):
"""
target: test get connection addr passes wrong params of alias
...
...
@@ -90,13 +86,12 @@ class TestConnectionParams(TestcaseBase):
expected: assert response is error
"""
#
not
check for alias
res
=
self
.
connection_wrap
.
get_connection_addr
(
alias
=
alias
)
log
.
info
(
res
[
0
]
)
# check for alias
self
.
connection_wrap
.
get_connection_addr
(
alias
=
alias
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
AliasType
%
type
(
alias
)}
)
@
pytest
.
mark
.
xfail
(
reason
=
"Feature #5725"
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_invalid_strs
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_not_string
)
def
test_connection_remove_alias_param_check
(
self
,
alias
):
"""
target: test remove connection passes wrong params of alias
...
...
@@ -104,14 +99,13 @@ class TestConnectionParams(TestcaseBase):
expected: assert response is error
"""
#
not
check for alias
# check for alias
self
.
_connect
()
res
=
self
.
connection_wrap
.
remove_connection
(
alias
=
alias
)
log
.
info
(
res
[
0
]
)
self
.
connection_wrap
.
remove_connection
(
alias
=
alias
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
AliasType
%
type
(
alias
)}
)
@
pytest
.
mark
.
xfail
(
reason
=
"Feature #5725"
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_invalid_strs
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"alias"
,
ct
.
get_not_string
)
def
test_connection_disconnect_alias_param_check
(
self
,
alias
):
"""
target: test disconnect passes wrong params of alias
...
...
@@ -119,10 +113,10 @@ class TestConnectionParams(TestcaseBase):
expected: assert response is error
"""
#
not
check for alias
# check for alias
self
.
_connect
()
res
=
self
.
connection_wrap
.
disconnect
(
alias
=
alias
)
log
.
info
(
res
[
0
]
)
self
.
connection_wrap
.
disconnect
(
alias
=
alias
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
AliasType
%
type
(
alias
)}
)
class
TestConnectionOperation
(
TestcaseBase
):
...
...
@@ -146,7 +140,7 @@ class TestConnectionOperation(TestcaseBase):
alias2
=
{
"port"
:
"-1"
,
"host"
:
"hostlocal"
},
testing
=
data
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
err_msg
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
err_msg
})
# list all connections and check the response
self
.
connection_wrap
.
list_connections
(
check_task
=
ct
.
CheckTasks
.
ccr
,
...
...
@@ -293,10 +287,10 @@ class TestConnectionOperation(TestcaseBase):
self
.
connection_wrap
.
connect
(
alias
=
"test_alias_name"
,
host
=
host
,
port
=
port
,
check_task
=
ct
.
CheckTasks
.
ccr
)
# add connection with diff params after that alias has been created
err_msg
=
cem
.
AliasExist
%
"test_alias_name"
err_msg
=
cem
.
ConnDiffConf
%
"test_alias_name"
self
.
connection_wrap
.
add_connection
(
test_alias_name
=
{
"host"
:
"localhost"
,
"port"
:
"1"
},
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
err_msg
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
err_msg
})
# add connection with the same params
self
.
connection_wrap
.
add_connection
(
test_alias_name
=
{
"host"
:
host
,
"port"
:
port
})
...
...
@@ -313,10 +307,10 @@ class TestConnectionOperation(TestcaseBase):
check_task
=
ct
.
CheckTasks
.
ccr
)
# add connection after that alias has been created
err_msg
=
cem
.
AliasExist
%
"test_alias_name"
err_msg
=
cem
.
ConnDiffConf
%
DefaultConfig
.
DEFAULT_USING
self
.
connection_wrap
.
add_connection
(
default
=
{
"host"
:
"localhost"
,
"port"
:
"1"
},
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
err_msg
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
err_msg
})
# add connection with the same params
self
.
connection_wrap
.
add_connection
(
test_alias_name
=
{
"host"
:
host
,
"port"
:
port
})
...
...
@@ -380,9 +374,9 @@ class TestConnectionOperation(TestcaseBase):
"""
# create connection that param of alias is not exist
err_msg
=
cem
.
AliasNotExist
%
ct
.
Not_Exist
err_msg
=
cem
.
ConnLackConf
%
ct
.
Not_Exist
self
.
connection_wrap
.
connect
(
alias
=
ct
.
Not_Exist
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
err_msg
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
err_msg
})
# list all connections and check the response
self
.
connection_wrap
.
list_connections
(
check_task
=
ct
.
CheckTasks
.
ccr
,
...
...
@@ -469,10 +463,10 @@ class TestConnectionOperation(TestcaseBase):
assert
res_obj1
==
res_obj2
# connect twice with the different params
err_msg
=
cem
.
Conn
ectExist
%
"default"
err_msg
=
cem
.
Conn
DiffConf
%
"default"
self
.
connection_wrap
.
connect
(
alias
=
connect_name
,
host
=
"host"
,
port
=
port
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
err_msg
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
err_msg
})
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L2
)
@
pytest
.
mark
.
parametrize
(
"connect_name"
,
[
DefaultConfig
.
DEFAULT_USING
,
"test_alias_nme"
])
...
...
@@ -511,8 +505,8 @@ class TestConnectionOperation(TestcaseBase):
# created connection with wrong connect name
self
.
connection_wrap
.
connect
(
alias
=
connect_name
,
ip
=
host
,
port
=
port
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
-
1
,
ct
.
err_msg
:
"Param is not complete. Please invoke as follow:"
})
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
NoHostPort
})
# list all connections and check the response
self
.
connection_wrap
.
list_connections
(
check_task
=
ct
.
CheckTasks
.
ccr
,
...
...
@@ -710,7 +704,7 @@ class TestConnectionOperation(TestcaseBase):
# init collection failed
self
.
collection_wrap
.
init_collection
(
name
=
collection_name
,
schema
=
schema
,
check_task
=
ct
.
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
"object has no attribute 'has_collection'"
},
ct
.
err_msg
:
cem
.
ConnectFirst
},
_using
=
ct
.
Not_Exist
)
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L1
)
...
...
tests20/python_client/testcases/test_query.py
浏览文件 @
e2dcbf53
import
pytest
from
pymilvus_orm.default_config
import
DefaultConfig
from
base.client_base
import
TestcaseBase
from
common.code_mapping
import
ConnectionErrorMessage
as
cem
from
common
import
common_func
as
cf
from
common
import
common_type
as
ct
from
common.common_type
import
CaseLabel
,
CheckTasks
...
...
@@ -422,7 +425,7 @@ class TestQueryBase(TestcaseBase):
check_items
=
CheckTasks
.
err_res
,
check_task
=
error
)
@
pytest
.
mark
.
skip
(
reason
=
"waiting for debug"
)
#
@pytest.mark.skip(reason="waiting for debug")
class
TestQueryOperation
(
TestcaseBase
):
"""
******************************************************************
...
...
@@ -430,19 +433,27 @@ class TestQueryOperation(TestcaseBase):
******************************************************************
"""
def
test_query_without_connection
(
self
):
@
pytest
.
mark
.
tags
(
ct
.
CaseLabel
.
L3
)
@
pytest
.
mark
.
parametrize
(
"collection_name"
,
[
cf
.
gen_unique_str
(
prefix
)])
def
test_query_without_connection
(
self
,
collection_name
):
"""
target: test query without connection
method: close connect and query
expected: raise exception
"""
c_name
=
cf
.
gen_unique_str
(
prefix
)
collection_w
=
self
.
init_collection_wrap
(
name
=
c_name
)
self
.
connection_wrap
.
remove_connection
(
ct
.
default_alias
)
res_list
,
_
=
self
.
connection_wrap
.
list_connections
()
assert
ct
.
default_alias
not
in
res_list
error
=
{
ct
.
err_code
:
1
,
ct
.
err_msg
:
'should create connect first'
}
collection_w
.
query
(
default_term_expr
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
error
)
# init a collection with default connection
collection_w
=
self
.
init_collection_wrap
(
name
=
collection_name
)
# remove default connection
self
.
connection_wrap
.
remove_connection
(
alias
=
DefaultConfig
.
DEFAULT_USING
)
# list connection to check
self
.
connection_wrap
.
list_connections
(
check_task
=
ct
.
CheckTasks
.
ccr
,
check_items
=
{
ct
.
list_content
:
[]})
# query after remove default connection
collection_w
.
query
(
default_term_expr
,
check_task
=
CheckTasks
.
err_res
,
check_items
=
{
ct
.
err_code
:
0
,
ct
.
err_msg
:
cem
.
ConnectFirst
})
def
test_query_without_loading
(
self
):
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录