未验证 提交 7d286ebc 编写于 作者: 紫晴 提交者: GitHub

Add input parameters for clearing log files (#5659)

* [skip ci] Update code of test_info
Signed-off-by: Nwangting0128 <ting.wang@zilliz.com>

* [skip ci] Add input parameters for clearing log files
Signed-off-by: Nwangting0128 <ting.wang@zilliz.com>
上级 bc3e0619
...@@ -12,6 +12,7 @@ from config.test_info import test_info ...@@ -12,6 +12,7 @@ from config.test_info import test_info
from utils.util_log import test_log as log from utils.util_log import test_log as log
from common import common_func as cf from common import common_func as cf
from common import common_type as ct from common import common_type as ct
from check.param_check import ip_check, number_check
class ParamInfo: class ParamInfo:
...@@ -72,12 +73,19 @@ class Base: ...@@ -72,12 +73,19 @@ class Base:
@pytest.fixture(scope="module", autouse=True) @pytest.fixture(scope="module", autouse=True)
def initialize_env(self, request): def initialize_env(self, request):
""" clean log before testing """ """ clean log before testing """
cf.modify_file([test_info.log_debug, test_info.log_info, test_info.log_err])
log.info("[initialize_milvus] Log cleaned up, start testing...")
host = request.config.getoption("--host") host = request.config.getoption("--host")
port = request.config.getoption("--port") port = request.config.getoption("--port")
handler = request.config.getoption("--handler") handler = request.config.getoption("--handler")
clean_log = request.config.getoption("--clean_log")
""" params check """
assert ip_check(host) and number_check(port)
""" modify log files """
cf.modify_file(file_path_list=[test_info.log_debug, test_info.log_info, test_info.log_err], is_modify=clean_log)
log.info("#" * 80)
log.info("[initialize_milvus] Log cleaned up, start testing...")
param_info.prepare_param_info(host, port, handler) param_info.prepare_param_info(host, port, handler)
......
...@@ -186,6 +186,7 @@ def gen_invalid_dataframe(): ...@@ -186,6 +186,7 @@ def gen_invalid_dataframe():
] ]
return dfs return dfs
def jaccard(x, y): def jaccard(x, y):
x = np.asarray(x, np.bool) x = np.asarray(x, np.bool)
y = np.asarray(y, np.bool) y = np.asarray(y, np.bool)
...@@ -241,4 +242,4 @@ def modify_file(file_path_list, is_modify=False, input_content=""): ...@@ -241,4 +242,4 @@ def modify_file(file_path_list, is_modify=False, input_content=""):
f.truncate() f.truncate()
f.write(input_content) f.write(input_content)
f.close() f.close()
log.info("[modify_file] File(%s) modification is complete." % file_path_list) log.info("[modify_file] file(%s) modification is complete." % file_path_list)
...@@ -7,20 +7,20 @@ class TestInfo: ...@@ -7,20 +7,20 @@ class TestInfo:
@staticmethod @staticmethod
def get_env_variable(var="CI_LOG_PATH"): def get_env_variable(var="CI_LOG_PATH"):
""" get log path of testing """ """ get log path for testing """
try: try:
log_path = os.environ[var] log_path = os.environ[var]
return str(log_path) return str(log_path)
except Exception as e: except Exception as e:
log_path = "/tmp/ci_logs/" log_path = "/tmp/ci_logs/"
print("Failed to get environment variables : %s, Use default path : %s" % (str(e), log_path)) print("[get_env_variable] failed to get environment variables : %s, use default path : %s" % (str(e), log_path))
return log_path return log_path
@staticmethod @staticmethod
def create_path(log_path): def create_path(log_path):
if not os.path.isdir(str(log_path)): if not os.path.isdir(str(log_path)):
print("[modify_file] folder(%s) is not exist." % log_path) print("[create_path] folder(%s) is not exist." % log_path)
print("[modify_file] create path now...") print("[create_path] create path now...")
os.makedirs(log_path) os.makedirs(log_path)
def get_default_config(self): def get_default_config(self):
......
...@@ -16,7 +16,7 @@ def pytest_addoption(parser): ...@@ -16,7 +16,7 @@ def pytest_addoption(parser):
parser.addoption('--search_vectors', action='store', default="search_vectors", help="vectors of search") parser.addoption('--search_vectors', action='store', default="search_vectors", help="vectors of search")
parser.addoption('--index_param', action='store', default="index_param", help="index_param of index") parser.addoption('--index_param', action='store', default="index_param", help="index_param of index")
parser.addoption('--data', action='store', default="data", help="data of request") parser.addoption('--data', action='store', default="data", help="data of request")
parser.addoption('--log_path', action='store', default="/tmp/ci_logs/", help="log path of ci test") parser.addoption('--clean_log', action='store_true', default=False, help="clean log before testing")
@pytest.fixture @pytest.fixture
...@@ -90,5 +90,5 @@ def data(request): ...@@ -90,5 +90,5 @@ def data(request):
@pytest.fixture @pytest.fixture
def log_path(request): def clean_log(request):
return request.config.getoption("--log_path") return request.config.getoption("--clean_log")
...@@ -14,7 +14,7 @@ class TestConnectionParams(TestcaseBase): ...@@ -14,7 +14,7 @@ class TestConnectionParams(TestcaseBase):
""" """
@pytest.mark.skip("No check for **kwargs") @pytest.mark.skip("No check for **kwargs")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_kwargs_param_check(self): def test_connection_kwargs_param_check(self):
""" """
target: test **kwargs of connection target: test **kwargs of connection
...@@ -35,7 +35,7 @@ class TestConnectionParams(TestcaseBase): ...@@ -35,7 +35,7 @@ class TestConnectionParams(TestcaseBase):
assert res[0].args[0] == "Fail connecting to server on localhost:19530. Timeout" assert res[0].args[0] == "Fail connecting to server on localhost:19530. Timeout"
@pytest.mark.skip("No check for alias") @pytest.mark.skip("No check for alias")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
@pytest.mark.parametrize("alias", get_invalid_strs) @pytest.mark.parametrize("alias", get_invalid_strs)
def test_connection_create_alias_param_check(self, alias): def test_connection_create_alias_param_check(self, alias):
""" """
...@@ -49,7 +49,7 @@ class TestConnectionParams(TestcaseBase): ...@@ -49,7 +49,7 @@ class TestConnectionParams(TestcaseBase):
@pytest.mark.skip("No check for alias") @pytest.mark.skip("No check for alias")
@pytest.mark.parametrize("alias", get_invalid_strs) @pytest.mark.parametrize("alias", get_invalid_strs)
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_get_alias_param_check(self, alias): def test_connection_get_alias_param_check(self, alias):
""" """
target: test get connection with wrong params of alias target: test get connection with wrong params of alias
...@@ -62,7 +62,7 @@ class TestConnectionParams(TestcaseBase): ...@@ -62,7 +62,7 @@ class TestConnectionParams(TestcaseBase):
@pytest.mark.skip("No check for alias") @pytest.mark.skip("No check for alias")
@pytest.mark.parametrize("alias", get_invalid_strs) @pytest.mark.parametrize("alias", get_invalid_strs)
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_get_addr_alias_param_check(self, alias): def test_connection_get_addr_alias_param_check(self, alias):
""" """
target: test get connection addr with wrong params of alias target: test get connection addr with wrong params of alias
...@@ -75,7 +75,7 @@ class TestConnectionParams(TestcaseBase): ...@@ -75,7 +75,7 @@ class TestConnectionParams(TestcaseBase):
@pytest.mark.skip("No check for alias") @pytest.mark.skip("No check for alias")
@pytest.mark.parametrize("alias", get_invalid_strs) @pytest.mark.parametrize("alias", get_invalid_strs)
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_remove_alias_param_check(self, alias): def test_connection_remove_alias_param_check(self, alias):
""" """
target: test remove connection with wrong params of alias target: test remove connection with wrong params of alias
...@@ -94,7 +94,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -94,7 +94,7 @@ class TestConnectionOperation(TestcaseBase):
The author : Ting.Wang The author : Ting.Wang
""" """
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_configure_repeat(self, host, port): def test_connection_configure_repeat(self, host, port):
""" """
target: test connection configure four times target: test connection configure four times
...@@ -114,7 +114,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -114,7 +114,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.add_connection() self.connection_wrap.add_connection()
assert self.connection_wrap.list_connections()[0] == [('default', None), ('dev', None), ('default1', None)] assert self.connection_wrap.list_connections()[0] == [('default', None), ('dev', None), ('default1', None)]
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_remove_connection_not_exist(self): def test_connection_remove_connection_not_exist(self):
""" """
target: test remove connection that is not exist target: test remove connection that is not exist
...@@ -131,7 +131,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -131,7 +131,7 @@ class TestConnectionOperation(TestcaseBase):
res = self.connection_wrap.remove_connection(alias=Not_Exist, check_res="") res = self.connection_wrap.remove_connection(alias=Not_Exist, check_res="")
assert res[0].args[0] == "There is no connection with alias '%s'." % Not_Exist assert res[0].args[0] == "There is no connection with alias '%s'." % Not_Exist
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_remove_connection_repeat(self): def test_connection_remove_connection_repeat(self):
""" """
target: test remove connection twice target: test remove connection twice
...@@ -145,7 +145,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -145,7 +145,7 @@ class TestConnectionOperation(TestcaseBase):
res = self.connection_wrap.remove_connection(alias='default', check_res='') res = self.connection_wrap.remove_connection(alias='default', check_res='')
assert res[0].args[0] == "There is no connection with alias 'default'." assert res[0].args[0] == "There is no connection with alias 'default'."
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_normal_remove_connection_repeat(self, host, port): def test_connection_normal_remove_connection_repeat(self, host, port):
""" """
target: test remove connection twice target: test remove connection twice
...@@ -163,7 +163,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -163,7 +163,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.remove_connection(alias='default') self.connection_wrap.remove_connection(alias='default')
self.connection_wrap.remove_connection(alias='dev') self.connection_wrap.remove_connection(alias='dev')
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_remove_connection_100_repeat(self): def test_connection_remove_connection_100_repeat(self):
""" """
target: test delete the same connection 100 times target: test delete the same connection 100 times
...@@ -177,7 +177,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -177,7 +177,7 @@ class TestConnectionOperation(TestcaseBase):
res = self.connection_wrap.remove_connection(alias='default', check_res='') res = self.connection_wrap.remove_connection(alias='default', check_res='')
assert res[0].args[0] == "There is no connection with alias 'default'." assert res[0].args[0] == "There is no connection with alias 'default'."
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_configure_remove_connection(self, host, port): def test_connection_configure_remove_connection(self, host, port):
""" """
target: test remove configure alias target: test remove configure alias
...@@ -191,7 +191,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -191,7 +191,7 @@ class TestConnectionOperation(TestcaseBase):
assert res[0].args[0] == "There is no connection with alias '%s'." % alias_name assert res[0].args[0] == "There is no connection with alias '%s'." % alias_name
@pytest.mark.skip("error res") @pytest.mark.skip("error res")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_connection_remove_configure(self, host, port): def test_connection_create_connection_remove_configure(self, host, port):
""" """
target: test create connection before remove configure target: test create connection before remove configure
...@@ -204,7 +204,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -204,7 +204,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.get_connection(alias=alias_name) self.connection_wrap.get_connection(alias=alias_name)
@pytest.mark.skip("error res") @pytest.mark.skip("error res")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_connection_reset_configure(self, host, port): def test_connection_create_connection_reset_configure(self, host, port):
""" """
target: test params of create connection are different with configure target: test params of create connection are different with configure
...@@ -217,7 +217,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -217,7 +217,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.get_connection(alias=alias_name) self.connection_wrap.get_connection(alias=alias_name)
@pytest.mark.skip("res needs to be confirmed") @pytest.mark.skip("res needs to be confirmed")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_connection_diff_configure(self, host, port): def test_connection_create_connection_diff_configure(self, host, port):
""" """
target: test params of create connection are different with configure target: test params of create connection are different with configure
...@@ -231,7 +231,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -231,7 +231,7 @@ class TestConnectionOperation(TestcaseBase):
res = self.connection_wrap.connect(alias="default", host=host, port=port, check_task='') res = self.connection_wrap.connect(alias="default", host=host, port=port, check_task='')
log.info(res[0]) log.info(res[0])
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_connection_repeat(self, host, port): def test_connection_create_connection_repeat(self, host, port):
""" """
target: test create connection twice target: test create connection twice
...@@ -244,7 +244,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -244,7 +244,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.connect(alias='default', host=host, port=port) self.connection_wrap.connect(alias='default', host=host, port=port)
self.connection_wrap.get_connection(alias='default') self.connection_wrap.get_connection(alias='default')
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_connection_not_exist(self, port): def test_connection_create_connection_not_exist(self, port):
""" """
target: test create connection is not exist target: test create connection is not exist
...@@ -255,7 +255,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -255,7 +255,7 @@ class TestConnectionOperation(TestcaseBase):
res = self.connection_wrap.connect(alias="default", host='host', port=port, check_task='') res = self.connection_wrap.connect(alias="default", host='host', port=port, check_task='')
assert res[0].args[0] == "Fail connecting to server on host:19530. Timeout" assert res[0].args[0] == "Fail connecting to server on host:19530. Timeout"
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_create_remove(self, host, port): def test_connection_create_remove(self, host, port):
""" """
target: test create and remove connection twice target: test create and remove connection twice
...@@ -270,7 +270,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -270,7 +270,7 @@ class TestConnectionOperation(TestcaseBase):
self.connection_wrap.connect(alias=alias_name, host=host, port=port) self.connection_wrap.connect(alias=alias_name, host=host, port=port)
self.connection_wrap.get_connection(alias=alias_name) self.connection_wrap.get_connection(alias=alias_name)
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_list_configure(self, host, port): def test_connection_list_configure(self, host, port):
""" """
target: test list connection of configure target: test list connection of configure
...@@ -282,7 +282,7 @@ class TestConnectionOperation(TestcaseBase): ...@@ -282,7 +282,7 @@ class TestConnectionOperation(TestcaseBase):
assert self.connection_wrap.list_connections()[0] == ['default', 'dev'] assert self.connection_wrap.list_connections()[0] == ['default', 'dev']
@pytest.mark.skip("Behavior to be determined") @pytest.mark.skip("Behavior to be determined")
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L3)
def test_connection_list_create_configure(self, host, port): def test_connection_list_create_configure(self, host, port):
""" """
target: test list connection of configure target: test list connection of configure
......
...@@ -12,7 +12,7 @@ def api_request_catch(): ...@@ -12,7 +12,7 @@ def api_request_catch():
def inner_wrapper(*args, **kwargs): def inner_wrapper(*args, **kwargs):
try: try:
res = func(*args, **kwargs) res = func(*args, **kwargs)
log.debug("(func_res) Response : %s " % str(res)) log.debug("(api_res) Response : %s " % str(res))
return res, True return res, True
except Exception as e: except Exception as e:
log.error("[Milvus API Exception]%s: %s" % (str(func), str(e))) log.error("[Milvus API Exception]%s: %s" % (str(func), str(e)))
...@@ -30,6 +30,6 @@ def api_request(_list, **kwargs): ...@@ -30,6 +30,6 @@ def api_request(_list, **kwargs):
if len(_list) > 1: if len(_list) > 1:
for a in _list[1:]: for a in _list[1:]:
arg.append(a) arg.append(a)
log.debug("(func_req)[%s] Parameters ars arg: %s, kwargs: %s" % (str(func), str(arg), str(kwargs))) log.debug("(api_req)[%s] Parameters ars arg: %s, kwargs: %s" % (str(func), str(arg), str(kwargs)))
return func(*arg, **kwargs) return func(*arg, **kwargs)
return False, False return False, False
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册