mirror of https://github.com/milvus-io/milvus.git
[test]Add auth optional for test (#18306)
Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>pull/18312/head
parent
f7bd054adb
commit
4d94e465dc
|
@ -88,8 +88,13 @@ class TestcaseBase(Base):
|
|||
|
||||
def _connect(self):
|
||||
""" Add a connection and create the connect """
|
||||
res, is_succ = self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=cf.param_info.param_host,
|
||||
port=cf.param_info.param_port)
|
||||
if cf.param_info.param_user and cf.param_info.param_password:
|
||||
res, is_succ = self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=cf.param_info.param_host,
|
||||
port=cf.param_info.param_port, user=cf.param_info.param_user,
|
||||
password=cf.param_info.param_password, secure=cf.param_info.param_secure)
|
||||
else:
|
||||
res, is_succ = self.connection_wrap.connect(alias=DefaultConfig.DEFAULT_USING, host=cf.param_info.param_host,
|
||||
port=cf.param_info.param_port)
|
||||
return res
|
||||
|
||||
def init_collection_wrap(self, name=None, schema=None, shards_num=2, check_task=None, check_items=None, **kwargs):
|
||||
|
|
|
@ -18,12 +18,18 @@ class ParamInfo:
|
|||
self.param_host = ""
|
||||
self.param_port = ""
|
||||
self.param_handler = ""
|
||||
self.param_user = ""
|
||||
self.param_password = ""
|
||||
self.param_secure = False
|
||||
self.param_replica_num = ct.default_replica_num
|
||||
|
||||
def prepare_param_info(self, host, port, handler, replica_num):
|
||||
def prepare_param_info(self, host, port, handler, replica_num, user, password, secure):
|
||||
self.param_host = host
|
||||
self.param_port = port
|
||||
self.param_handler = handler
|
||||
self.param_user = user
|
||||
self.param_password = password
|
||||
self.param_secure = secure
|
||||
self.param_replica_num = replica_num
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,9 @@ def pytest_addoption(parser):
|
|||
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("--user", action="store", default="", help="user name for connection")
|
||||
parser.addoption("--password", action="store", default="", help="password for connection")
|
||||
parser.addoption("--secure", action="store", default=False, help="secure for connection")
|
||||
parser.addoption("--http_port", action="store", default=19121, help="http's port")
|
||||
parser.addoption("--handler", action="store", default="GRPC", help="handler of request")
|
||||
parser.addoption("--tag", action="store", default="all", help="only run tests matching the tag.")
|
||||
|
@ -57,6 +60,21 @@ def port(request):
|
|||
return request.config.getoption("--port")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def user(request):
|
||||
return request.config.getoption("--user")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def password(request):
|
||||
return request.config.getoption("--password")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def secure(request):
|
||||
return request.config.getoption("--secure")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def http_port(request):
|
||||
return request.config.getoption("--http_port")
|
||||
|
@ -153,6 +171,9 @@ def initialize_env(request):
|
|||
host = request.config.getoption("--host")
|
||||
port = request.config.getoption("--port")
|
||||
handler = request.config.getoption("--handler")
|
||||
user = request.config.getoption("--user")
|
||||
password = request.config.getoption("--password")
|
||||
secure = request.config.getoption("--secure")
|
||||
clean_log = request.config.getoption("--clean_log")
|
||||
replica_num = request.config.getoption("--replica_num")
|
||||
|
||||
|
@ -167,7 +188,7 @@ def initialize_env(request):
|
|||
|
||||
log.info("#" * 80)
|
||||
log.info("[initialize_milvus] Log cleaned up, start testing...")
|
||||
param_info.prepare_param_info(host, port, handler, replica_num)
|
||||
param_info.prepare_param_info(host, port, handler, replica_num, user, password, secure)
|
||||
|
||||
|
||||
@pytest.fixture(params=ct.get_invalid_strs)
|
||||
|
|
Loading…
Reference in New Issue