diff --git a/tests20/python_client/base/ClientRequest.py b/tests20/python_client/base/client_request.py similarity index 65% rename from tests20/python_client/base/ClientRequest.py rename to tests20/python_client/base/client_request.py index a34706fa80..7b4ff5a39e 100644 --- a/tests20/python_client/base/ClientRequest.py +++ b/tests20/python_client/base/client_request.py @@ -2,13 +2,13 @@ import pytest import sys sys.path.append("..") -from base.Connections import ApiConnections -from base.Collection import ApiCollection -from base.Partition import ApiPartition -from base.Index import ApiIndex -from base.Utility import ApiUtility +from base.connections import ApiConnections +from base.collection import ApiCollection +from base.partition import ApiPartition +from base.index import ApiIndex +from base.utility import ApiUtility -from config.my_info import my_info +from config.test_info import test_info from common.common_func import * from check.func_check import * @@ -40,12 +40,12 @@ def func_req(_list, **kwargs): class ParamInfo: def __init__(self): - self.param_ip = "" + self.param_host = "" self.param_port = "" self.param_handler = "" - def prepare_param_info(self, ip, port, handler): - self.param_ip = ip + def prepare_param_info(self, host, port, handler): + self.param_host = host self.param_port = port self.param_handler = handler @@ -82,13 +82,13 @@ class Base: @pytest.fixture(scope="module", autouse=True) def initialize_env(self, request): """ clean log before testing """ - modify_file([my_info.test_log, my_info.test_err]) + modify_file([test_info.log_info, test_info.log_err]) log.info("[initialize_milvus] Log cleaned up, start testing...") - ip = request.config.getoption("--ip") + host = request.config.getoption("--host") port = request.config.getoption("--port") handler = request.config.getoption("--handler") - param_info.prepare_param_info(ip, port, handler) + param_info.prepare_param_info(host, port, handler) class ApiReq(Base): @@ -97,9 +97,14 @@ class ApiReq(Base): Public methods that can be used to add cases. """ - def func(self): - pass + def _connect(self): + """ Testing func """ + self.connection.configure(check_res='', default={"host": "192.168.1.240", "port": "19530"}) + res = self.connection.get_connection(alias='default') + return res - @staticmethod - def func_2(): - pass + def _collection(self, name=get_unique_str, data=None, schema=None, check_res=None, **kwargs): + """ Testing func """ + self._connect() + res = self.collection.collection_init(name=name, data=data, schema=schema, check_res=check_res, **kwargs) + return res diff --git a/tests20/python_client/base/Collection.py b/tests20/python_client/base/collection.py similarity index 99% rename from tests20/python_client/base/Collection.py rename to tests20/python_client/base/collection.py index 264df81522..84530c05fa 100644 --- a/tests20/python_client/base/Collection.py +++ b/tests20/python_client/base/collection.py @@ -6,7 +6,7 @@ import sys sys.path.append("..") from check.param_check import * from check.func_check import * -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/base/Connections.py b/tests20/python_client/base/connections.py similarity index 98% rename from tests20/python_client/base/Connections.py rename to tests20/python_client/base/connections.py index e07228512e..af294b2d2e 100644 --- a/tests20/python_client/base/Connections.py +++ b/tests20/python_client/base/connections.py @@ -6,7 +6,7 @@ import sys sys.path.append("..") from check.param_check import * from check.func_check import * -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/base/Index.py b/tests20/python_client/base/index.py similarity index 98% rename from tests20/python_client/base/Index.py rename to tests20/python_client/base/index.py index 84ca45686b..b7dee81d8c 100644 --- a/tests20/python_client/base/Index.py +++ b/tests20/python_client/base/index.py @@ -6,7 +6,7 @@ import sys sys.path.append("..") from check.param_check import * from check.func_check import * -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/base/Partition.py b/tests20/python_client/base/partition.py similarity index 99% rename from tests20/python_client/base/Partition.py rename to tests20/python_client/base/partition.py index b1f0549163..0944165804 100644 --- a/tests20/python_client/base/Partition.py +++ b/tests20/python_client/base/partition.py @@ -6,7 +6,7 @@ import sys sys.path.append("..") from check.param_check import * from check.func_check import * -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/base/Utility.py b/tests20/python_client/base/utility.py similarity index 98% rename from tests20/python_client/base/Utility.py rename to tests20/python_client/base/utility.py index 94620969ec..51004fd9f3 100644 --- a/tests20/python_client/base/Utility.py +++ b/tests20/python_client/base/utility.py @@ -6,7 +6,7 @@ import sys sys.path.append("..") from check.param_check import * from check.func_check import * -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/check/func_check.py b/tests20/python_client/check/func_check.py index 7167d30e6a..eef4b5537b 100644 --- a/tests20/python_client/check/func_check.py +++ b/tests20/python_client/check/func_check.py @@ -1,4 +1,4 @@ -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * @@ -18,7 +18,8 @@ class CheckFunc: check_result = True if self.check_res is None: - log.info("self.check_res is None, the response of API: %s" % self.res) + pass + # log.info("self.check_res is None, the response of API: %s" % self.res) elif self.check_res == cname_param_check: check_result = self.req_cname_check(self.res, self.func_name, self.params.get('collection_name')) elif self.check_res == pname_param_check: diff --git a/tests20/python_client/check/param_check.py b/tests20/python_client/check/param_check.py index 4ad23e40ff..e3253c917d 100644 --- a/tests20/python_client/check/param_check.py +++ b/tests20/python_client/check/param_check.py @@ -2,7 +2,7 @@ import pytest import sys sys.path.append("..") -from utils.util_log import my_log +from utils.util_log import test_log as log def ip_check(ip): @@ -10,17 +10,17 @@ def ip_check(ip): return True if not isinstance(ip, str): - my_log.error("[IP_CHECK] IP(%s) is not a string." % ip) + log.error("[IP_CHECK] IP(%s) is not a string." % ip) return False _list = ip.split('.') if len(_list) != 4: - my_log.error("[IP_CHECK] IP(%s) is wrong, please check manually." % ip) + log.error("[IP_CHECK] IP(%s) is wrong, please check manually." % ip) return False for i in _list: if not str(i).isdigit(): - my_log.error("[IP_CHECK] IP(%s) is wrong, please check manually." % ip) + log.error("[IP_CHECK] IP(%s) is wrong, please check manually." % ip) return False return True @@ -31,7 +31,7 @@ def number_check(num): return True else: - my_log.error("[NUMBER_CHECK] Number(%s) is not a numbers." % num) + log.error("[NUMBER_CHECK] Number(%s) is not a numbers." % num) return False @@ -40,5 +40,5 @@ def exist_check(param, _list): return True else: - my_log.error("[EXIST_CHECK] Param(%s) is not in (%s)" % (param, _list)) + log.error("[EXIST_CHECK] Param(%s) is not in (%s)" % (param, _list)) return False diff --git a/tests20/python_client/common/common_func.py b/tests20/python_client/common/common_func.py index 482949abb2..8478487f5d 100644 --- a/tests20/python_client/common/common_func.py +++ b/tests20/python_client/common/common_func.py @@ -5,13 +5,15 @@ import numpy as np from sklearn import preprocessing from pymilvus_orm.types import DataType -from utils.util_log import my_log as log +from utils.util_log import test_log as log from common.common_type import * """" Methods of processing data """ l2 = lambda x, y: np.linalg.norm(np.array(x) - np.array(y)) +get_unique_str = "test_" + "".join(random.choice(string.ascii_letters + string.digits) for _ in range(8)) + def get_binary_default_fields(auto_id=True): default_fields = { @@ -53,11 +55,6 @@ def get_entities(nb=default_nb, is_normal=False): return entities -def get_unique_str(str_value="test_"): - prefix = "".join(random.choice(string.ascii_letters + string.digits) for _ in range(8)) - return str_value + "_" + prefix - - def modify_file(file_name_list, input_content=""): if not isinstance(file_name_list, list): log.error("[modify_file] file is not a list.") diff --git a/tests20/python_client/config/my_info.py b/tests20/python_client/config/test_info.py similarity index 58% rename from tests20/python_client/config/my_info.py rename to tests20/python_client/config/test_info.py index b66a9ecf50..0278e2c5c2 100644 --- a/tests20/python_client/config/my_info.py +++ b/tests20/python_client/config/test_info.py @@ -1,7 +1,7 @@ import json -class MyInfo: +class TestInfo: def __init__(self): self.get_default_config() @@ -9,8 +9,8 @@ class MyInfo: """ Make sure the path exists """ self.home_dir = "/tmp/" self.log_dir = self.home_dir + "log/" - self.test_log = "%s/refactor_test.log" % self.log_dir - self.test_err = "%s/refactor_test.err" % self.log_dir + self.log_info = "%s/refactor_test.log" % self.log_dir + self.log_err = "%s/refactor_test.err" % self.log_dir -my_info = MyInfo() +test_info = TestInfo() diff --git a/tests20/python_client/conftest.py b/tests20/python_client/conftest.py index 2d14ce020b..65f23201db 100644 --- a/tests20/python_client/conftest.py +++ b/tests20/python_client/conftest.py @@ -3,6 +3,7 @@ import pytest def pytest_addoption(parser): parser.addoption("--ip", action="store", default="localhost", help="service's ip") + parser.addoption("--host", action="store", default="localhost", help="service's ip") parser.addoption("--service", action="store", default="", help="service address") parser.addoption("--port", action="store", default=19530, help="service's port") parser.addoption("--http_port", action="store", default=19121, help="http's port") @@ -16,6 +17,11 @@ def ip(request): return request.config.getoption("--ip") +@pytest.fixture +def host(request): + return request.config.getoption("--host") + + @pytest.fixture def service(request): return request.config.getoption("--service") diff --git a/tests20/python_client/pytest.ini b/tests20/python_client/pytest.ini index 56c5f9692b..91d77821bf 100644 --- a/tests20/python_client/pytest.ini +++ b/tests20/python_client/pytest.ini @@ -1,4 +1,4 @@ [pytest] -addopts = --ip 192.168.1.240 --html=/Users/wt/Desktop/report.html +addopts = --host 192.168.1.240 --html=/Users/wt/Desktop/report.html # python3 -W ignore -m pytest \ No newline at end of file diff --git a/tests20/python_client/requirements.txt b/tests20/python_client/requirements.txt index 174987cad8..c7de4737ec 100644 --- a/tests20/python_client/requirements.txt +++ b/tests20/python_client/requirements.txt @@ -1,5 +1,6 @@ pytest==5.3.4 sklearn==0.0 numpy==1.18.1 +pytest-html==3.1.1 pymilvus-orm==0.0.1 git+https://github.com/Projectplace/pytest-tags diff --git a/tests20/python_client/testcases/test_collection.py b/tests20/python_client/testcases/test_collection.py index 300d51a89a..563f403a5d 100644 --- a/tests20/python_client/testcases/test_collection.py +++ b/tests20/python_client/testcases/test_collection.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/testcases/test_connection.py b/tests20/python_client/testcases/test_connection.py index 5cffda3675..06adeef1da 100644 --- a/tests20/python_client/testcases/test_connection.py +++ b/tests20/python_client/testcases/test_connection.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * @@ -13,3 +13,12 @@ class TestConnection(ApiReq): res_ = self.connection.get_connection(alias='default') log.info("res : %s" % str(res_)) log.info("self.connection : %s" % str(self.connection)) + res_list = self.connection.list_connections() + log.info(res_list) + + def test_connection_kwargs_param_check(self): + res_configure = self.connection.configure(check_res='', default={"host": "192.168.1.240", "port": "19530"}) + log.info(res_configure) + res_list = self.connection.list_connections() + log.info(res_list) + diff --git a/tests20/python_client/testcases/test_index.py b/tests20/python_client/testcases/test_index.py index 96a76b3f22..148dd544b4 100644 --- a/tests20/python_client/testcases/test_index.py +++ b/tests20/python_client/testcases/test_index.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/testcases/test_params.py b/tests20/python_client/testcases/test_params.py index 4f5d8da9ff..b2b38884b1 100644 --- a/tests20/python_client/testcases/test_params.py +++ b/tests20/python_client/testcases/test_params.py @@ -3,8 +3,8 @@ from milvus import DataType from common.common_type import * from common.common_func import * -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log class TestParams(ApiReq): diff --git a/tests20/python_client/testcases/test_partition.py b/tests20/python_client/testcases/test_partition.py index 35d4f9d474..34e5bfa8fb 100644 --- a/tests20/python_client/testcases/test_partition.py +++ b/tests20/python_client/testcases/test_partition.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/testcases/test_schema.py b/tests20/python_client/testcases/test_schema.py index e150ac234c..dcc6d6cfdb 100644 --- a/tests20/python_client/testcases/test_schema.py +++ b/tests20/python_client/testcases/test_schema.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/testcases/test_search.py b/tests20/python_client/testcases/test_search.py index 5e774631bb..249fae3d6f 100644 --- a/tests20/python_client/testcases/test_search.py +++ b/tests20/python_client/testcases/test_search.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/testcases/test_utility.py b/tests20/python_client/testcases/test_utility.py index ac4d455626..22961e9c82 100644 --- a/tests20/python_client/testcases/test_utility.py +++ b/tests20/python_client/testcases/test_utility.py @@ -1,6 +1,6 @@ import pytest -from base.ClientRequest import ApiReq -from utils.util_log import my_log as log +from base.client_request import ApiReq +from utils.util_log import test_log as log from common.common_type import * diff --git a/tests20/python_client/utils/util_log.py b/tests20/python_client/utils/util_log.py index d0ec75959b..3178f01e4e 100644 --- a/tests20/python_client/utils/util_log.py +++ b/tests20/python_client/utils/util_log.py @@ -1,9 +1,9 @@ import logging -from config.my_info import my_info +from config.test_info import test_info -class MyLog: +class TestLog: def __init__(self, logger, log_file, log_err): self.logger = logger self.log_file = log_file @@ -30,6 +30,6 @@ class MyLog: """All modules share this unified log""" -test_log = my_info.test_log -test_err = my_info.test_err -my_log = MyLog('refactor_test', test_log, test_err).log +log_info = test_info.log_info +log_err = test_info.log_err +test_log = TestLog('refactor_test', log_info, log_err).log