From e052b8c20e1db63f71a95ea3575b31254baaf955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=B4=AB=E6=99=B4?= Date: Mon, 26 Jul 2021 15:51:20 +0800 Subject: [PATCH] Add the default timeout value of the interface (#6779) Signed-off-by: wangting0128 --- .../python_client/base/collection_wrapper.py | 35 +++++++++++++++++-- tests20/python_client/base/index_wrapper.py | 6 ++++ .../python_client/base/partition_wrapper.py | 18 ++++++++++ tests20/python_client/base/utility_wrapper.py | 9 +++++ 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/tests20/python_client/base/collection_wrapper.py b/tests20/python_client/base/collection_wrapper.py index 3057746949..8dec129968 100644 --- a/tests20/python_client/base/collection_wrapper.py +++ b/tests20/python_client/base/collection_wrapper.py @@ -4,6 +4,10 @@ sys.path.append("..") from check.param_check import * from check.func_check import * from utils.api_request import api_request +from utils.util_log import test_log as log + + +TIMEOUT = 5 class ApiCollectionWrapper: @@ -51,12 +55,18 @@ class ApiCollectionWrapper: return res, check_result def drop(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.drop], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() return res, check_result def load(self, partition_names=None, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.load, partition_names], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, @@ -64,6 +74,9 @@ class ApiCollectionWrapper: return res, check_result def release(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.release], **kwargs) check_result = ResponseChecker(res, func_name, check_task, @@ -71,6 +84,9 @@ class ApiCollectionWrapper: return res, check_result def insert(self, data, partition_name=None, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.insert, data, partition_name], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, @@ -81,6 +97,8 @@ class ApiCollectionWrapper: def search(self, data, anns_field, param, limit, expr=None, partition_names=None, output_fields=None, timeout=None, check_task=None, check_items=None, **kwargs): + timeout = TIMEOUT if timeout is None else timeout + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.search, data, anns_field, param, limit, expr, partition_names, output_fields, timeout], **kwargs) @@ -93,6 +111,8 @@ class ApiCollectionWrapper: def query(self, expr, output_fields=None, partition_names=None, timeout=None, check_task=None, check_items=None, **kwargs): + timeout = TIMEOUT if timeout is None else timeout + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.query, expr, output_fields, partition_names, timeout]) check_result = ResponseChecker(res, func_name, check_task, check_items, check, @@ -120,16 +140,19 @@ class ApiCollectionWrapper: return res, check_result def drop_partition(self, partition_name, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.drop_partition, partition_name], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, partition_name=partition_name, **kwargs).run() return res, check_result - def create_partition(self, partition_name, check_task=None, check_items=None, **kwargs): + def create_partition(self, partition_name, check_task=None, check_items=None, description=""): func_name = sys._getframe().f_code.co_name - res, check = api_request([self.collection.create_partition, partition_name], **kwargs) + res, check = api_request([self.collection.create_partition, partition_name, description]) check_result = ResponseChecker(res, func_name, check_task, check_items, check, - partition_name=partition_name, **kwargs).run() + partition_name=partition_name).run() return res, check_result @property @@ -143,6 +166,9 @@ class ApiCollectionWrapper: return res, check_result def create_index(self, field_name, index_params, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.create_index, field_name, index_params], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, @@ -156,6 +182,9 @@ class ApiCollectionWrapper: return res, check_result def drop_index(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, check = api_request([self.collection.drop_index], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() diff --git a/tests20/python_client/base/index_wrapper.py b/tests20/python_client/base/index_wrapper.py index 64db7458aa..e72f501f3b 100644 --- a/tests20/python_client/base/index_wrapper.py +++ b/tests20/python_client/base/index_wrapper.py @@ -7,6 +7,9 @@ from check.func_check import * from utils.api_request import api_request +TIMEOUT = 5 + + class ApiIndexWrapper: index = None @@ -21,6 +24,9 @@ class ApiIndexWrapper: return res, check_result def drop(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, is_succ = api_request([self.index.drop], **kwargs) check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ, **kwargs).run() diff --git a/tests20/python_client/base/partition_wrapper.py b/tests20/python_client/base/partition_wrapper.py index fd30ca999f..ebbaeba431 100644 --- a/tests20/python_client/base/partition_wrapper.py +++ b/tests20/python_client/base/partition_wrapper.py @@ -6,6 +6,9 @@ from check.func_check import * from utils.api_request import api_request +TIMEOUT = 5 + + class ApiPartitionWrapper: partition = None @@ -36,6 +39,9 @@ class ApiPartitionWrapper: return self.partition.num_entities if self.partition else None def drop(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, succ = api_request([self.partition.drop], **kwargs) check_result = ResponseChecker(res, func_name, @@ -43,6 +49,9 @@ class ApiPartitionWrapper: return res, check_result def load(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, succ = api_request([self.partition.load], **kwargs) check_result = ResponseChecker(res, func_name, check_task, @@ -51,6 +60,9 @@ class ApiPartitionWrapper: return res, check_result def release(self, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, succ = api_request([self.partition.release], **kwargs) check_result = ResponseChecker(res, func_name, check_task, @@ -59,6 +71,9 @@ class ApiPartitionWrapper: return res, check_result def insert(self, data, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, succ = api_request([self.partition.insert, data], **kwargs) check_result = ResponseChecker(res, func_name, check_task, @@ -68,6 +83,9 @@ class ApiPartitionWrapper: def search(self, data, anns_field, params, limit, expr=None, output_fields=None, check_task=None, check_items=None, **kwargs): + timeout = kwargs.get("timeout", TIMEOUT) + kwargs.update({"timeout": timeout}) + func_name = sys._getframe().f_code.co_name res, succ = api_request([self.partition.search, data, anns_field, params, limit, expr, output_fields], **kwargs) diff --git a/tests20/python_client/base/utility_wrapper.py b/tests20/python_client/base/utility_wrapper.py index fc40a6c746..5dd426c2ac 100644 --- a/tests20/python_client/base/utility_wrapper.py +++ b/tests20/python_client/base/utility_wrapper.py @@ -7,6 +7,9 @@ from check.func_check import * from utils.api_request import api_request +TIMEOUT = 5 + + class ApiUtilityWrapper: """ Method of encapsulating utility files """ @@ -23,6 +26,8 @@ class ApiUtilityWrapper: def wait_for_loading_complete(self, collection_name, partition_names=[], 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.wait_for_loading_complete, collection_name, partition_names, timeout, using]) @@ -42,6 +47,8 @@ class ApiUtilityWrapper: def wait_for_index_building_complete(self, collection_name, index_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.wait_for_index_building_complete, collection_name, index_name, timeout, using]) @@ -67,6 +74,8 @@ class ApiUtilityWrapper: return res, check_result def list_collections(self, 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_collections, timeout, using]) check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ,