mirror of https://github.com/milvus-io/milvus.git
refactor wrappers (#5642)
* [skip ci] Refactor function names Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com> * [skip ci]Refactor wrappers Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>pull/5643/head
parent
bc46e4780d
commit
6e9a4e366e
|
@ -39,7 +39,7 @@ class SearchChecker(Checker):
|
|||
data=search_vec,
|
||||
params={"nprobe": 32},
|
||||
limit=1,
|
||||
check_res="nothing"
|
||||
check_task="nothing"
|
||||
)
|
||||
if result is True:
|
||||
self._succ += 1
|
||||
|
@ -56,7 +56,7 @@ class InsertChecker(Checker):
|
|||
while self._running is True:
|
||||
sleep(1)
|
||||
_, result = self.c_wrapper.insert(data=cf.gen_default_list_data(),
|
||||
check_res="nothing")
|
||||
check_task="nothing")
|
||||
if result is True:
|
||||
self._succ += 1
|
||||
else:
|
||||
|
@ -72,11 +72,11 @@ class CreateChecker(Checker):
|
|||
def keep_creating(self):
|
||||
while self._running is True:
|
||||
collection, result = self.c_wrapper.collection_init(name=cf.gen_unique_str(),
|
||||
schema=cf.gen_default_collection_schema(),
|
||||
check_res="check_nothing")
|
||||
schema=cf.gen_default_collection_schema(),
|
||||
check_task="check_nothing")
|
||||
if result is True:
|
||||
self._succ += 1
|
||||
self.c_wrapper.drop(check_res="check_nothing")
|
||||
self.c_wrapper.drop(check_task="check_nothing")
|
||||
else:
|
||||
self._fail += 1
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class TestsChaos:
|
|||
c_wrapper = ApiCollectionWrapper()
|
||||
c_wrapper.collection_init(name=cf.gen_unique_str(),
|
||||
schema=cf.gen_default_collection_schema(),
|
||||
check_res="check_nothing")
|
||||
check_task="check_nothing")
|
||||
return c_wrapper
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
|
@ -35,8 +35,8 @@ class TestsChaos:
|
|||
raise Exception("no connections")
|
||||
c_wrapper = ApiCollectionWrapper()
|
||||
_, result = c_wrapper.collection_init(name=cf.gen_unique_str(),
|
||||
schema=cf.gen_default_collection_schema(),
|
||||
check_res="check_nothing")
|
||||
schema=cf.gen_default_collection_schema(),
|
||||
check_task="check_nothing")
|
||||
if result is False:
|
||||
log.log("result: ")
|
||||
# for _ in range(10):
|
||||
|
|
|
@ -36,8 +36,6 @@ class Base:
|
|||
partition_wrap = None
|
||||
index_wrap = None
|
||||
utility_wrap = None
|
||||
partition_mul = None
|
||||
collection_mul = None
|
||||
|
||||
def setup_class(self):
|
||||
log.info("[setup_class] Start setup class...")
|
||||
|
@ -52,8 +50,6 @@ class Base:
|
|||
self.partition_wrap = ApiPartitionWrapper()
|
||||
self.index_wrap = ApiIndexWrapper()
|
||||
self.utility_wrap = ApiUtilityWrapper()
|
||||
self.partition_mul = ()
|
||||
self.collection_mul = ()
|
||||
|
||||
def teardown(self):
|
||||
log.info(("*" * 35) + " teardown " + ("*" * 35))
|
||||
|
@ -105,40 +101,32 @@ class TestcaseBase(Base):
|
|||
res, _ = self.connection_wrap.connect(alias='default')
|
||||
return res
|
||||
|
||||
def _collection(self, name=None, data=None, schema=None, check_res=None, c_object=None, **kwargs):
|
||||
def _collection(self, **kwargs):
|
||||
""" Init a collection and return the object of collection """
|
||||
name = cf.gen_unique_str("ApiReq") if name is None else name
|
||||
name = cf.gen_unique_str()
|
||||
schema = cf.gen_default_collection_schema()
|
||||
if self.connection_wrap.get_connection(alias='default') is None:
|
||||
self._connect()
|
||||
res, cr = self.collection_wrap.collection_init(name=name, schema=schema, **kwargs)
|
||||
return res
|
||||
|
||||
def init_collection_wrap(self, name=None, data=None, schema=None, check_task=None, **kwargs):
|
||||
name = cf.gen_unique_str('coll_') if name is None else name
|
||||
schema = cf.gen_default_collection_schema() if schema is None else schema
|
||||
c_object = self.collection_wrap if c_object is None else c_object
|
||||
if self.connection_wrap.get_connection(alias='default')[0] is None:
|
||||
self._connect()
|
||||
collection_w = ApiCollectionWrapper()
|
||||
collection_w.collection_init(name=name, data=data, schema=schema,
|
||||
check_task=check_task, **kwargs)
|
||||
return collection_w
|
||||
|
||||
self._connect()
|
||||
|
||||
res, cr = c_object.collection_init(name=name, data=data, schema=schema, check_res=check_res, **kwargs)
|
||||
assert name == c_object.name
|
||||
return res
|
||||
|
||||
def _partition(self, c_object=None, p_object=None, name=None, descriptions=None, **kwargs):
|
||||
""" Init a partition in a collection and return the object of partition """
|
||||
c_object = self.collection_wrap.collection if c_object is None else c_object
|
||||
p_object = self.partition_wrap if p_object is None else p_object
|
||||
def init_partition_wrap(self, collection_wrap, name=None, description=None,
|
||||
negative=False, check_task=None, **kwargs):
|
||||
name = cf.gen_unique_str("partition_") if name is None else name
|
||||
descriptions = cf.gen_unique_str("partition_des_") if descriptions is None else descriptions
|
||||
|
||||
res, cr = p_object.partition_init(c_object, name, description=descriptions, **kwargs)
|
||||
return res
|
||||
|
||||
def _collection_object_multiple(self, mul_number=2):
|
||||
""" Initialize multiple objects of collection and return the list of objects """
|
||||
for i in range(int(mul_number)):
|
||||
par = ApiCollectionWrapper()
|
||||
self.collection_mul += (par, )
|
||||
log.debug("[_collection_object_multiple] All objects of collection are : %s" % str(self.collection_mul))
|
||||
return self.collection_mul
|
||||
|
||||
def _partition_object_multiple(self, mul_number=2):
|
||||
""" Initialize multiple objects of partition in a collection and return the list of objects """
|
||||
for i in range(int(mul_number)):
|
||||
par = ApiPartitionWrapper()
|
||||
self.partition_mul += (par, )
|
||||
log.debug("[_partition_object_multiple] All objects of partition are : %s" % str(self.partition_mul))
|
||||
return self.partition_mul
|
||||
description = cf.gen_unique_str("partition_des_") if description is None else description
|
||||
collection_wrap = self.init_collection_wrap() if collection_wrap is None else collection_wrap
|
||||
partition_wrap = ApiPartitionWrapper()
|
||||
partition_wrap.init_partition(collection_wrap.collection, name,
|
||||
description=description,
|
||||
check_task=check_task, **kwargs)
|
||||
return partition_wrap
|
||||
|
|
|
@ -1,25 +1,20 @@
|
|||
from pymilvus_orm import Collection
|
||||
from pymilvus_orm.types import DataType
|
||||
from pymilvus_orm.default_config import DefaultConfig
|
||||
import sys
|
||||
|
||||
sys.path.append("..")
|
||||
from check.param_check import *
|
||||
from check.func_check import *
|
||||
from utils.util_log import test_log as log
|
||||
from common.common_type import *
|
||||
from base.api_request import api_request
|
||||
from utils.api_request import api_request
|
||||
|
||||
|
||||
class ApiCollectionWrapper:
|
||||
collection = None
|
||||
|
||||
def collection_init(self, name, data=None, schema=None, check_res=None, check_params=None, **kwargs):
|
||||
def collection_init(self, name, data=None, schema=None, check_task=None, check_params=None, **kwargs):
|
||||
""" In order to distinguish the same name of collection """
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([Collection, name, data, schema], **kwargs)
|
||||
self.collection = res if check is True else None
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, name=name, data=data, schema=schema, **kwargs).run()
|
||||
res, is_succ = api_request([Collection, name, data, schema], **kwargs)
|
||||
self.collection = res if is_succ else None
|
||||
check_result = ResponseChecker(res, func_name, check_task, check_params, is_succ, name=name, data=data, schema=schema, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
@property
|
||||
|
@ -119,16 +114,18 @@ class ApiCollectionWrapper:
|
|||
# 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):
|
||||
def partition(self, partition_name, check_task=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.collection.partition, partition_name])
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, partition_name=partition_name).run()
|
||||
res, succ = api_request([self.collection.partition, partition_name])
|
||||
check_result = ResponseChecker(res, func_name, check_task, check_params,
|
||||
succ, partition_name=partition_name).run()
|
||||
return res, check_result
|
||||
|
||||
def has_partition(self, partition_name, check_res=None, check_params=None):
|
||||
def has_partition(self, partition_name, check_task=None, check_params=None):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.collection.has_partition, partition_name])
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, partition_name=partition_name).run()
|
||||
res, succ = api_request([self.collection.has_partition, partition_name])
|
||||
check_result = ResponseChecker(res, func_name, check_task, check_params,
|
||||
succ, partition_name=partition_name).run()
|
||||
return res, check_result
|
||||
|
||||
def drop_partition(self, partition_name, check_res=None, check_params=None, **kwargs):
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
from pymilvus_orm import Connections
|
||||
from pymilvus_orm.types import DataType
|
||||
from pymilvus_orm.default_config import DefaultConfig
|
||||
import sys
|
||||
|
||||
sys.path.append("..")
|
||||
from check.param_check import *
|
||||
from check.func_check import *
|
||||
from base.api_request import api_request
|
||||
from utils.api_request import api_request
|
||||
|
||||
|
||||
class ApiConnectionsWrapper:
|
||||
|
|
|
@ -4,7 +4,7 @@ from pymilvus_orm import Index
|
|||
sys.path.append("..")
|
||||
from check.param_check import *
|
||||
from check.func_check import *
|
||||
from base.api_request import api_request
|
||||
from utils.api_request import api_request
|
||||
|
||||
|
||||
class ApiIndexWrapper:
|
||||
|
|
|
@ -1,31 +1,29 @@
|
|||
from pymilvus_orm import Partition
|
||||
from pymilvus_orm.types import DataType
|
||||
from pymilvus_orm.default_config import DefaultConfig
|
||||
import sys
|
||||
|
||||
sys.path.append("..")
|
||||
from check.param_check import *
|
||||
from check.func_check import *
|
||||
from base.api_request import api_request
|
||||
from utils.api_request import api_request
|
||||
|
||||
|
||||
class ApiPartitionWrapper:
|
||||
partition = None
|
||||
|
||||
def partition_init(self, collection, name, description="", check_res=None, check_params=None, **kwargs):
|
||||
def init_partition(self, collection, name, description="",
|
||||
check_task=None, check_params=None, **kwargs):
|
||||
""" In order to distinguish the same name of partition """
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([Partition, collection, name, description], **kwargs)
|
||||
self.partition = res if check is True else None
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check,
|
||||
response, is_succ = api_request([Partition, collection, name, description], **kwargs)
|
||||
self.partition = response if is_succ is True else None
|
||||
check_result = ResponseChecker(response, func_name, check_task, check_params, is_succ,
|
||||
collection=collection, name=name, description=description,
|
||||
is_empty=True, num_entities=0,
|
||||
**kwargs).run()
|
||||
return res, check_result
|
||||
return response, check_result
|
||||
|
||||
@property
|
||||
def description(self, check_res=None, check_params=None):
|
||||
return self.partition.description
|
||||
return self.partition.description if self.partition else 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, check).run()
|
||||
|
@ -33,7 +31,7 @@ class ApiPartitionWrapper:
|
|||
|
||||
@property
|
||||
def name(self, check_res=None, check_params=None):
|
||||
return self.partition.name
|
||||
return self.partition.name if self.partition else 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, check).run()
|
||||
|
@ -41,7 +39,7 @@ class ApiPartitionWrapper:
|
|||
|
||||
@property
|
||||
def is_empty(self, check_res=None, check_params=None):
|
||||
return self.partition.is_empty
|
||||
return self.partition.is_empty if self.partition else 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, check).run()
|
||||
|
@ -49,40 +47,51 @@ class ApiPartitionWrapper:
|
|||
|
||||
@property
|
||||
def num_entities(self, check_res=None, check_params=None):
|
||||
return self.partition.num_entities
|
||||
return self.partition.num_entities if self.partition else 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, check).run()
|
||||
# return res, check_result
|
||||
|
||||
def drop(self, check_res=None, check_params=None, **kwargs):
|
||||
def drop(self, check_task=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.partition.drop], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
res, succ = api_request([self.partition.drop], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task, check_params, succ, **kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def load(self, field_names=None, index_names=None, check_res=None, check_params=None, **kwargs):
|
||||
def load(self, field_names=None, index_names=None, check_task=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.partition.load, field_names, index_names], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, field_names=field_names, index_names=index_names,
|
||||
res, succ = api_request([self.partition.load, field_names, index_names], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task,
|
||||
check_params, is_succ=succ,
|
||||
field_names=field_names,
|
||||
index_names=index_names,
|
||||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def release(self, check_res=None, check_params=None, **kwargs):
|
||||
def release(self, check_task=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.partition.release], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, **kwargs).run()
|
||||
res, succ = api_request([self.partition.release], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task,
|
||||
check_params, is_succ=succ,
|
||||
**kwargs).run()
|
||||
return res, check_result
|
||||
|
||||
def insert(self, data, check_res=None, check_params=None, **kwargs):
|
||||
def insert(self, data, check_task=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.partition.insert, data], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_res, check_params, check, data=data, **kwargs).run()
|
||||
res, succ = api_request([self.partition.insert, data], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task,
|
||||
check_params, is_succ=succ, 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):
|
||||
def search(self, data, anns_field, params, limit, expr=None, output_fields=None,
|
||||
check_task=None, check_params=None, **kwargs):
|
||||
func_name = sys._getframe().f_code.co_name
|
||||
res, check = api_request([self.partition.search, data, anns_field, params, limit, expr, output_fields], **kwargs)
|
||||
check_result = ResponseChecker(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()
|
||||
res, succ = api_request([self.partition.search, data, anns_field, params,
|
||||
limit, expr, output_fields], **kwargs)
|
||||
check_result = ResponseChecker(res, func_name, check_task, check_params,
|
||||
is_succ=succ, data=data, anns_field=anns_field,
|
||||
params=params, limit=limit, expr=expr,
|
||||
output_fields=output_fields, **kwargs).run()
|
||||
return res, check_result
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
from pymilvus_orm import utility
|
||||
from pymilvus_orm.types import DataType
|
||||
from pymilvus_orm.default_config import DefaultConfig
|
||||
import sys
|
||||
|
||||
sys.path.append("..")
|
||||
from check.param_check import *
|
||||
from check.func_check import *
|
||||
from utils.util_log import test_log as log
|
||||
from common.common_type import *
|
||||
from base.api_request import api_request
|
||||
from utils.api_request import api_request
|
||||
|
||||
|
||||
class ApiUtilityWrapper:
|
||||
|
|
|
@ -1,49 +1,61 @@
|
|||
from utils.util_log import test_log as log
|
||||
from common.common_type import *
|
||||
from pymilvus_orm import Collection, Partition
|
||||
from utils.api_request import Error
|
||||
|
||||
|
||||
class ResponseChecker:
|
||||
def __init__(self, response, func_name, check_items, check_params, expect_succ=True, **kwargs):
|
||||
self.response = response # response of api request
|
||||
self.func_name = func_name
|
||||
self.check_items = check_items
|
||||
self.check_params = check_params
|
||||
self.expect_succ = expect_succ
|
||||
def __init__(self, response, func_name, check_task, check_params, is_succ=True, **kwargs):
|
||||
self.response = response # response of api request
|
||||
self.func_name = func_name # api function name
|
||||
self.check_task = check_task # task to check response of the api request
|
||||
self.check_items = check_params # check items and expectations that to be checked in check task
|
||||
self.succ = is_succ # api responses successful or not
|
||||
|
||||
# parse **kwargs. not used for now
|
||||
self.params = {}
|
||||
self.kwargs_dict = {} # not used for now, just for extantion
|
||||
for key, value in kwargs.items():
|
||||
self.params[key] = value
|
||||
self.keys = self.params.keys()
|
||||
self.kwargs_dict[key] = value
|
||||
self.keys = self.kwargs_dict.keys()
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Method: start response checking for milvus API call
|
||||
"""
|
||||
result = True
|
||||
if self.check_items is None:
|
||||
result = self.assert_expectation(self.expect_succ, True)
|
||||
if self.check_task is None:
|
||||
result = self.assert_succ(self.succ, True)
|
||||
|
||||
elif self.check_items == CheckParams.err_res:
|
||||
result = self.assert_expectation(self.expect_succ, False)
|
||||
elif self.check_task == CheckTasks.err_res:
|
||||
result = self.assert_exception(self.response, self.succ, self.kwargs_dict)
|
||||
|
||||
elif self.check_items == CheckParams.list_count and self.check_params is not None:
|
||||
elif self.check_task == CheckTasks.check_list_count and self.check_params is not None:
|
||||
result = self.check_list_count(self.response, self.func_name, self.check_params)
|
||||
|
||||
elif self.check_items == CheckParams.collection_property_check:
|
||||
result = self.req_collection_property_check(self.response, self.func_name, self.params)
|
||||
elif self.check_task == CheckTasks.check_collection_property:
|
||||
result = self.check_collection_property(self.response, self.func_name, self.kwargs_dict)
|
||||
|
||||
elif self.check_items == CheckParams.partition_property_check:
|
||||
result = self.partition_property_check(self.response, self.func_name, self.params)
|
||||
elif self.check_task == CheckTasks.check_partition_property:
|
||||
result = self.check_partition_property(self.response, self.func_name, self.kwargs_dict)
|
||||
|
||||
# Add check_items here if something new need verify
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def assert_expectation(expect, actual):
|
||||
assert actual == expect
|
||||
def assert_succ(actual, expect):
|
||||
assert actual is expect
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def assert_exception(res, actual=True, error_dict=None):
|
||||
assert actual is False
|
||||
assert len(error_dict) > 0
|
||||
if isinstance(res, Error):
|
||||
assert res.code == error_dict["err_code"] \
|
||||
or error_dict["err_msg"] in res.message
|
||||
else:
|
||||
log.error("[CheckFunc] Response of API is not an error: %s" % str(res))
|
||||
assert False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
|
@ -63,11 +75,7 @@ class ResponseChecker:
|
|||
return True
|
||||
|
||||
@staticmethod
|
||||
def req_collection_property_check(collection, func_name, params):
|
||||
'''
|
||||
:param collection
|
||||
:return:
|
||||
'''
|
||||
def check_collection_property(collection, func_name, params):
|
||||
exp_func_name = "collection_init"
|
||||
if func_name != exp_func_name:
|
||||
log.warning("The function name is {} rather than {}".format(func_name, exp_func_name))
|
||||
|
@ -79,15 +87,21 @@ class ResponseChecker:
|
|||
return True
|
||||
|
||||
@staticmethod
|
||||
def partition_property_check(partition, func_name, params):
|
||||
exp_func_name = "partition_init"
|
||||
def check_partition_property(partition, func_name, params):
|
||||
exp_func_name = "_init_partition"
|
||||
if func_name != exp_func_name:
|
||||
log.warning("The function name is {} rather than {}".format(func_name, exp_func_name))
|
||||
if not isinstance(partition, Partition):
|
||||
raise Exception("The result to check isn't collection type object")
|
||||
assert partition.name == params["name"]
|
||||
assert partition.description == params["description"]
|
||||
assert partition.is_empty == params["is_empty"]
|
||||
assert partition.num_entities == params["num_entities"]
|
||||
raise Exception("The result to check isn't partition type object")
|
||||
if len(params) == 0:
|
||||
raise Exception("No expect values found in the check task")
|
||||
if params["name"]:
|
||||
assert partition.name == params["name"]
|
||||
if params["description"]:
|
||||
assert partition.description == params["description"]
|
||||
if params["is_empty"]:
|
||||
assert partition.is_empty == params["is_empty"]
|
||||
if params["num_entities"]:
|
||||
assert partition.num_entities == params["num_entities"]
|
||||
return True
|
||||
|
||||
|
|
|
@ -71,15 +71,13 @@ binary_metrics = ["JACCARD", "HAMMING", "TANIMOTO", "SUBSTRUCTURE", "SUPERSTRUCT
|
|||
structure_metrics = ["SUBSTRUCTURE", "SUPERSTRUCTURE"]
|
||||
|
||||
|
||||
class CheckParams:
|
||||
class CheckTasks:
|
||||
""" The name of the method used to check the result """
|
||||
false = False
|
||||
err_res = "error_response"
|
||||
cname_param_check = "collection_name_param_check"
|
||||
pname_param_check = "partition_name_param_check"
|
||||
list_count = "check_list_count"
|
||||
collection_property_check = "collection_property_check"
|
||||
partition_property_check = "partition_property_check"
|
||||
check_list_count = "check_list_count"
|
||||
check_collection_property = "check_collection_property"
|
||||
check_partition_property = "check_partition_property"
|
||||
|
||||
|
||||
class CaseLabel:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[pytest]
|
||||
|
||||
addopts = --host 192.168.1.239 --html=/Users/wt/Desktop/report.html
|
||||
addopts = --host 192.168.1.239 --html=/Users/yanliang/Docuement/report.html
|
||||
-;addopts = --host 172.28.255.155 --html=/tmp/report.html
|
||||
# python3 -W ignore -m pytest
|
|
@ -7,7 +7,7 @@ from base.client_base import TestcaseBase
|
|||
from utils.util_log import test_log as log
|
||||
from common import common_func as cf
|
||||
from common import common_type as ct
|
||||
from common.common_type import CaseLabel, CheckParams
|
||||
from common.common_type import CaseLabel, CheckTasks
|
||||
|
||||
|
||||
prefix = "collection"
|
||||
|
@ -88,7 +88,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
self._connect()
|
||||
c_name = ""
|
||||
ex, check = self.collection_wrap.collection_init(c_name, schema=default_schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "value is illegal" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -101,7 +101,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
self._connect()
|
||||
c_name = get_invalid_string
|
||||
ex, check = self.collection_wrap.collection_init(c_name, schema=default_schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
|
||||
assert "invalid" or "illegal" in str(ex)
|
||||
|
||||
|
@ -153,7 +153,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
fields = [cf.gen_int64_field()]
|
||||
schema = cf.gen_collection_schema(fields=fields)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The collection already exist, but the schema isnot the same as the passed in" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -170,7 +170,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
assert_default_collection(collection)
|
||||
schema = cf.gen_default_collection_schema(primary_field=ct.default_int64_field_name)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The collection already exist, but the schema isnot the same as the passed in" in str(ex)
|
||||
assert collection.primary_field is None
|
||||
|
||||
|
@ -190,7 +190,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
new_fields = cf.gen_float_vec_field(dim=new_dim)
|
||||
schema.fields[-1] = new_fields
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The collection already exist, but the schema isnot the same as the passed in" in str(ex)
|
||||
assert collection.primary_field is None
|
||||
|
||||
|
@ -206,7 +206,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
c_name = collection.name
|
||||
assert_default_collection(collection)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=get_invalid_type_schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "schema type must be schema.CollectionSchema" in str(ex)
|
||||
assert_default_collection(collection, c_name)
|
||||
|
||||
|
@ -271,7 +271,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
self._connect()
|
||||
c_name = cf.gen_unique_str(prefix)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=None,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "Collection missing schema" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
@ -284,7 +284,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
self._connect()
|
||||
c_name = cf.gen_unique_str(prefix)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=get_invalid_type_schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "schema type must be schema.CollectionSchema" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -322,7 +322,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
field = FieldSchema(name=get_invalid_string, dtype=5)
|
||||
schema = cf.gen_collection_schema(fields=[field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
message_one = "but expected one of: bytes, unicode"
|
||||
message_two = "You should specify the name of field"
|
||||
message_three = "Invalid field name"
|
||||
|
@ -352,7 +352,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
vec_field = cf.gen_float_vec_field()
|
||||
schema = cf.gen_collection_schema(fields=[field, vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "Field type must be of DataType" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
@ -366,7 +366,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
c_name = cf.gen_unique_str(prefix)
|
||||
schema = cf.gen_collection_schema(fields=[])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The field of the schema cannot be empty" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -382,7 +382,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
field_two = cf.gen_int64_field()
|
||||
schema = cf.gen_collection_schema(fields=[field_one, field_two])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "duplicated field name" in str(ex)
|
||||
has, _ = self.utility_wrap.has_collection(c_name)
|
||||
assert not has
|
||||
|
@ -440,7 +440,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
c_name = cf.gen_unique_str(prefix)
|
||||
schema = cf.gen_collection_schema([cf.gen_int64_field()])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The schema must have vector column" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
@ -469,7 +469,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
vec_field = cf.gen_float_vec_field()
|
||||
schema = cf.gen_collection_schema(fields=[field, vec_field], primary_field=field.name)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "the data type of primary key should be int64" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -485,7 +485,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = cf.gen_float_vec_field(is_primary=True)
|
||||
schema = cf.gen_collection_schema(fields=[int_field, float_vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "there are more than one primary key" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -501,7 +501,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = cf.gen_float_vec_field(name="vec")
|
||||
schema = cf.gen_collection_schema(fields=[int_field, float_vec_field], primary_field="vec")
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "there are more than one primary key" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -533,7 +533,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = cf.gen_float_vec_field()
|
||||
schema = cf.gen_collection_schema(fields=[int_field, float_vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
log.info(str(ex))
|
||||
cf.gen_unique_str(prefix)
|
||||
with pytest.raises(Exception, match="Param is_primary must be bool type"):
|
||||
|
@ -552,7 +552,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = FieldSchema(name="vec", dtype=dtype)
|
||||
schema = cf.gen_collection_schema(fields=[float_vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "dimension is not defined in field type params" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -567,7 +567,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = cf.gen_float_vec_field(dim=get_invalid_dim)
|
||||
schema = cf.gen_collection_schema(fields=[float_vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "dim must be of int" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -583,7 +583,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
float_vec_field = cf.gen_float_vec_field(dim=dim)
|
||||
schema = cf.gen_collection_schema(fields=[float_vec_field])
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "invalid dimension: {}. should be in range 1 ~ 32768".format(dim) in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -705,7 +705,7 @@ class TestCollectionParams(TestcaseBase):
|
|||
data = cf.gen_default_binary_list_data(nb)
|
||||
ex, _ = self.collection_wrap.collection_init(c_name, schema=default_binary_schema,
|
||||
data=data,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
log.debug(str(ex))
|
||||
|
||||
|
||||
|
@ -746,7 +746,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
res_list = self.connection_wrap.list_connections()
|
||||
assert ct.default_alias not in res_list
|
||||
ex, check = self.collection_wrap.collection_init(c_name, schema=default_schema,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "There is no connection with alias '{}'".format(ct.default_alias) in str(ex)
|
||||
assert self.collection_wrap.collection is None
|
||||
|
||||
|
@ -780,7 +780,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
dup_collection, _ = self.collection_wrap.collection_init(collection.name)
|
||||
assert_default_collection(dup_collection, collection.name)
|
||||
dup_collection.drop()
|
||||
has, _ = self.utility_wrap.has_collection(collection.name, check_res=CheckParams.err_res)
|
||||
has, _ = self.utility_wrap.has_collection(collection.name, check_res=CheckTasks.err_res)
|
||||
assert not has
|
||||
with pytest.raises(Exception, match="can't find collection"):
|
||||
collection.num_entities
|
||||
|
@ -811,9 +811,9 @@ class TestCollectionOperation(TestcaseBase):
|
|||
self._connect()
|
||||
c_name = cf.gen_unique_str(prefix)
|
||||
data = pd.DataFrame()
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None,
|
||||
ex, _ = self.collection_wrap.init_collection(name=c_name, schema=None,
|
||||
data=data,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The field of the schema cannot be empty" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -827,7 +827,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
c_name = cf.gen_unique_str(prefix)
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None,
|
||||
data=get_invalid_df,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
message_one = "Cannot infer schema from empty dataframe"
|
||||
message_two = "Field name should not be empty"
|
||||
message_three = "Invalid field name"
|
||||
|
@ -847,7 +847,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
df = pd.DataFrame(data=mix_data, columns=list("ABC"))
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None,
|
||||
data=df,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "The data in the same column must be of the same type" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
@ -861,7 +861,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
c_name = cf.gen_unique_str(prefix)
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None,
|
||||
data=get_non_df,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "Data of not pandas.DataFrame type should bepassed into the schema" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
@ -876,7 +876,7 @@ class TestCollectionOperation(TestcaseBase):
|
|||
data = cf.gen_default_list_data(nb=100)
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None,
|
||||
data=data,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "Data of not pandas.DataFrame type should bepassed into the schema" in str(ex)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -922,5 +922,5 @@ class TestCollectionOperation(TestcaseBase):
|
|||
c_name = cf.gen_unique_str(prefix)
|
||||
data = cf.gen_default_binary_list_data(nb=100)
|
||||
ex, _ = self.collection_wrap.collection_init(name=c_name, schema=None, data=data,
|
||||
check_res=CheckParams.err_res)
|
||||
check_task=CheckTasks.err_res)
|
||||
assert "Data of not pandas.DataFrame type should bepassed into the schema" in str(ex)
|
||||
|
|
|
@ -250,7 +250,7 @@ class TestConnectionOperation(TestcaseBase):
|
|||
method: create connection with not exist link
|
||||
expected: assert res is wrong
|
||||
"""
|
||||
self.connection_wrap.get_connection(alias='default', check_res=CheckParams.false)
|
||||
self.connection_wrap.get_connection(alias='default', check_res=CheckTasks.false)
|
||||
res = self.connection_wrap.connect(alias="default", host='host', port=port, check_res='')
|
||||
assert res[0].args[0] == "Fail connecting to server on host:19530. Timeout"
|
||||
|
||||
|
@ -265,7 +265,7 @@ class TestConnectionOperation(TestcaseBase):
|
|||
self.connection_wrap.connect(alias=alias_name, host=host, port=port)
|
||||
self.connection_wrap.get_connection(alias=alias_name)
|
||||
self.connection_wrap.remove_connection(alias=alias_name)
|
||||
self.connection_wrap.get_connection(alias=alias_name, check_res=CheckParams.false)
|
||||
self.connection_wrap.get_connection(alias=alias_name, check_res=CheckTasks.false)
|
||||
self.connection_wrap.connect(alias=alias_name, host=host, port=port)
|
||||
self.connection_wrap.get_connection(alias=alias_name)
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
import threading
|
||||
import pytest
|
||||
|
||||
from pymilvus_orm import Partition
|
||||
from base.partition_wrapper import ApiPartitionWrapper
|
||||
from base.client_base import TestcaseBase
|
||||
from utils.util_log import test_log as log
|
||||
from common import common_func as cf
|
||||
from common import common_type as ct
|
||||
from common.common_type import CaseLabel, CheckParams
|
||||
from common.common_type import CaseLabel, CheckTasks
|
||||
|
||||
prefix = "partition_"
|
||||
|
||||
|
@ -15,23 +14,24 @@ class TestPartitionParams(TestcaseBase):
|
|||
""" Test case of partition interface in parameters"""
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
@pytest.mark.parametrize("partition_name, descriptions", [(cf.gen_unique_str(prefix), cf.gen_unique_str("desc_"))])
|
||||
def test_partition_default(self, partition_name, descriptions):
|
||||
@pytest.mark.parametrize("partition_name, description",
|
||||
[(cf.gen_unique_str(prefix), cf.gen_unique_str("desc_"))])
|
||||
def test_partition_default(self, partition_name, description):
|
||||
"""
|
||||
target: verify create a partition
|
||||
method: 1. create a partition
|
||||
expected: 1. create successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name, description=descriptions,
|
||||
check_res=CheckParams.partition_property_check)
|
||||
# create partition
|
||||
self.init_partition_wrap(collection_w, partition_name,
|
||||
description=description,
|
||||
check_task=CheckTasks.check_partition_property)
|
||||
|
||||
# check that the partition has been created
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", [""])
|
||||
|
@ -41,81 +41,78 @@ class TestPartitionParams(TestcaseBase):
|
|||
method: 1. create a partition empty none name
|
||||
expected: 1. raise exception
|
||||
"""
|
||||
self.collection_wrap.collection_init()
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
# create a collection
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
res, cr = self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name, check_res=CheckParams.err_res)
|
||||
# waiting to be extracted as a public method
|
||||
assert res.code == 1
|
||||
assert "Partition tag should not be empty" in res.message
|
||||
# create partition
|
||||
self.partition_wrap.init_partition(collection_w.collection, partition_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
err_code=1, err_msg="Partition tag should not be empty")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name, descriptions", [(cf.gen_unique_str(prefix), "")])
|
||||
def test_partition_empty_description(self, partition_name, descriptions):
|
||||
@pytest.mark.parametrize("partition_name, description", [(cf.gen_unique_str(prefix), "")])
|
||||
def test_partition_empty_description(self, partition_name, description):
|
||||
"""
|
||||
target: verify create a partition with empty description
|
||||
method: 1. create a partition with empty description
|
||||
expected: 1. create successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name, description=descriptions,
|
||||
check_res=CheckParams.partition_property_check)
|
||||
self.init_partition_wrap(collection_w, partition_name,
|
||||
description=description,
|
||||
check_task=CheckTasks.check_partition_property)
|
||||
|
||||
# check that the partition has been created
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("collection_name, partition_name, descriptions",
|
||||
@pytest.mark.parametrize("collection_name, partition_name, description",
|
||||
[(cf.gen_unique_str(), cf.gen_unique_str(prefix), cf.gen_unique_str())])
|
||||
def test_partition_dup_name(self, collection_name, partition_name, descriptions):
|
||||
def test_partition_dup_name(self, collection_name, partition_name, description):
|
||||
"""
|
||||
target: verify create partitions with duplicate name
|
||||
method: 1. create partitions with duplicate name
|
||||
expected: 1. create successfully
|
||||
2. the same partition returned with diff object id
|
||||
"""
|
||||
# create a collection
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# create collection
|
||||
self._collection(name=collection_name)
|
||||
|
||||
# init two objects of partition
|
||||
self._partition_object_multiple(mul_number=2)
|
||||
self.partition_mul[0].partition_init(self.collection_wrap.collection, partition_name, descriptions)
|
||||
self.partition_mul[1].partition_init(self.collection_wrap.collection, partition_name, descriptions)
|
||||
# create two partitions
|
||||
partition_w1 = self.init_partition_wrap(collection_w, partition_name, description)
|
||||
partition_w2 = self.init_partition_wrap(collection_w, partition_name, description)
|
||||
|
||||
# public check func to be extracted
|
||||
assert (id(self.partition_mul[0]) != id(self.partition_mul[1]))
|
||||
assert self.partition_mul[0].name == self.partition_mul[1].name
|
||||
assert self.partition_mul[0].description == self.partition_mul[1].description
|
||||
assert id(partition_w1.partition) != id(partition_w2.partition)
|
||||
assert partition_w1.name == partition_w2.name
|
||||
assert partition_w1.description == partition_w2.description
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("descriptions", ct.get_invalid_strs)
|
||||
@pytest.mark.parametrize("description", ct.get_invalid_strs)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
def test_partition_special_chars_description(self, partition_name, descriptions):
|
||||
def test_partition_special_chars_description(self, partition_name, description):
|
||||
"""
|
||||
target: verify create a partition with special characters in description
|
||||
method: 1. create a partition with special characters in description
|
||||
expected: 1. create successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name, description=descriptions,
|
||||
check_res=CheckParams.partition_property_check)
|
||||
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
assert self.partition_wrap.description == descriptions
|
||||
# create partition
|
||||
self.init_partition_wrap(collection_w, partition_name,
|
||||
description=description,
|
||||
check_task=CheckTasks.check_partition_property)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
assert collection_w.description == description
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5373")
|
||||
# @pytest.mark.xfail(reason="issue #5373")
|
||||
def test_partition_default_name(self):
|
||||
"""
|
||||
target: verify create a partition with default name
|
||||
|
@ -123,23 +120,18 @@ class TestPartitionParams(TestcaseBase):
|
|||
2. create a partition with _default name
|
||||
expected: 1. the same partition returned
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# check that the default partition exists
|
||||
self.collection_wrap.has_partition(ct.default_partition_name)
|
||||
assert collection_w.has_partition(ct.default_partition_name)[0]
|
||||
|
||||
res_mp, cr = self.collection_wrap.partition(ct.default_partition_name)
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, ct.default_partition_name)
|
||||
# check that can get the _default partition
|
||||
collection, _ = collection_w.partition(ct.default_partition_name)
|
||||
|
||||
assert id(self.partition_wrap.partition) == id(res_mp)
|
||||
|
||||
# m_collection = self._collection()
|
||||
# assert m_collection.has_partition(ct.default_partition_name)
|
||||
# m_partition = m_collection.partition(ct.default_partition_name)
|
||||
# m_partition2, _ = self.partition_wrap.partition_init(m_collection, ct.default_partition_name)
|
||||
# assert (id(m_partition2) == id(m_partition))
|
||||
# check that init the _default partition object
|
||||
partition_w = self.init_partition_wrap(collection_w, ct.default_partition_name)
|
||||
assert collection.name == partition_w.name
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", ct.get_invalid_strs)
|
||||
|
@ -149,16 +141,15 @@ class TestPartitionParams(TestcaseBase):
|
|||
method: 1. create a partition with invalid names
|
||||
expected: 1. raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
res, cr = self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name,
|
||||
check_res=CheckParams.err_res)
|
||||
self.init_collection_wrap()
|
||||
|
||||
# create partition
|
||||
self.partition_wrap.init_partition(self.collection_wrap.collection, partition_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_params={'err_code':1, 'err_msg':"is illegal"}
|
||||
)
|
||||
# TODO: need an error code issue #5144 and assert independently
|
||||
assert "is illegal" in res.message or res.code == 1
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -168,10 +159,10 @@ class TestPartitionParams(TestcaseBase):
|
|||
method: 1. create a partition with none collection
|
||||
expected: 1. raise exception
|
||||
"""
|
||||
|
||||
# init partition with collection is None
|
||||
res, cr = self.partition_wrap.partition_init(collection=None, name=partition_name, check_res=CheckParams.err_res)
|
||||
assert "'NoneType' object has no attribute" in res.message
|
||||
# create partition with collection is None
|
||||
self.partition_wrap.init_partition(collection=None, name=partition_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
err_code=1, err_msg="'NoneType' object has no attribute")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -182,22 +173,20 @@ class TestPartitionParams(TestcaseBase):
|
|||
2. drop the partition
|
||||
expected: 1. drop successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
|
||||
# check that the partition exists
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
partition_w.drop()
|
||||
|
||||
# check that the partition not exists
|
||||
res, cr = self.collection_wrap.has_partition(partition_name)
|
||||
assert res is False
|
||||
assert not collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5384")
|
||||
|
@ -213,49 +202,49 @@ class TestPartitionParams(TestcaseBase):
|
|||
expected: 1. the released partition is released
|
||||
2. the other partition is not released
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init two objects of partition
|
||||
self._partition_object_multiple(mul_number=2)
|
||||
|
||||
# init two partitions
|
||||
self._partition(p_object=self.partition_mul[0])
|
||||
self._partition(p_object=self.partition_mul[1])
|
||||
# create two partitions
|
||||
partition_w1 = self.init_partition_wrap(collection_w)
|
||||
partition_w2 = self.init_partition_wrap(collection_w)
|
||||
|
||||
# insert data to two partition
|
||||
self.partition_mul[0].insert(cf.gen_default_list_data())
|
||||
self.partition_mul[1].insert(cf.gen_default_list_data())
|
||||
partition_w1.insert(cf.gen_default_list_data())
|
||||
partition_w2.insert(cf.gen_default_list_data())
|
||||
|
||||
# load two partitions
|
||||
self.partition_mul[0].load()
|
||||
self.partition_mul[1].load()
|
||||
partition_w1.load()
|
||||
partition_w2.load()
|
||||
|
||||
# search two partitions
|
||||
res0, cr0 = self.partition_mul[0].search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res1, cr1 = self.partition_mul[1].search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res0) == 1 and len(res1) == 1
|
||||
res1, _ = partition_w1.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res2, _ = partition_w2.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res1) == 1 and len(res2) == 1
|
||||
|
||||
# release the first one of partition
|
||||
for _ in range(2):
|
||||
self.partition_mul[0].release()
|
||||
# release the first partition
|
||||
partition_w1.release()
|
||||
|
||||
# check result
|
||||
res0, cr0 = self.partition_mul[0].search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res1, cr1 = self.partition_mul[1].search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res0) == 0 and len(res1) == 1
|
||||
# check result
|
||||
res1, _ = partition_w1.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res2, _ = partition_w2.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res1) == 0 and len(res2) == 1
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5302")
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
@pytest.mark.parametrize("data, nums", [(cf.gen_default_dataframe_data(10), 10),
|
||||
(cf.gen_default_list_data(1), 1),
|
||||
(cf.gen_default_tuple_data(10), 10)])
|
||||
def test_partition_insert(self, data, nums):
|
||||
def test_partition_insert(self, partition_name, data, nums):
|
||||
"""
|
||||
target: verify insert multi entities by dataFrame
|
||||
method: 1. create a collection and a partition
|
||||
|
@ -263,24 +252,25 @@ class TestPartitionParams(TestcaseBase):
|
|||
3. insert data again
|
||||
expected: 1. insert data successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self._partition()
|
||||
assert self.partition_wrap.is_empty
|
||||
assert self.partition_wrap.num_entities == 0
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name,
|
||||
check_task=CheckTasks.check_partition_property,
|
||||
is_empty=True, num_entities=0)
|
||||
|
||||
# insert data
|
||||
self.partition_wrap.insert(data) # TODO: add ndarray type data
|
||||
assert self.partition_wrap.is_empty is False
|
||||
assert self.partition_wrap.num_entities == nums
|
||||
partition_w.insert(data)
|
||||
# TODO need a flush before assert
|
||||
assert not partition_w.is_empty
|
||||
assert partition_w.num_entities == nums
|
||||
|
||||
# insert data
|
||||
self.partition_wrap.insert(data)
|
||||
assert self.partition_wrap.is_empty is False
|
||||
assert self.partition_wrap.num_entities == (nums + nums)
|
||||
partition_w.insert(data)
|
||||
# TODO need a flush before assert
|
||||
assert not partition_w.is_empty
|
||||
assert partition_w.num_entities == (nums + nums)
|
||||
|
||||
|
||||
class TestPartitionOperations(TestcaseBase):
|
||||
|
@ -296,43 +286,37 @@ class TestPartitionOperations(TestcaseBase):
|
|||
3. create partition in collection1
|
||||
expected: 1. raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# drop collection
|
||||
self.collection_wrap.drop()
|
||||
collection_w.drop()
|
||||
|
||||
# init partition failed
|
||||
res, cr = self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name,
|
||||
check_res=CheckParams.err_res)
|
||||
|
||||
assert res.code == 1 and "can't find collection" in res.message
|
||||
# create partition failed
|
||||
self.partition_wrap.init_partition(collection_w.collection, partition_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
err_code=1, err_msg="can't find collection")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
def test_partition_same_name_in_diff_collections(self, partition_name):
|
||||
"""
|
||||
target: verify create partitions with sanme name in diff collections
|
||||
target: verify create partitions with same name in diff collections
|
||||
method: 1. create a partition in collection1
|
||||
2. create a partition in collection2
|
||||
expected: 1. create successfully
|
||||
"""
|
||||
|
||||
# init two objects of collection
|
||||
self._collection_object_multiple(mul_number=2)
|
||||
|
||||
# create two collections
|
||||
for c in self.collection_mul:
|
||||
self._collection(c_object=c)
|
||||
collection_w1 = self.init_collection_wrap()
|
||||
collection_w2 = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
for c in self.collection_mul:
|
||||
self.partition_wrap.partition_init(c.collection, partition_name)
|
||||
# create 2 partitions in 2 diff collections
|
||||
self.init_partition_wrap(collection_wrap=collection_w1, name=partition_name)
|
||||
self.init_partition_wrap(collection_wrap=collection_w2, name=partition_name)
|
||||
|
||||
# check result
|
||||
for c in self.collection_mul:
|
||||
c.has_partition(partition_name)
|
||||
assert collection_w1.has_partition(partition_name)[0]
|
||||
assert collection_w2.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_partition_multi_partitions_in_collection(self):
|
||||
|
@ -342,14 +326,13 @@ class TestPartitionOperations(TestcaseBase):
|
|||
expected: 1. create successfully
|
||||
"""
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
for _ in range(10):
|
||||
partition_name = cf.gen_unique_str(prefix)
|
||||
|
||||
# init partition with different name and check partition is exists
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
# create partition with different names and check the partition exists
|
||||
self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_partition_maximum_partitions(self):
|
||||
|
@ -366,9 +349,10 @@ class TestPartitionOperations(TestcaseBase):
|
|||
def create_partition(collection, threads_n):
|
||||
for _ in range(ct.max_partition_num // threads_n):
|
||||
name = cf.gen_unique_str(prefix)
|
||||
Partition(collection, name)
|
||||
par_wrap = ApiPartitionWrapper()
|
||||
par_wrap.init_partition(collection, name)
|
||||
|
||||
m_collection = self._collection()
|
||||
m_collection = self.init_collection_wrap()
|
||||
for _ in range(threads_num):
|
||||
t = threading.Thread(target=create_partition, args=(m_collection, threads_num))
|
||||
threads.append(t)
|
||||
|
@ -376,10 +360,10 @@ class TestPartitionOperations(TestcaseBase):
|
|||
for t in threads:
|
||||
t.join()
|
||||
p_name = cf.gen_unique_str()
|
||||
ex, _ = self.partition_wrap.partition_init(m_collection, p_name,
|
||||
check_res=CheckParams.err_res)
|
||||
assert ex.code == 1
|
||||
assert "maximum partition's number should be limit to 4096" in ex.message
|
||||
self.partition_wrap.init_partition(m_collection, p_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
err_code=1,
|
||||
err_msg="maximum partition's number should be limit to 4096")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5302")
|
||||
|
@ -390,23 +374,14 @@ class TestPartitionOperations(TestcaseBase):
|
|||
method: 1. drop the _default partition
|
||||
expected: 1. raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
res_mp, cr = self.collection_wrap.partition(ct.default_partition_name)
|
||||
partition_w = collection_w.partition(ct.default_partition_name)
|
||||
|
||||
# insert data
|
||||
res_mp.insert(cf.gen_default_list_data())
|
||||
|
||||
# TODO need a flush?
|
||||
assert res_mp.is_empty is False
|
||||
|
||||
# drop partition
|
||||
with pytest.raises(Exception) as e:
|
||||
res_mp.drop()
|
||||
log.error(e)
|
||||
# verify that drop partition with error
|
||||
partition_w.drop(check_task=CheckTasks.err_res, err_code=1, err_msg="not")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -418,20 +393,19 @@ class TestPartitionOperations(TestcaseBase):
|
|||
3. drop the same partition again
|
||||
expected: raise exception when 2nd time
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
self.collection_wrap.has_partition(partition_name)
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
collection_w.has_partition(partition_name)
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
assert not self.collection_wrap.has_partition(partition_name)[0]
|
||||
partition_w.drop()
|
||||
assert not collection_w.has_partition(partition_name)
|
||||
|
||||
# drop partition again
|
||||
self.partition_wrap.drop(check_res=CheckParams.err_res)
|
||||
# verify that drop the partition again with exception
|
||||
partition_w.drop(check_task=CheckTasks.err_res, err_code=1, err_msg="None Type")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -443,19 +417,18 @@ class TestPartitionOperations(TestcaseBase):
|
|||
3. loop #1 and #2 for times
|
||||
expected: create and drop successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# range for 5 times
|
||||
for i in range(5):
|
||||
# init partition and check that the partition exists
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition and check that the partition exists
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# drop partition and check that the partition not exists
|
||||
self.partition_wrap.drop()
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is False
|
||||
partition_w.drop()
|
||||
assert not collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("flush", [True, False])
|
||||
|
@ -469,16 +442,15 @@ class TestPartitionOperations(TestcaseBase):
|
|||
3. drop the partition
|
||||
expected: drop successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# insert data to partition
|
||||
self.partition_wrap.insert(cf.gen_default_dataframe_data())
|
||||
partition_w.insert(cf.gen_default_dataframe_data())
|
||||
|
||||
# flush
|
||||
if flush:
|
||||
|
@ -486,8 +458,8 @@ class TestPartitionOperations(TestcaseBase):
|
|||
pass
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is False
|
||||
partition_w.drop()
|
||||
assert not collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("flush", [True, False])
|
||||
|
@ -503,19 +475,18 @@ class TestPartitionOperations(TestcaseBase):
|
|||
5. drop the partition
|
||||
expected: drop successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self._collection()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)
|
||||
|
||||
# insert data to partition
|
||||
self.partition_wrap.insert(data)
|
||||
|
||||
# create index of collection
|
||||
self.collection_wrap.create_index(ct.default_float_vec_field_name, index_param)
|
||||
collection_w.create_index(ct.default_float_vec_field_name, index_param)
|
||||
|
||||
# flush
|
||||
if flush:
|
||||
|
@ -523,8 +494,8 @@ class TestPartitionOperations(TestcaseBase):
|
|||
pass
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is False
|
||||
partition_w.drop()
|
||||
assert not collection_w.has_partition(partition_name)[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_partition_release_empty_partition(self):
|
||||
|
@ -534,16 +505,12 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. release the partition
|
||||
expected: release successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
self._partition()
|
||||
assert self.partition_wrap.is_empty
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap()
|
||||
assert partition_w.is_empty
|
||||
|
||||
# release partition
|
||||
self.partition_wrap.release()
|
||||
partition_w.release()
|
||||
# TODO: assert no more memory consumed
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
|
@ -555,20 +522,14 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. release the partition
|
||||
expected: raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
self._partition()
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap()
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
partition_w.drop()
|
||||
|
||||
# release partition and check err res
|
||||
res, cr = self.partition_wrap.release(check_res=CheckParams.err_res)
|
||||
# TODO assert the error code
|
||||
log.error(res)
|
||||
# release the dropped partition and check err response
|
||||
partition_w.release(check_task=CheckTasks.err_res, err_code=1, err_msg="None Type")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -580,21 +541,18 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. release the partition
|
||||
expected: raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# drop collection
|
||||
self.collection_wrap.drop()
|
||||
collection_w.drop()
|
||||
|
||||
# release partition and check err res
|
||||
res, cr = self.partition_wrap.release(check_res=CheckParams.err_res)
|
||||
# TODO assert the error code
|
||||
log.error(res)
|
||||
# release the partition and check err response
|
||||
partition_w.release(check_task=CheckTasks.err_res, err_code=1, err_msg="None Type")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5384")
|
||||
|
@ -609,36 +567,36 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. release the partition
|
||||
expected: partition released successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# insert data to partition
|
||||
self.partition_wrap.insert(cf.gen_default_list_data())
|
||||
partition_w.insert(cf.gen_default_list_data())
|
||||
|
||||
# load partition
|
||||
self.partition_wrap.load()
|
||||
partition_w.load()
|
||||
|
||||
# search of partition
|
||||
res_1, cr = self.partition_wrap.search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res_1, _ = partition_w.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res_1) == 1
|
||||
|
||||
# release collection
|
||||
self.collection_wrap.release()
|
||||
collection_w.release()
|
||||
|
||||
# search of partition
|
||||
res_2, cr = self.partition_wrap.search(data=search_vectors, anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
res_2, _ = partition_w.search(data=search_vectors,
|
||||
anns_field=ct.default_float_vec_field_name,
|
||||
params={"nprobe": 32}, limit=1)
|
||||
assert len(res_2) == 0
|
||||
|
||||
# release partition
|
||||
self.partition_wrap.release()
|
||||
# TODO assert release successfully
|
||||
partition_w.release()
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5302")
|
||||
|
@ -650,16 +608,16 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. insert some data into _default partition
|
||||
expected: insert successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
res_mp, cr = self.collection_wrap.partition(partition_name)
|
||||
# get the default partition
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
|
||||
# insert data to partition
|
||||
res_mp.insert(data)
|
||||
assert res_mp.num_entities == len(data)
|
||||
partition_w.insert(data)
|
||||
assert partition_w.num_entities == len(data)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_partition_insert_dropped_partition(self):
|
||||
|
@ -669,20 +627,16 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. insert some data into dropped partition
|
||||
expected: raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
self._partition()
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap()
|
||||
|
||||
# drop partition
|
||||
self.partition_wrap.drop()
|
||||
partition_w.drop()
|
||||
|
||||
# insert data to partition
|
||||
res, cr = self.partition_wrap.insert(cf.gen_default_dataframe_data(), check_res=CheckParams.err_res)
|
||||
# TODO: assert the error code
|
||||
log.error(res)
|
||||
partition_w.insert(cf.gen_default_dataframe_data(),
|
||||
check_task=CheckTasks.err_res, err_code=1, err_msg="not")
|
||||
# TODO: update the assert error
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", [cf.gen_unique_str(prefix)])
|
||||
|
@ -693,21 +647,19 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. insert some data into dropped collection
|
||||
expected: raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
collection_w = self.init_collection_wrap()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
assert self.collection_wrap.has_partition(partition_name)[0] is True
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(collection_w, partition_name)
|
||||
assert collection_w.has_partition(partition_name)[0]
|
||||
|
||||
# drop collection
|
||||
self.collection_wrap.drop()
|
||||
collection_w.drop()
|
||||
|
||||
# insert data to partition
|
||||
res, cr = self.partition_wrap.insert(cf.gen_default_dataframe_data(), check_res=CheckParams.err_res)
|
||||
# TODO: assert the error code
|
||||
log.error(res)
|
||||
partition_w.insert(cf.gen_default_dataframe_data(), check_task=CheckTasks.err_res,
|
||||
err_code=1, err_msg="None Type")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue #5302")
|
||||
|
@ -718,18 +670,14 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. insert maximum size data
|
||||
expected: insert successfully
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
self._partition()
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap()
|
||||
|
||||
# insert data to partition
|
||||
max_size = 100000 # TODO: clarify the max size of data
|
||||
self.partition_wrap.insert(cf.gen_default_dataframe_data(max_size))
|
||||
partition_w.insert(cf.gen_default_dataframe_data(max_size))
|
||||
# TODO: need a flush for #5302
|
||||
assert self.partition_wrap.num_entities == max_size
|
||||
assert partition_w.num_entities == max_size
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("dim, expected_err",
|
||||
|
@ -742,18 +690,12 @@ class TestPartitionOperations(TestcaseBase):
|
|||
2. insert dismatch dim data
|
||||
expected: raise exception
|
||||
"""
|
||||
|
||||
# create collection
|
||||
self._collection()
|
||||
|
||||
# init partition
|
||||
self.partition_wrap.partition_init(self.collection_wrap.collection, partition_name)
|
||||
# create partition
|
||||
partition_w = self.init_partition_wrap(partition_name)
|
||||
|
||||
data = cf.gen_default_list_data(nb=10, dim=dim)
|
||||
# insert data to partition
|
||||
res, cr = self.partition_wrap.insert(data, check_res=CheckParams.err_res)
|
||||
# TODO: assert expected_err in error code
|
||||
log.error(res)
|
||||
partition_w.insert(data, check_task=CheckTasks.err_res, err_code=1, err_msg="blabla")
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("sync", [True, False])
|
||||
|
|
|
@ -213,7 +213,7 @@ class TestUtilityBase(TestcaseBase):
|
|||
p_name = cf.gen_unique_str()
|
||||
collection = self._collection(c_name)
|
||||
api_p = ApiPartitionWrapper()
|
||||
api_p.partition_init(collection, p_name)
|
||||
api_p.init_partition(collection, p_name)
|
||||
res, _ = ut.has_partition(c_name, p_name)
|
||||
assert res is True
|
||||
|
||||
|
@ -245,7 +245,7 @@ class TestUtilityBase(TestcaseBase):
|
|||
p_name = cf.gen_unique_str()
|
||||
collection = self._collection(c_name)
|
||||
api_p = ApiPartitionWrapper()
|
||||
api_p.partition_init(collection, p_name)
|
||||
api_p.init_partition(collection, p_name)
|
||||
res, _ = ut.has_partition(c_name, p_name)
|
||||
assert res is True
|
||||
api_p.drop()
|
||||
|
|
|
@ -15,8 +15,7 @@ def api_request_catch():
|
|||
log.debug("(func_res) Response : %s " % str(res))
|
||||
return res, True
|
||||
except Exception as e:
|
||||
# log.info("exception: %s", e)
|
||||
log.error("[Partition API Exception]%s: %s" % (str(func), str(e)))
|
||||
log.error("[Milvus API Exception]%s: %s" % (str(func), str(e)))
|
||||
return Error(e), False
|
||||
return inner_wrapper
|
||||
return wrapper
|
Loading…
Reference in New Issue