2021-05-11 09:59:29 +00:00
|
|
|
|
import pytest
|
2021-09-02 05:22:10 +00:00
|
|
|
|
import concurrent.futures
|
2021-10-08 05:54:53 +00:00
|
|
|
|
from pymilvus import DefaultConfig, Milvus
|
2021-06-25 02:46:09 +00:00
|
|
|
|
|
2021-06-05 02:25:34 +00:00
|
|
|
|
from base.client_base import TestcaseBase
|
2021-10-08 05:54:53 +00:00
|
|
|
|
from utils.utils import get_milvus, gen_invalid_ips, gen_invalid_ints, gen_invalid_uris
|
2021-06-18 08:26:07 +00:00
|
|
|
|
import common.common_type as ct
|
|
|
|
|
import common.common_func as cf
|
2021-06-23 12:22:08 +00:00
|
|
|
|
from common.code_mapping import ConnectionErrorMessage as cem
|
2021-05-11 09:59:29 +00:00
|
|
|
|
|
2021-09-02 05:22:10 +00:00
|
|
|
|
CONNECT_TIMEOUT = 12
|
|
|
|
|
|
2021-05-11 09:59:29 +00:00
|
|
|
|
|
2021-06-05 02:25:34 +00:00
|
|
|
|
class TestConnectionParams(TestcaseBase):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
Test case of connections interface
|
|
|
|
|
The author : Ting.Wang
|
|
|
|
|
"""
|
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-23 12:22:08 +00:00
|
|
|
|
@pytest.mark.parametrize("data", ct.get_dict_without_host_port)
|
|
|
|
|
def test_connection_add_connection_kwargs_param_check(self, data):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test **kwargs of add_connection
|
2021-06-01 10:49:31 +00:00
|
|
|
|
method: passing wrong parameters of **kwargs
|
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
|
|
|
|
|
2021-06-23 12:22:08 +00:00
|
|
|
|
# check param of **kwargs
|
|
|
|
|
self.connection_wrap.add_connection(_kwargs=data, check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: cem.NoHostPort})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get addr of default alias
|
2021-06-23 12:22:08 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_connect_kwargs_param_check(self):
|
|
|
|
|
"""
|
|
|
|
|
target: test **kwargs of connect
|
|
|
|
|
method: passing wrong parameters of **kwargs
|
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get addr of default alias
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING)
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
|
|
|
|
# No check for **kwargs
|
2021-06-23 12:22:08 +00:00
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, _kwargs=[1, 2],
|
|
|
|
|
check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: cem.NoHostPort})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-25 02:46:09 +00:00
|
|
|
|
@pytest.mark.parametrize("alias", ct.get_not_string)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_connect_alias_param_check(self, alias):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test connect passes wrong params of alias
|
|
|
|
|
method: connect passes wrong params of alias
|
2021-06-01 10:49:31 +00:00
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-25 02:46:09 +00:00
|
|
|
|
# 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)})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-25 02:46:09 +00:00
|
|
|
|
@pytest.mark.parametrize("alias", ct.get_not_string)
|
2021-06-01 10:49:31 +00:00
|
|
|
|
def test_connection_get_alias_param_check(self, alias):
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test get connection passes wrong params of alias
|
|
|
|
|
method: get connection passes wrong params of alias
|
2021-06-01 10:49:31 +00:00
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-25 02:46:09 +00:00
|
|
|
|
# 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)})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-25 02:46:09 +00:00
|
|
|
|
@pytest.mark.parametrize("alias", ct.get_not_string)
|
2021-06-01 10:49:31 +00:00
|
|
|
|
def test_connection_get_addr_alias_param_check(self, alias):
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test get connection addr passes wrong params of alias
|
|
|
|
|
method: get connection addr passes wrong params of alias
|
2021-06-01 10:49:31 +00:00
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-25 02:46:09 +00:00
|
|
|
|
# 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)})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-25 02:46:09 +00:00
|
|
|
|
@pytest.mark.parametrize("alias", ct.get_not_string)
|
2021-06-01 10:49:31 +00:00
|
|
|
|
def test_connection_remove_alias_param_check(self, alias):
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test remove connection passes wrong params of alias
|
|
|
|
|
method: remove connection passes wrong params of alias
|
2021-06-01 10:49:31 +00:00
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-25 02:46:09 +00:00
|
|
|
|
# check for alias
|
2021-06-01 10:49:31 +00:00
|
|
|
|
self._connect()
|
2021-06-25 02:46:09 +00:00
|
|
|
|
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)})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-25 02:46:09 +00:00
|
|
|
|
@pytest.mark.parametrize("alias", ct.get_not_string)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_disconnect_alias_param_check(self, alias):
|
|
|
|
|
"""
|
|
|
|
|
target: test disconnect passes wrong params of alias
|
|
|
|
|
method: disconnect passes wrong params of alias
|
|
|
|
|
expected: assert response is error
|
|
|
|
|
"""
|
|
|
|
|
|
2021-06-25 02:46:09 +00:00
|
|
|
|
# check for alias
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self._connect()
|
2021-06-25 02:46:09 +00:00
|
|
|
|
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)})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-05 02:25:34 +00:00
|
|
|
|
class TestConnectionOperation(TestcaseBase):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
Test case of connections interface
|
|
|
|
|
The author : Ting.Wang
|
|
|
|
|
"""
|
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-23 12:22:08 +00:00
|
|
|
|
@pytest.mark.parametrize("data, err_msg", [(ct.get_wrong_format_dict[0], cem.PortType),
|
|
|
|
|
(ct.get_wrong_format_dict[1], cem.HostType)])
|
|
|
|
|
def test_connection_add_wrong_format(self, data, err_msg):
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
target: test add_connection, regardless of whether the connection exists
|
|
|
|
|
method: add existing and non-existing configurations at the same time
|
|
|
|
|
expected: list_connections include the configured connections
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# add connections
|
|
|
|
|
self.connection_wrap.add_connection(alias1={"host": "localhost", "port": "1"},
|
|
|
|
|
alias2={"port": "-1", "host": "hostlocal"},
|
2021-06-23 12:22:08 +00:00
|
|
|
|
testing=data,
|
|
|
|
|
check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: err_msg})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
|
2021-06-23 12:22:08 +00:00
|
|
|
|
('alias1', None), ('alias2', None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "1"}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "hostlocal", "port": "-1"}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="testing", check_task=ct.CheckTasks.ccr,
|
2021-06-23 12:22:08 +00:00
|
|
|
|
check_items={ct.dict_content: {}})
|
2021-06-18 08:26:07 +00:00
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_more(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test add_connection passes in multiple parameters
|
|
|
|
|
method: add two params of add_connection
|
|
|
|
|
expected: added to the connection list successfully
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# add connections
|
|
|
|
|
self.connection_wrap.add_connection(alias1={"host": "localhost", "port": "1"},
|
|
|
|
|
alias2={"host": "192.168.1.1", "port": "123"})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: None})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
|
|
|
|
|
('alias1', None), ('alias2', None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "1"}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "192.168.1.1", "port": "123"}})
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_single_more(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: test add connections separately
|
|
|
|
|
method: add_connection twice
|
|
|
|
|
expected: added to the connection list successfully
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# add connections
|
|
|
|
|
self.connection_wrap.add_connection(alias1={"host": "localhost", "port": "1"})
|
|
|
|
|
self.connection_wrap.add_connection(alias2={"host": "192.168.1.1", "port": "123"})
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
|
|
|
|
|
('alias1', None), ('alias2', None)]})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias1", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "1"}})
|
|
|
|
|
self.connection_wrap.get_connection_addr(alias="alias2", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "192.168.1.1", "port": "123"}})
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L0)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_default(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: add_connection passes default params successfully
|
|
|
|
|
method: add_connection passes default params
|
|
|
|
|
expected: response of add_connection is normal
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# add connections
|
|
|
|
|
self.connection_wrap.add_connection(default={'host': 'localhost', 'port': '19530'})
|
|
|
|
|
self.connection_wrap.add_connection(default={'port': '19530', 'host': 'localhost'})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_cover_default(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: add a connection to override the default connection
|
|
|
|
|
method: add_connection passes alias of default and different configure
|
|
|
|
|
expected: the configuration was successfully overwritten
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get all addr of default alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': 'localhost', 'port': '19530'}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connections
|
|
|
|
|
self.connection_wrap.add_connection(default={'host': '192.168.1.1', 'port': '12345'})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': '192.168.1.1',
|
|
|
|
|
'port': '12345'}})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_get_addr_not_exist(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: get addr of alias that is not exist and return {}
|
|
|
|
|
method: get_connection_addr passes alias that is not exist
|
|
|
|
|
expected: response of get_connection_addr is None
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get an addr that not exist and return {}
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=ct.Not_Exist, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
@pytest.mark.skip("The maximum number of add_connection is not set")
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_max(self):
|
|
|
|
|
"""
|
|
|
|
|
The maximum number of add_connection is not set
|
|
|
|
|
"""
|
|
|
|
|
pass
|
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_after_connect(self, host, port):
|
|
|
|
|
"""
|
2021-09-27 10:54:33 +00:00
|
|
|
|
target: add_connection with different params after normal connect
|
|
|
|
|
method: then add_connection with different params
|
|
|
|
|
expected: add_connection failed
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# create connection that param of alias is not exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias="test_alias_name", host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connection with diff params after that alias has been created
|
2021-06-25 02:46:09 +00:00
|
|
|
|
err_msg = cem.ConnDiffConf % "test_alias_name"
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={"host": "localhost", "port": "1"},
|
2021-06-18 08:26:07 +00:00
|
|
|
|
check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: err_msg})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connection with the same params
|
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={"host": host, "port": port})
|
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_after_default_connect(self, host, port):
|
|
|
|
|
"""
|
2021-09-28 02:34:18 +00:00
|
|
|
|
target: add_connection with different params after default alias connected
|
|
|
|
|
method: 1. connect with default alias
|
|
|
|
|
2. add_connection with the same alias but different params
|
|
|
|
|
expected: add_connection failed
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
# create connection that param of alias is default
|
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=host, port=port,
|
2021-06-18 08:26:07 +00:00
|
|
|
|
check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connection after that alias has been created
|
2021-06-25 02:46:09 +00:00
|
|
|
|
err_msg = cem.ConnDiffConf % DefaultConfig.DEFAULT_USING
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self.connection_wrap.add_connection(default={"host": "localhost", "port": "1"},
|
2021-06-18 08:26:07 +00:00
|
|
|
|
check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: err_msg})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connection with the same params
|
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={"host": host, "port": port})
|
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_after_disconnect(self, host, port):
|
|
|
|
|
"""
|
2021-09-29 11:11:12 +00:00
|
|
|
|
target: update connection params after connection disconnected
|
|
|
|
|
method: 1. connect and disconnect a connection
|
|
|
|
|
2. re-add connection by the same alias with different connection params
|
|
|
|
|
expected: re-add_connection successfully with new params
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-09-29 11:11:12 +00:00
|
|
|
|
# add a new connection and connect
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias="test_alias_name", host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-09-29 11:11:12 +00:00
|
|
|
|
# disconnect the connection
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self.connection_wrap.disconnect(alias="test_alias_name")
|
|
|
|
|
|
2021-09-29 11:11:12 +00:00
|
|
|
|
# get the connection address after it disconnected
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": host, "port": port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-09-29 11:11:12 +00:00
|
|
|
|
# re-add connection by the same alias with different connection params
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={"host": "localhost", "port": "1"})
|
|
|
|
|
|
2021-09-29 11:11:12 +00:00
|
|
|
|
# re-get the connection address
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "1"}})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_add_after_remove(self, host, port):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-09-30 10:16:56 +00:00
|
|
|
|
target: add_connection after normal connect、remove_connection
|
|
|
|
|
method: 1. connect and remove_connection
|
|
|
|
|
2. add connection by the same alias with different params
|
|
|
|
|
expected: add_connection by the same alias with different params successfully
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# create connection that param of alias is not exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias="test_alias_name", host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# disconnect alias is exist
|
|
|
|
|
self.connection_wrap.remove_connection(alias="test_alias_name")
|
|
|
|
|
|
|
|
|
|
# get an addr that is not exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add connection after that alias has been disconnected
|
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={"host": "localhost", "port": "1"})
|
|
|
|
|
|
|
|
|
|
# get an addr that is exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias="test_alias_name", check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "1"}})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_connect_alias_not_exist(self):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-01 12:42:51 +00:00
|
|
|
|
target: connect with a non existing alias and raise error
|
|
|
|
|
method: connect with a non existing alias
|
2021-06-10 11:19:49 +00:00
|
|
|
|
expected: response of connect is error
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# create connection that param of alias is not exist
|
2021-06-25 02:46:09 +00:00
|
|
|
|
err_msg = cem.ConnLackConf % ct.Not_Exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=ct.Not_Exist, check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: err_msg})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': "localhost", 'port': "19530"}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_connect_default_alias_invalid(self, port):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-02 11:40:28 +00:00
|
|
|
|
target: connect with non existing params
|
|
|
|
|
method: 1. add connection with non existing params
|
|
|
|
|
2. try to connect
|
|
|
|
|
expected: raise an exception
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# add invalid default connection
|
|
|
|
|
self.connection_wrap.add_connection(default={'host': "host", 'port': port})
|
|
|
|
|
|
|
|
|
|
# using default alias to create connection, the connection does not exist
|
2021-06-23 12:22:08 +00:00
|
|
|
|
err_msg = cem.FailConnect % ("host", str(port))
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.err_res,
|
2021-06-23 12:22:08 +00:00
|
|
|
|
check_items={ct.err_code: -1, ct.err_msg: err_msg})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': "host", 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-07-27 08:05:21 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L0)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_connect_default_alias_effective(self, host, port):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-04 00:34:06 +00:00
|
|
|
|
target: verify connections by default alias
|
|
|
|
|
method: 1. add connection with default alias
|
|
|
|
|
2. connect with default alias
|
|
|
|
|
3. list connections and get connection address
|
|
|
|
|
expected: 1. add connection, connect, list and get connection address successfully
|
2021-06-10 11:19:49 +00:00
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# add a valid default connection
|
2021-06-04 01:35:34 +00:00
|
|
|
|
self.connection_wrap.add_connection(default={'host': host, 'port': port})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING,
|
2021-07-27 08:05:21 +00:00
|
|
|
|
ct.Connect_Object_Name)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': host, 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING])
|
|
|
|
|
def test_connection_connect_repeat(self, host, port, connect_name):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: connect twice and return the same object
|
|
|
|
|
method: connect twice
|
|
|
|
|
expected: return the same object of connect
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# add a valid default connection
|
|
|
|
|
self.connection_wrap.add_connection(default={'host': host, 'port': port})
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
res_obj1 = self.connection_wrap.get_connection(alias=connect_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: ct.Connect_Object_Name})[0]
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# connect twice with the same params
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
res_obj2 = self.connection_wrap.get_connection(alias=connect_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: ct.Connect_Object_Name})[0]
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# check the response of the same alias is equal
|
|
|
|
|
assert res_obj1 == res_obj2
|
|
|
|
|
|
|
|
|
|
# connect twice with the different params
|
2021-06-25 02:46:09 +00:00
|
|
|
|
err_msg = cem.ConnDiffConf % "default"
|
2021-06-10 11:19:49 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, host="host", port=port,
|
2021-06-23 12:22:08 +00:00
|
|
|
|
check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: err_msg})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, "test_alias_nme"])
|
|
|
|
|
def test_connection_connect_params(self, host, port, connect_name):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
target: connect directly via parameters and return the object of connect successfully
|
|
|
|
|
method: connect directly via parameters
|
|
|
|
|
expected: response of connect is Milvus object
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection(alias=connect_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: ct.Connect_Object_Name})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-07-27 08:05:21 +00:00
|
|
|
|
list_content = [(connect_name, ct.Connect_Object_Name)] if connect_name is DefaultConfig.DEFAULT_USING else \
|
2021-06-18 08:26:07 +00:00
|
|
|
|
[(DefaultConfig.DEFAULT_USING, None), (connect_name, ct.Connect_Object_Name)]
|
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: list_content})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=connect_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': host, 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, "test_alias_nme"])
|
|
|
|
|
def test_connection_connect_wrong_params(self, host, port, connect_name):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-05 12:32:44 +00:00
|
|
|
|
target: connect directly via invalid parameters and raise error
|
|
|
|
|
method: connect directly via invalid parameters
|
|
|
|
|
expected: raise exception with error msg
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# created connection with wrong connect name
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, ip=host, port=port, check_task=ct.CheckTasks.err_res,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
check_items={ct.err_code: 0,
|
|
|
|
|
ct.err_msg: cem.NoHostPort})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-23 12:22:08 +00:00
|
|
|
|
dict_content = {'host': DefaultConfig.DEFAULT_HOST,
|
|
|
|
|
'port': DefaultConfig.DEFAULT_PORT} if connect_name == DefaultConfig.DEFAULT_USING else {}
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=connect_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: dict_content})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, ct.Not_Exist])
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_disconnect_not_exist(self, connect_name):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-06 12:57:11 +00:00
|
|
|
|
target: disconnect with non existing alias
|
|
|
|
|
method: disconnect with non existing alias
|
2021-06-10 11:19:49 +00:00
|
|
|
|
expected: check connection list is normal
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# disconnect alias is not exist
|
|
|
|
|
self.connection_wrap.disconnect(alias=connect_name)
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING,
|
|
|
|
|
check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {"host": "localhost", "port": "19530"}})
|
2021-06-01 10:49:31 +00:00
|
|
|
|
|
2021-07-02 07:24:17 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_disconnect_after_default_connect(self, host, port):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-07 12:29:32 +00:00
|
|
|
|
target: check results after disconnect with default alias
|
|
|
|
|
method: 1. connect with default alias
|
|
|
|
|
2. get connection
|
|
|
|
|
3. disconnect with default alias
|
|
|
|
|
4. get connection
|
|
|
|
|
5. disconnect again
|
|
|
|
|
6. list connections and get connection address
|
2021-06-10 11:19:49 +00:00
|
|
|
|
expected: the connection was successfully terminated
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
|
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
|
# add a valid default connection
|
|
|
|
|
self.connection_wrap.add_connection(default={'host': host, 'port': port})
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: ct.Connect_Object_Name})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# disconnect alias is exist
|
|
|
|
|
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
|
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: None})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# disconnect twice
|
|
|
|
|
self.connection_wrap.disconnect(alias=DefaultConfig.DEFAULT_USING)
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': host, 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_disconnect_after_connect(self, host, port):
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-10-08 09:33:40 +00:00
|
|
|
|
target: disconnect with customized alias and check results
|
|
|
|
|
method: 1. connect with customized alias
|
|
|
|
|
2. disconnect with the alias
|
|
|
|
|
3. list connections and get connection address
|
2021-06-10 11:19:49 +00:00
|
|
|
|
expected: the connection was successfully terminated
|
2021-06-01 10:49:31 +00:00
|
|
|
|
"""
|
2021-06-10 11:19:49 +00:00
|
|
|
|
test_alias_name = "test_alias_name"
|
|
|
|
|
|
|
|
|
|
# add a valid default connection
|
|
|
|
|
self.connection_wrap.add_connection(test_alias_name={'host': host, 'port': port})
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=test_alias_name, host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
|
2021-07-27 08:05:21 +00:00
|
|
|
|
(
|
|
|
|
|
test_alias_name, ct.Connect_Object_Name)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': host, 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# disconnect alias is exist
|
|
|
|
|
self.connection_wrap.disconnect(alias=test_alias_name)
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None),
|
|
|
|
|
(test_alias_name, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# get all addr of alias and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection_addr(alias=test_alias_name, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.dict_content: {'host': host, 'port': port}})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_remove_connection_not_exist(self):
|
|
|
|
|
"""
|
|
|
|
|
target: remove connection that is not exist and check result
|
|
|
|
|
method: remove connection that is not exist
|
|
|
|
|
expected: connection list is normal
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# remove the connection that is not exist
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.remove_connection(alias=ct.Not_Exist)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.list_content: [(DefaultConfig.DEFAULT_USING, None)]})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
def test_connection_remove_default_alias(self):
|
|
|
|
|
"""
|
|
|
|
|
target: remove default alias connect and check result
|
|
|
|
|
method: remove default alias connect
|
|
|
|
|
expected: list connection and return {}
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# remove the connection that is not exist
|
|
|
|
|
self.connection_wrap.remove_connection(alias=DefaultConfig.DEFAULT_USING)
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, check_items={ct.list_content: []})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, "test_alias_name"])
|
|
|
|
|
def test_connection_remove_after_connect(self, host, port, connect_name):
|
|
|
|
|
"""
|
|
|
|
|
target: remove connection after connect and check result
|
|
|
|
|
method: remove connection after connect
|
|
|
|
|
expected: addr is None, response of list_connection still included that configure
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# remove the connection that is not exist
|
|
|
|
|
self.connection_wrap.remove_connection(alias=connect_name)
|
|
|
|
|
|
|
|
|
|
# get the object of alias
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.get_connection(alias=DefaultConfig.DEFAULT_USING, check_task=ct.CheckTasks.ccr,
|
|
|
|
|
check_items={ct.value_content: None})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
|
|
|
|
list_content = [] if connect_name == DefaultConfig.DEFAULT_USING else [(DefaultConfig.DEFAULT_USING, None)]
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, check_items={ct.list_content: list_content})
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
2021-06-18 08:26:07 +00:00
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
@pytest.mark.parametrize("connect_name", [DefaultConfig.DEFAULT_USING, "test_alias_name"])
|
|
|
|
|
def test_connection_remove_after_disconnect(self, host, port, connect_name):
|
|
|
|
|
"""
|
|
|
|
|
target: remove connection after disconnect and check result
|
|
|
|
|
method: remove connection after disconnect
|
|
|
|
|
expected: response of list_connection not included that configure
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.connect(alias=connect_name, host=host, port=port, check_task=ct.CheckTasks.ccr)
|
2021-06-10 11:19:49 +00:00
|
|
|
|
|
|
|
|
|
# disconnect alias is exist
|
|
|
|
|
self.connection_wrap.disconnect(alias=connect_name)
|
|
|
|
|
|
|
|
|
|
# remove connection
|
|
|
|
|
self.connection_wrap.remove_connection(alias=connect_name)
|
|
|
|
|
|
|
|
|
|
# remove twice connection
|
|
|
|
|
self.connection_wrap.remove_connection(alias=connect_name)
|
|
|
|
|
|
|
|
|
|
# list all connections and check the response
|
|
|
|
|
list_content = [] if connect_name == DefaultConfig.DEFAULT_USING else [(DefaultConfig.DEFAULT_USING, None)]
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.connection_wrap.list_connections(check_task=ct.CheckTasks.ccr, check_items={ct.list_content: list_content})
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-07-27 08:05:21 +00:00
|
|
|
|
def test_connection_init_collection_invalid_connection(self):
|
2021-06-18 08:26:07 +00:00
|
|
|
|
"""
|
|
|
|
|
target: create collection with invalid connection
|
|
|
|
|
method: init collection with invalid connection
|
|
|
|
|
expected: check result
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# init collection failed
|
2021-07-27 08:05:21 +00:00
|
|
|
|
collection_name = cf.gen_unique_str('connection_test_')
|
|
|
|
|
schema = cf.gen_default_collection_schema()
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.collection_wrap.init_collection(name=collection_name, schema=schema, check_task=ct.CheckTasks.err_res,
|
|
|
|
|
check_items={ct.err_code: 0,
|
2021-06-25 02:46:09 +00:00
|
|
|
|
ct.err_msg: cem.ConnectFirst},
|
2021-06-18 08:26:07 +00:00
|
|
|
|
_using=ct.Not_Exist)
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L1)
|
2021-07-27 08:05:21 +00:00
|
|
|
|
def test_connection_init_collection_connection(self, host, port):
|
2021-06-18 08:26:07 +00:00
|
|
|
|
"""
|
|
|
|
|
target: create collection then disconnection
|
|
|
|
|
method: connection, init collection, then disconnection
|
|
|
|
|
expected: check result
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=host, port=port,
|
|
|
|
|
check_task=ct.CheckTasks.ccr)
|
|
|
|
|
|
|
|
|
|
# init collection successfully
|
2021-07-27 08:05:21 +00:00
|
|
|
|
collection_name = cf.gen_unique_str('connection_test_')
|
|
|
|
|
schema = cf.gen_default_collection_schema()
|
2021-06-18 08:26:07 +00:00
|
|
|
|
self.collection_wrap.init_collection(name=collection_name, schema=schema, _using=DefaultConfig.DEFAULT_USING)
|
|
|
|
|
|
|
|
|
|
# remove connection
|
|
|
|
|
self.connection_wrap.remove_connection(alias=DefaultConfig.DEFAULT_USING)
|
|
|
|
|
|
|
|
|
|
# drop collection failed
|
|
|
|
|
self.collection_wrap.drop(check_task=ct.CheckTasks.err_res,
|
|
|
|
|
check_items={ct.err_code: 0, ct.err_msg: "should create connect first"})
|
|
|
|
|
|
|
|
|
|
# successfully created default connection
|
|
|
|
|
self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=host, port=port,
|
|
|
|
|
check_task=ct.CheckTasks.ccr)
|
|
|
|
|
|
|
|
|
|
# drop collection success
|
|
|
|
|
self.collection_wrap.drop()
|
2021-09-02 05:22:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestConnect:
|
|
|
|
|
|
|
|
|
|
def local_ip(self, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
check if ip is localhost or not
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
if not args["ip"] or args["ip"] == 'localhost' or args["ip"] == "127.0.0.1":
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
def test_close_repeatedly(self, dis_connect, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test disconnect repeatedly
|
|
|
|
|
method: disconnect a connected client, disconnect again
|
|
|
|
|
expected: raise an error after disconnected
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-10 11:26:01 +00:00
|
|
|
|
with pytest.raises(Exception) as e:
|
|
|
|
|
dis_connect.close()
|
2021-09-02 05:22:10 +00:00
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
def test_connect_uri(self, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test connect with correct uri
|
|
|
|
|
method: uri format and value are both correct
|
|
|
|
|
expected: connected is True
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
|
|
|
milvus = get_milvus(args["ip"], args["port"], uri=uri_value, handler=args["handler"])
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
def test_connect_uri_null(self, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test connect with null uri
|
|
|
|
|
method: uri set null
|
|
|
|
|
expected: connected is True
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
uri_value = ""
|
|
|
|
|
if self.local_ip(args):
|
|
|
|
|
milvus = get_milvus(None, None, uri=uri_value, handler=args["handler"])
|
|
|
|
|
else:
|
|
|
|
|
with pytest.raises(Exception) as e:
|
|
|
|
|
milvus = get_milvus(None, None, uri=uri_value, handler=args["handler"])
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
def test_connect_with_multiprocess(self, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test uri connect with multiprocess
|
|
|
|
|
method: set correct uri, test with multiprocessing connecting
|
2021-12-02 14:24:26 +00:00
|
|
|
|
expected: all connections are connected
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
|
|
|
|
|
def connect():
|
|
|
|
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
|
|
|
|
assert milvus
|
|
|
|
|
|
|
|
|
|
with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
|
|
|
|
|
future_results = {executor.submit(
|
|
|
|
|
connect): i for i in range(100)}
|
|
|
|
|
for future in concurrent.futures.as_completed(future_results):
|
|
|
|
|
future.result()
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
def test_connect_repeatedly(self, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test connect repeatedly
|
|
|
|
|
method: connect again
|
|
|
|
|
expected: status.code is 0, and status.message shows have connected already
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
uri_value = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
|
|
|
milvus = Milvus(uri=uri_value, handler=args["handler"])
|
|
|
|
|
milvus = Milvus(uri=uri_value, handler=args["handler"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestConnectIPInvalid(object):
|
|
|
|
|
"""
|
|
|
|
|
Test connect server with invalid ip
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(
|
|
|
|
|
scope="function",
|
|
|
|
|
params=gen_invalid_ips()
|
|
|
|
|
)
|
|
|
|
|
def get_invalid_ip(self, request):
|
|
|
|
|
yield request.param
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
@pytest.mark.timeout(CONNECT_TIMEOUT)
|
|
|
|
|
def test_connect_with_invalid_ip(self, args, get_invalid_ip):
|
|
|
|
|
ip = get_invalid_ip
|
|
|
|
|
with pytest.raises(Exception) as e:
|
|
|
|
|
milvus = get_milvus(ip, args["port"], args["handler"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestConnectPortInvalid(object):
|
|
|
|
|
"""
|
|
|
|
|
Test connect server with invalid ip
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(
|
|
|
|
|
scope="function",
|
|
|
|
|
params=gen_invalid_ints()
|
|
|
|
|
)
|
|
|
|
|
def get_invalid_port(self, request):
|
|
|
|
|
yield request.param
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
@pytest.mark.timeout(CONNECT_TIMEOUT)
|
|
|
|
|
def test_connect_with_invalid_port(self, args, get_invalid_port):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test ip:port connect with invalid port value
|
|
|
|
|
method: set port in gen_invalid_ports
|
|
|
|
|
expected: connected is False
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
port = get_invalid_port
|
|
|
|
|
with pytest.raises(Exception) as e:
|
|
|
|
|
milvus = get_milvus(args["ip"], port, args["handler"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestConnectURIInvalid(object):
|
|
|
|
|
"""
|
|
|
|
|
Test connect server with invalid uri
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(
|
|
|
|
|
scope="function",
|
|
|
|
|
params=gen_invalid_uris()
|
|
|
|
|
)
|
|
|
|
|
def get_invalid_uri(self, request):
|
|
|
|
|
yield request.param
|
|
|
|
|
|
|
|
|
|
@pytest.mark.tags(ct.CaseLabel.L2)
|
|
|
|
|
@pytest.mark.timeout(CONNECT_TIMEOUT)
|
|
|
|
|
def test_connect_with_invalid_uri(self, get_invalid_uri, args):
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
target: test uri connect with invalid uri value
|
|
|
|
|
method: set port in gen_invalid_uris
|
|
|
|
|
expected: connected is False
|
2021-09-17 08:13:50 +00:00
|
|
|
|
"""
|
2021-09-02 05:22:10 +00:00
|
|
|
|
uri_value = get_invalid_uri
|
|
|
|
|
with pytest.raises(Exception) as e:
|
|
|
|
|
milvus = get_milvus(uri=uri_value, handler=args["handler"])
|