2021-08-20 03:00:56 +00:00
|
|
|
from pymilvus import Connections
|
|
|
|
from pymilvus import DefaultConfig
|
2021-05-11 09:59:29 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append("..")
|
2021-10-02 08:53:56 +00:00
|
|
|
from check.func_check import ResponseChecker
|
2021-06-07 04:15:35 +00:00
|
|
|
from utils.api_request import api_request
|
2021-05-11 09:59:29 +00:00
|
|
|
|
|
|
|
|
2021-06-04 01:35:34 +00:00
|
|
|
class ApiConnectionsWrapper:
|
2021-05-11 09:59:29 +00:00
|
|
|
def __init__(self):
|
2021-06-02 11:21:33 +00:00
|
|
|
self.connection = Connections()
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def add_connection(self, check_task=None, check_items=None, **kwargs):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.add_connection], **kwargs)
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ, **kwargs).run()
|
|
|
|
return response, check_result
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def disconnect(self, alias, check_task=None, check_items=None):
|
2021-06-02 11:21:33 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.disconnect, alias])
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ, alias=alias).run()
|
|
|
|
return response, check_result
|
2021-06-02 11:21:33 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def remove_connection(self, alias, check_task=None, check_items=None):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.remove_connection, alias])
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ, alias=alias).run()
|
|
|
|
return response, check_result
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-08 02:35:35 +00:00
|
|
|
def connect(self, alias=DefaultConfig.DEFAULT_USING, check_task=None, check_items=None, **kwargs):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, succ = api_request([self.connection.connect, alias], **kwargs)
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, succ, alias=alias, **kwargs).run()
|
|
|
|
return response, check_result
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def get_connection(self, alias=DefaultConfig.DEFAULT_USING, check_task=None, check_items=None):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.get_connection, alias])
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ, alias=alias).run()
|
|
|
|
return response, check_result
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def list_connections(self, check_task=None, check_items=None):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.list_connections])
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ).run()
|
|
|
|
return response, check_result
|
2021-05-11 09:59:29 +00:00
|
|
|
|
2021-06-10 11:19:49 +00:00
|
|
|
def get_connection_addr(self, alias, check_task=None, check_items=None):
|
2021-05-11 09:59:29 +00:00
|
|
|
func_name = sys._getframe().f_code.co_name
|
2021-06-10 11:19:49 +00:00
|
|
|
response, is_succ = api_request([self.connection.get_connection_addr, alias])
|
|
|
|
check_result = ResponseChecker(response, func_name, check_task, check_items, is_succ, alias=alias).run()
|
|
|
|
return response, check_result
|