2021-11-29 19:56:01 +08:00
|
|
|
from datetime import datetime
|
|
|
|
|
2021-08-20 11:00:56 +08:00
|
|
|
from pymilvus import utility
|
2021-05-11 17:59:29 +08:00
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append("..")
|
2021-09-30 19:52:16 +08:00
|
|
|
from check.func_check import ResponseChecker
|
2021-06-07 12:15:35 +08:00
|
|
|
from utils.api_request import api_request
|
2021-05-11 17:59:29 +08:00
|
|
|
|
|
|
|
|
2021-08-03 11:01:25 +08:00
|
|
|
TIMEOUT = 20
|
2021-07-26 15:51:20 +08:00
|
|
|
|
|
|
|
|
2021-06-04 09:35:34 +08:00
|
|
|
class ApiUtilityWrapper:
|
2021-05-11 17:59:29 +08:00
|
|
|
""" Method of encapsulating utility files """
|
|
|
|
|
|
|
|
ut = utility
|
|
|
|
|
2021-11-08 20:46:26 +08:00
|
|
|
def get_query_segment_info(self, collection_name, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.get_query_segment_info, collection_name, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
2021-12-23 14:23:30 +08:00
|
|
|
collection_name=collection_name, timeout=timeout, using=using).run()
|
2021-11-08 20:46:26 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-09-10 10:36:00 +08:00
|
|
|
def loading_progress(self, collection_name, partition_names=None,
|
2021-06-17 11:49:57 +08:00
|
|
|
using="default", check_task=None, check_items=None):
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-09 14:23:48 +08:00
|
|
|
res, is_succ = api_request([self.ut.loading_progress, collection_name, partition_names, using])
|
2021-06-17 11:49:57 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task,
|
|
|
|
check_items, is_succ, collection_name=collection_name,
|
2021-06-05 10:25:34 +08:00
|
|
|
partition_names=partition_names, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-09-10 10:36:00 +08:00
|
|
|
def wait_for_loading_complete(self, collection_name, partition_names=None, timeout=None, using="default",
|
2021-06-17 11:49:57 +08:00
|
|
|
check_task=None, check_items=None):
|
2021-07-26 15:51:20 +08:00
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-17 11:49:57 +08:00
|
|
|
res, is_succ = api_request([self.ut.wait_for_loading_complete, collection_name,
|
|
|
|
partition_names, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name, partition_names=partition_names,
|
|
|
|
timeout=timeout, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-06-17 11:49:57 +08:00
|
|
|
def index_building_progress(self, collection_name, index_name="", using="default",
|
|
|
|
check_task=None, check_items=None):
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-09 14:23:48 +08:00
|
|
|
res, is_succ = api_request([self.ut.index_building_progress, collection_name, index_name, using])
|
2021-06-17 11:49:57 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name, index_name=index_name,
|
2021-06-05 10:25:34 +08:00
|
|
|
using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-06-17 11:49:57 +08:00
|
|
|
def wait_for_index_building_complete(self, collection_name, index_name="", timeout=None, using="default",
|
|
|
|
check_task=None, check_items=None):
|
2021-07-26 15:51:20 +08:00
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-07-05 17:18:03 +08:00
|
|
|
res, is_succ = api_request([self.ut.wait_for_index_building_complete, collection_name,
|
2021-06-17 11:49:57 +08:00
|
|
|
index_name, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name, index_name=index_name,
|
2021-06-05 10:25:34 +08:00
|
|
|
timeout=timeout, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-06-09 14:23:48 +08:00
|
|
|
def has_collection(self, collection_name, using="default", check_task=None, check_items=None):
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-09 14:23:48 +08:00
|
|
|
res, is_succ = api_request([self.ut.has_collection, collection_name, using])
|
2021-06-17 11:49:57 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-06-17 11:49:57 +08:00
|
|
|
def has_partition(self, collection_name, partition_name, using="default",
|
|
|
|
check_task=None, check_items=None):
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-09 14:23:48 +08:00
|
|
|
res, is_succ = api_request([self.ut.has_partition, collection_name, partition_name, using])
|
2021-06-17 11:49:57 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name,
|
2021-06-05 10:25:34 +08:00
|
|
|
partition_name=partition_name, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
|
|
|
|
2021-09-10 10:36:00 +08:00
|
|
|
def drop_collection(self, collection_name, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-09-10 18:34:02 +08:00
|
|
|
res, is_succ = api_request([self.ut.drop_collection, collection_name, timeout, using])
|
2021-09-10 10:36:00 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
collection_name=collection_name,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
|
|
|
|
2021-06-09 14:23:48 +08:00
|
|
|
def list_collections(self, timeout=None, using="default", check_task=None, check_items=None):
|
2021-07-26 15:51:20 +08:00
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
|
2021-05-11 17:59:29 +08:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-09 14:23:48 +08:00
|
|
|
res, is_succ = api_request([self.ut.list_collections, timeout, using])
|
2021-06-17 11:49:57 +08:00
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
2021-05-11 17:59:29 +08:00
|
|
|
return res, check_result
|
2021-08-12 18:12:10 +08:00
|
|
|
|
|
|
|
def calc_distance(self, vectors_left, vectors_right, params=None, timeout=None,
|
|
|
|
using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.calc_distance, vectors_left, vectors_right,
|
|
|
|
params, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
2021-11-08 20:48:34 +08:00
|
|
|
|
|
|
|
def load_balance(self, src_node_id, dst_node_ids, sealed_segment_ids, timeout=None,
|
|
|
|
using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.load_balance, src_node_id, dst_node_ids,
|
|
|
|
sealed_segment_ids, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
2021-11-29 19:56:01 +08:00
|
|
|
|
2021-12-17 20:46:15 +08:00
|
|
|
def create_alias(self, collection_name, alias, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.create_alias, collection_name, alias, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
|
|
|
|
|
|
|
def drop_alias(self, alias, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.drop_alias, alias, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
|
|
|
|
|
|
|
def alter_alias(self, collection_name, alias, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.alter_alias, collection_name, alias, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
|
|
|
|
|
|
|
def list_aliases(self, collection_name, timeout=None, using="default", check_task=None, check_items=None):
|
|
|
|
timeout = TIMEOUT if timeout is None else timeout
|
|
|
|
func_name = sys._getframe().f_code.co_name
|
|
|
|
res, is_succ = api_request([self.ut.list_aliases, collection_name, timeout, using])
|
|
|
|
check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,
|
|
|
|
timeout=timeout, using=using).run()
|
|
|
|
return res, check_result
|
|
|
|
|
2021-11-29 19:56:01 +08:00
|
|
|
def mkts_from_datetime(self, d_time=None, milliseconds=0., delta=None):
|
|
|
|
d_time = datetime.now() if d_time is None else d_time
|
2021-11-30 20:11:44 +08:00
|
|
|
res, _ = api_request([self.ut.mkts_from_datetime, d_time, milliseconds, delta])
|
|
|
|
return res
|
|
|
|
|
|
|
|
def mkts_from_hybridts(self, hybridts, milliseconds=0., delta=None):
|
|
|
|
res, _ = api_request([self.ut.mkts_from_hybridts, hybridts, milliseconds, delta])
|
2021-11-29 19:56:01 +08:00
|
|
|
return res
|