mirror of https://github.com/milvus-io/milvus.git
Add test cases of connection (#5517)
* Add test cases of connection Signed-off-by: wangting0128 <ting.wang@zilliz.com> * Update code Signed-off-by: wangting0128 <ting.wang@zilliz.com>pull/5550/head^2
parent
cc517570ab
commit
56da071cce
|
@ -77,7 +77,15 @@ class Base:
|
|||
self.utility = ApiUtility()
|
||||
|
||||
def teardown(self):
|
||||
pass
|
||||
try:
|
||||
""" Delete connection and reset configuration"""
|
||||
res, cr = self.connection.list_connections()
|
||||
for i in res:
|
||||
if self.connection.get_connection(alias=i)[1]:
|
||||
self.connection.remove_connection(i, check_res='')
|
||||
self.connection.configure()
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
@pytest.fixture(scope="module", autouse=True)
|
||||
def initialize_env(self, request):
|
||||
|
@ -97,18 +105,18 @@ class ApiReq(Base):
|
|||
Public methods that can be used to add cases.
|
||||
"""
|
||||
|
||||
@pytest.fixture(scope="module",params=ct.get_invalid_strs)
|
||||
@pytest.fixture(scope="module", params=ct.get_invalid_strs)
|
||||
def get_invalid_string(self, request):
|
||||
yield request.param
|
||||
|
||||
@pytest.fixture(scope="module",params=cf.gen_simple_index())
|
||||
@pytest.fixture(scope="module", params=cf.gen_simple_index())
|
||||
def get_index_param(self, request):
|
||||
yield request.param
|
||||
|
||||
def _connect(self):
|
||||
""" Testing func """
|
||||
self.connection.configure(check_res='', default={"host": "192.168.1.240", "port": 19530})
|
||||
res, _ = self.connection.create_connection(alias='default')
|
||||
self.connection.configure(check_res='', default={"host": param_info.param_host, "port": param_info.param_port})
|
||||
res = self.connection.create_connection(alias='default')
|
||||
return res
|
||||
|
||||
def _collection(self, name=None, data=None, schema=None, check_res=None, **kwargs):
|
||||
|
|
|
@ -43,68 +43,68 @@ class ApiCollection:
|
|||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([Collection, name, data, schema], **kwargs)
|
||||
self.collection = res if check is True else None
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, name=name, data=data, schema=schema, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, name=name, data=data, schema=schema, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def schema(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.schema])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def description(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.description])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def name(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def is_empty(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.is_empty])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def num_entities(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.num_entities])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def primary_field(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.primary_field])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def drop(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.drop], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def load(self, field_names=None, index_names=None, partition_names=None, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.load, field_names, index_names, partition_names], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, field_names=field_names, index_names=index_names,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, field_names=field_names, index_names=index_names,
|
||||
partition_names=partition_names, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def release(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.release], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def insert(self, data, partition_name=None, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.insert, data, partition_name], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, dat=data, partition_name=partition_name, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, dat=data, partition_name=partition_name, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def search(self, data, anns_field, param, limit, expression, partition_names=None, output_fields=None, timeout=None,
|
||||
|
@ -112,7 +112,7 @@ class ApiCollection:
|
|||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.search, data, anns_field, param, limit, expression, partition_names,
|
||||
output_fields, timeout], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, data=data, anns_field=anns_field, param=param, limit=limit,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, data=data, anns_field=anns_field, param=param, limit=limit,
|
||||
expression=expression, partition_names=partition_names, output_fields=output_fields,
|
||||
timeout=timeout, **kwargs).run()
|
||||
return res, check_result
|
||||
|
@ -120,54 +120,54 @@ class ApiCollection:
|
|||
def partitions(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.partitions])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def partition(self, partition_name, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.partition, partition_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, partition_name=partition_name).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, partition_name=partition_name).run()
|
||||
return res, check_result
|
||||
|
||||
def has_partition(self, partition_name, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.has_partition, partition_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, partition_name=partition_name).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, partition_name=partition_name).run()
|
||||
return res, check_result
|
||||
|
||||
def drop_partition(self, partition_name, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.drop_partition, partition_name], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, partition_name=partition_name, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, partition_name=partition_name, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def indexes(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.indexes])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def index(self, index_name="", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.index, index_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, index_name=index_name).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, index_name=index_name).run()
|
||||
return res, check_result
|
||||
|
||||
def create_index(self, field_name, index_params, index_name="", check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.create_index, field_name, index_params, index_name], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, field_name=field_name, index_params=index_params,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, field_name=field_name, index_params=index_params,
|
||||
index_name=index_name, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def has_index(self, index_name="", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.has_index, index_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, index_name=index_name).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, index_name=index_name).run()
|
||||
return res, check_result
|
||||
|
||||
def drop_index(self, index_name="", check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.collection.drop_index, index_name], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, index_name=index_name, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, index_name=index_name, **kwargs).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -42,35 +42,35 @@ class ApiConnections:
|
|||
def configure(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.configure], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def remove_connection(self, alias, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.remove_connection, alias])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, alias=alias).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, alias=alias).run()
|
||||
return res, check_result
|
||||
|
||||
def create_connection(self, alias=DefaultConfig.DEFAULT_USING, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.create_connection, alias], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, alias=alias, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, alias=alias, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def get_connection(self, alias=DefaultConfig.DEFAULT_USING, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.get_connection, alias])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, alias=alias).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, alias=alias).run()
|
||||
return res, check_result
|
||||
|
||||
def list_connections(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.list_connections])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def get_connection_addr(self, alias, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.connection.get_connection_addr, alias])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, alias=alias).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, alias=alias).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -43,36 +43,36 @@ class ApiIndex:
|
|||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([Index, collection, field_name, index_params, name], **kwargs)
|
||||
self.index = res if check is True else None
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection=collection, field_name=field_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection=collection, field_name=field_name,
|
||||
index_params=index_params, name=name, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def name(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.index.name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def params(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.index.params])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def collection_name(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.index.collection_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def field_name(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.index.field_name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def drop(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.index.drop], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -50,7 +50,7 @@ class ApiPartition:
|
|||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([Partition, collection, name, description], **kwargs)
|
||||
self.partition = res if check is True else None
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check,
|
||||
collection=collection, name=name, description=description,
|
||||
is_empty=True, num_entities=0,
|
||||
**kwargs).run()
|
||||
|
@ -59,55 +59,55 @@ class ApiPartition:
|
|||
def description(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.description])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def name(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.name])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def is_empty(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.is_empty])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def num_entities(self, check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.num_entities])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check).run()
|
||||
return res, check_result
|
||||
|
||||
def drop(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.drop], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def load(self, field_names=None, index_names=None, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.load, field_names, index_names], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, field_names=field_names, index_names=index_names,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, field_names=field_names, index_names=index_names,
|
||||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def release(self, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.release], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def insert(self, data, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.insert, data], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, data=data, **kwargs).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, data=data, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def search(self, data, anns_field, params, limit, expr=None, output_fields=None, check_res=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.partition.search, data, anns_field, params, limit, expr, output_fields], **kwargs)
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, data=data, anns_field=anns_field, params=params,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, data=data, anns_field=anns_field, params=params,
|
||||
limit=limit, expr=expr, output_fields=output_fields, **kwargs).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -43,46 +43,46 @@ class ApiUtility:
|
|||
def loading_progress(self, collection_name, partition_names=[], using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.loading_progress, collection_name, partition_names, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name,
|
||||
partition_names=partition_names,using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def wait_for_loading_complete(self, collection_name, partition_names=[], timeout=None, using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.wait_for_loading_complete, collection_name, partition_names, timeout, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name,
|
||||
partition_names=partition_names, timeout=timeout, using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def index_building_progress(self, collection_name, index_name="", using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.index_building_progress, collection_name, index_name, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name, index_name=index_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name, index_name=index_name,
|
||||
using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def wait_for_index_building_complete(self, collection_name, index_name="", timeout=None, using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.wait_for_loading_complete, collection_name, index_name, timeout, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name, index_name=index_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name, index_name=index_name,
|
||||
timeout=timeout, using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def has_collection(self, collection_name, using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.has_collection, collection_name, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name, using=using).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name, using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def has_partition(self, collection_name, partition_name, using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.has_partition, collection_name, partition_name, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, collection_name=collection_name,
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, collection_name=collection_name,
|
||||
partition_name=partition_name, using=using).run()
|
||||
return res, check_result
|
||||
|
||||
def list_collections(self, timeout=None, using="default", check_res=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = func_req([self.ut.list_collections, timeout, using])
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, timeout=timeout, using=using).run()
|
||||
check_result = CheckFunc(res, func_name, check_res, check_params, check, timeout=timeout, using=using).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -4,11 +4,12 @@ from pymilvus_orm import Collection, Partition
|
|||
|
||||
|
||||
class CheckFunc:
|
||||
def __init__(self, res, func_name, check_res, check_params, **kwargs):
|
||||
def __init__(self, res, func_name, check_res, check_params, check_res_result=True, **kwargs):
|
||||
self.res = res # response of api request
|
||||
self.func_name = func_name
|
||||
self.check_res = check_res
|
||||
self.check_params = check_params
|
||||
self.check_res_result = check_res_result
|
||||
self.params = {}
|
||||
|
||||
for key, value in kwargs.items():
|
||||
|
@ -17,11 +18,14 @@ class CheckFunc:
|
|||
self.keys = self.params.keys()
|
||||
|
||||
def run(self):
|
||||
check_result = None
|
||||
check_result = True
|
||||
|
||||
if self.check_res is None:
|
||||
pass
|
||||
# log.info("self.check_res is None, the response of API: %s" % self.res)
|
||||
assert self.check_res_result is True
|
||||
check_result = True
|
||||
elif self.check_res == CheckParams.false:
|
||||
assert self.check_res_result is False
|
||||
check_result = False
|
||||
elif self.check_res == CheckParams.cname_param_check:
|
||||
check_result = self.req_cname_check(self.res, self.func_name, self.params.get('collection_name'))
|
||||
elif self.check_res == CheckParams.pname_param_check:
|
||||
|
@ -32,6 +36,7 @@ class CheckFunc:
|
|||
check_result = self.req_collection_property_check(self.res, self.func_name, self.params)
|
||||
elif self.check_res == CheckParams.partition_property_check:
|
||||
check_result = self.partition_property_check(self.res, self.func_name, self.params)
|
||||
|
||||
return check_result
|
||||
|
||||
@staticmethod
|
||||
|
|
|
@ -30,6 +30,8 @@ float_field_desc = "float type field"
|
|||
float_vec_field_desc = "float vector type field"
|
||||
binary_vec_field_desc = "binary vector type field"
|
||||
|
||||
Not_Exist = "Not_Exist"
|
||||
|
||||
|
||||
"""" List of parameters used to pass """
|
||||
get_invalid_strs = [
|
||||
|
@ -68,6 +70,7 @@ structure_metrics = ["SUBSTRUCTURE", "SUPERSTRUCTURE"]
|
|||
|
||||
class CheckParams:
|
||||
""" The name of the method used to check the result """
|
||||
false = False
|
||||
cname_param_check = "collection_name_param_check"
|
||||
pname_param_check = "partition_name_param_check"
|
||||
list_count = "check_list_count"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[pytest]
|
||||
|
||||
addopts = --host 192.168.1.240 --html=/Users/wt/Desktop/report.html
|
||||
;addopts = --host 172.28.255.155 --html=/tmp/report.html
|
||||
addopts = --host 192.168.1.239 --html=/Users/wt/Desktop/report.html
|
||||
-;addopts = --host 172.28.255.155 --html=/tmp/report.html
|
||||
# python3 -W ignore -m pytest
|
|
@ -1,35 +1,298 @@
|
|||
import pytest
|
||||
|
||||
from pymilvus_orm.default_config import DefaultConfig
|
||||
from base.client_request import ApiReq
|
||||
from utils.util_log import test_log as log
|
||||
from common.common_type import *
|
||||
|
||||
|
||||
class TestConnection(ApiReq):
|
||||
""" Test case of connections interface """
|
||||
class TestConnectionParams(ApiReq):
|
||||
"""
|
||||
Test case of connections interface
|
||||
The author : Ting.Wang
|
||||
"""
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L3)
|
||||
def test_case(self):
|
||||
self.connection.configure(check_res='', default={"host": "192.168.1.240", "port": "19530"})
|
||||
res_ = self.connection.get_connection(alias='default')
|
||||
log.info("res : %s" % str(res_))
|
||||
log.info("self.connection : %s" % str(self.connection))
|
||||
res_list = self.connection.list_connections()
|
||||
log.info(res_list)
|
||||
@pytest.mark.skip("No check for **kwargs")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_kwargs_param_check(self):
|
||||
"""
|
||||
target: test **kwargs of connection
|
||||
method: passing wrong parameters of **kwargs
|
||||
expected: assert response is error
|
||||
"""
|
||||
|
||||
def test_wt(self):
|
||||
res_configure = self.connection.configure(check_res='', default={"host": "192.168.1.240", "port": "19530"})
|
||||
log.info(res_configure)
|
||||
res_list, che = self.connection.list_connections(check_res='')
|
||||
log.info(res_list)
|
||||
for i in res_list:
|
||||
log.info("!" * 20)
|
||||
log.info(self.connection.remove_connection(alias=i))
|
||||
res_list = self.connection.list_connections(check_res='')
|
||||
log.info(res_list)
|
||||
log.info("!" * 20)
|
||||
log.info(self.utility.list_collections())
|
||||
# No check for **kwargs
|
||||
res, check_result = self.connection.configure(_kwargs=[1, 2])
|
||||
log.info(res)
|
||||
|
||||
def test_check_res(self):
|
||||
self.connection.configure(check_res='', check_params=None, default={"host": "192.168.1.240", "port": "19530"})
|
||||
res, cr = self.connection.get_connection_addr(alias='default')
|
||||
assert res == {}
|
||||
|
||||
# No check for **kwargs
|
||||
res, check_result = self.connection.create_connection(alias=DefaultConfig.DEFAULT_USING, _kwargs=[1, 2])
|
||||
log.info(res.args[0])
|
||||
assert res.args[0] == "Fail connecting to server on localhost:19530. Timeout"
|
||||
|
||||
@pytest.mark.skip("No check for alias")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("alias", get_invalid_strs)
|
||||
def test_connection_create_alias_param_check(self, alias):
|
||||
"""
|
||||
target: test create connection with wrong params of alias
|
||||
method: create connection with wrong params of alias
|
||||
expected: assert response is error
|
||||
"""
|
||||
# No check for alias
|
||||
res, cr = self.connection.create_connection(alias=alias)
|
||||
log.info(res)
|
||||
|
||||
@pytest.mark.skip("No check for alias")
|
||||
@pytest.mark.parametrize("alias", get_invalid_strs)
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_get_alias_param_check(self, alias):
|
||||
"""
|
||||
target: test get connection with wrong params of alias
|
||||
method: get connection with wrong params of alias
|
||||
expected: assert response is error
|
||||
"""
|
||||
# not check for alias
|
||||
res, cr = self.connection.get_connection(alias=alias)
|
||||
log.info(res)
|
||||
|
||||
@pytest.mark.skip("No check for alias")
|
||||
@pytest.mark.parametrize("alias", get_invalid_strs)
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_get_addr_alias_param_check(self, alias):
|
||||
"""
|
||||
target: test get connection addr with wrong params of alias
|
||||
method: get connection addr with wrong params of alias
|
||||
expected: assert response is error
|
||||
"""
|
||||
# not check for alias
|
||||
res, cr = self.connection.get_connection_addr(alias=alias)
|
||||
log.info(res)
|
||||
|
||||
@pytest.mark.skip("No check for alias")
|
||||
@pytest.mark.parametrize("alias", get_invalid_strs)
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_remove_alias_param_check(self, alias):
|
||||
"""
|
||||
target: test remove connection with wrong params of alias
|
||||
method: remove connection with wrong params of alias
|
||||
expected: assert response is error
|
||||
"""
|
||||
# not check for alias
|
||||
self._connect()
|
||||
res, cr = self.connection.remove_connection(alias=alias)
|
||||
log.info(res)
|
||||
|
||||
|
||||
class TestConnectionOperation(ApiReq):
|
||||
"""
|
||||
Test case of connections interface
|
||||
The author : Ting.Wang
|
||||
"""
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_configure_repeat(self, host, port):
|
||||
"""
|
||||
target: test connection configure four times
|
||||
method: connection configure twice with the same params
|
||||
expected: assert the configuration is successful
|
||||
"""
|
||||
self.connection.configure(default={"host": host, "port": port}, dev={"host": host, "port": port})
|
||||
assert self.connection.list_connections()[0] == ['default', 'dev']
|
||||
assert self.connection.get_connection_addr(alias='default')[0] == {}
|
||||
|
||||
self.connection.configure(default={"host": host, "port": port}, dev={"host": host, "port": port})
|
||||
assert self.connection.list_connections()[0] == ['default', 'dev']
|
||||
|
||||
self.connection.configure(default1={"host": host, "port": port})
|
||||
assert self.connection.list_connections()[0] == ['default1']
|
||||
|
||||
self.connection.configure()
|
||||
assert self.connection.list_connections()[0] == []
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_remove_connection_not_exist(self):
|
||||
"""
|
||||
target: test remove connection that is not exist
|
||||
method: 1、remove connection that is not exist
|
||||
2、create connection with default alias
|
||||
3、remove connection that is not exist
|
||||
expected: assert alias of Not_exist is not exist
|
||||
"""
|
||||
res, cr = self.connection.remove_connection(alias=Not_Exist, check_res="")
|
||||
assert res.args[0] == "There is no connection with alias '%s'." % Not_Exist
|
||||
|
||||
self._connect()
|
||||
|
||||
res, cr = self.connection.remove_connection(alias=Not_Exist, check_res="")
|
||||
assert res.args[0] == "There is no connection with alias '%s'." % Not_Exist
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_remove_connection_repeat(self):
|
||||
"""
|
||||
target: test remove connection twice
|
||||
method: remove connection twice
|
||||
expected: assert the second response is an error
|
||||
"""
|
||||
self._connect()
|
||||
|
||||
self.connection.remove_connection(alias='default')
|
||||
|
||||
res, cr = self.connection.remove_connection(alias='default', check_res='')
|
||||
assert res.args[0] == "There is no connection with alias 'default'."
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_normal_remove_connection_repeat(self, host, port):
|
||||
"""
|
||||
target: test remove connection twice
|
||||
method: remove connection twice
|
||||
expected: assert the responses are True
|
||||
"""
|
||||
self.connection.configure(default={"host": host, "port": port}, dev={"host": host, "port": port})
|
||||
|
||||
self.connection.create_connection(alias='default')
|
||||
res, cr = self.connection.get_connection_addr(alias='default')
|
||||
assert res["host"] == host
|
||||
assert res["port"] == port
|
||||
self.connection.create_connection(alias='dev')
|
||||
|
||||
self.connection.remove_connection(alias='default')
|
||||
self.connection.remove_connection(alias='dev')
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_remove_connection_100_repeat(self):
|
||||
"""
|
||||
target: test delete the same connection 100 times
|
||||
method: delete the same connection 100 times
|
||||
expected: assert the remaining 99 delete errors
|
||||
"""
|
||||
self._connect()
|
||||
self.connection.remove_connection(alias='default')
|
||||
|
||||
for i in range(100):
|
||||
res, cr = self.connection.remove_connection(alias='default', check_res='')
|
||||
assert res.args[0] == "There is no connection with alias 'default'."
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_configure_remove_connection(self, host, port):
|
||||
"""
|
||||
target: test remove configure alias
|
||||
method: remove configure alias
|
||||
expected: assert res is err
|
||||
"""
|
||||
self.connection.configure(default={"host": host, "port": port})
|
||||
alias_name = 'default'
|
||||
|
||||
res, cr = self.connection.remove_connection(alias=alias_name, check_res='')
|
||||
assert res.args[0] == "There is no connection with alias '%s'." % alias_name
|
||||
|
||||
@pytest.mark.skip("error res")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_connection_remove_configure(self, host, port):
|
||||
"""
|
||||
target: test create connection before remove configure
|
||||
method: create connection before reset configure
|
||||
expected: assert res
|
||||
"""
|
||||
alias_name = "default"
|
||||
self.connection.create_connection(alias=alias_name, host=host, port=port)
|
||||
self.connection.configure()
|
||||
self.connection.get_connection(alias=alias_name)
|
||||
|
||||
@pytest.mark.skip("error res")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_connection_reset_configure(self, host, port):
|
||||
"""
|
||||
target: test params of create connection are different with configure
|
||||
method: params of create connection are different with configure
|
||||
expected: assert res
|
||||
"""
|
||||
alias_name = "default"
|
||||
self.connection.create_connection(alias=alias_name, host=host, port=port)
|
||||
self.connection.configure(default={'host': host, 'port': port})
|
||||
self.connection.get_connection(alias=alias_name)
|
||||
|
||||
@pytest.mark.skip("res needs to be confirmed")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_connection_diff_configure(self, host, port):
|
||||
"""
|
||||
target: test params of create connection are different with configure
|
||||
method: params of create connection are different with configure
|
||||
expected: assert res
|
||||
"""
|
||||
# error
|
||||
self.connection.configure(default={"host": 'host', "port": port})
|
||||
res, cr = self.connection.create_connection(alias="default", host=host, port=port, check_res='')
|
||||
log.info(res)
|
||||
res, cr = self.connection.create_connection(alias="default", host=host, port=port, check_res='')
|
||||
log.info(res)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_connection_repeat(self, host, port):
|
||||
"""
|
||||
target: test create connection twice
|
||||
method: create connection twice
|
||||
expected: res is True
|
||||
"""
|
||||
self._connect()
|
||||
self.connection.get_connection(alias='default')
|
||||
self.connection.list_connections(check_res=CheckParams.list_count, check_params={"list_count": 1})
|
||||
|
||||
self.connection.create_connection(alias='default', host=host, port=port)
|
||||
self.connection.get_connection(alias='default')
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_connection_not_exist(self, port):
|
||||
"""
|
||||
target: test create connection is not exist
|
||||
method: create connection with not exist link
|
||||
expected: assert res is wrong
|
||||
"""
|
||||
self.connection.get_connection(alias='default', check_res=CheckParams.false)
|
||||
res, cr = self.connection.create_connection(alias="default", host='host', port=port, check_res='')
|
||||
assert res.args[0] == "Fail connecting to server on host:19530. Timeout"
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_create_remove(self, host, port):
|
||||
"""
|
||||
target: test create and remove connection twice
|
||||
method: create and remove connection twice
|
||||
expected: assert res is correct
|
||||
"""
|
||||
alias_name = "default"
|
||||
self.connection.create_connection(alias=alias_name, host=host, port=port)
|
||||
self.connection.get_connection(alias=alias_name)
|
||||
self.connection.remove_connection(alias=alias_name)
|
||||
self.connection.get_connection(alias=alias_name, check_res=CheckParams.false)
|
||||
self.connection.create_connection(alias=alias_name, host=host, port=port)
|
||||
self.connection.get_connection(alias=alias_name)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_list_configure(self, host, port):
|
||||
"""
|
||||
target: test list connection of configure
|
||||
method: list connection of configure
|
||||
expected: assert res is correct
|
||||
"""
|
||||
self.connection.configure(default={"host": host, "port": port}, dev={"host": host, "port": port})
|
||||
self.connection.create_connection(alias="default")
|
||||
assert self.connection.list_connections()[0] == ['default', 'dev']
|
||||
|
||||
@pytest.mark.skip("Behavior to be determined")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_connection_list_create_configure(self, host, port):
|
||||
"""
|
||||
target: test list connection of configure
|
||||
method: list connection of configure
|
||||
expected: assert res is correct
|
||||
"""
|
||||
self.connection.create_connection(alias="default1", host=host, port=port)
|
||||
self.connection.configure(default={"host": host, "port": port}, dev={"host": host, "port": port})
|
||||
log.info(self.connection.list_connections()[0])
|
||||
assert self.connection.list_connections()[0] == ['default', 'dev']
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue