mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-03 12:29:36 +08:00
parent
8b7181c584
commit
ec3d8c98a4
@ -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
|
@ -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 *
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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.")
|
||||
|
@ -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()
|
@ -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")
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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 *
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user