[test]Fix chaos testcases (#19320)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
zhuwenxing 2022-09-21 16:44:51 +08:00 committed by GitHub
parent fc3309b8b8
commit d379a23dae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 11 deletions

View File

@ -7,7 +7,8 @@ def pytest_addoption(parser):
parser.addoption("--target_component", action="store", default="querynode", help="target_component") parser.addoption("--target_component", action="store", default="querynode", help="target_component")
parser.addoption("--chaos_duration", action="store", default="1m", help="chaos_duration") parser.addoption("--chaos_duration", action="store", default="1m", help="chaos_duration")
parser.addoption("--chaos_interval", action="store", default="10s", help="chaos_interval") parser.addoption("--chaos_interval", action="store", default="10s", help="chaos_interval")
parser.addoption("--request_duration", action="store", default="3m", help="request_duration")
parser.addoption("--is_check", action="store", type=bool, default=False, help="is_check")
@pytest.fixture @pytest.fixture
def milvus_ns(request): def milvus_ns(request):
@ -31,3 +32,13 @@ def chaos_duration(request):
@pytest.fixture @pytest.fixture
def chaos_interval(request): def chaos_interval(request):
return request.config.getoption("--chaos_interval") return request.config.getoption("--chaos_interval")
@pytest.fixture
def request_duration(request):
return request.config.getoption("--request_duration")
@pytest.fixture
def is_check(request):
return request.config.getoption("--is_check")

View File

@ -26,7 +26,7 @@ class TestAllCollection(TestcaseBase):
@pytest.mark.tags(CaseLabel.L1) @pytest.mark.tags(CaseLabel.L1)
def test_milvus_default(self, collection_name): def test_milvus_default(self, collection_name):
# create # create
name = collection_name name = collection_name if collection_name else cf.gen_unique_str("Checker_")
t0 = time.time() t0 = time.time()
collection_w = self.init_collection_wrap(name=name, active_trace=True) collection_w = self.init_collection_wrap(name=name, active_trace=True)
tt = time.time() - t0 tt = time.time() - t0

View File

@ -45,7 +45,7 @@ def get_all_collections():
all_collections = data["all"] all_collections = data["all"]
except Exception as e: except Exception as e:
log.error(f"get_all_collections error: {e}") log.error(f"get_all_collections error: {e}")
return [] return [None]
return all_collections return all_collections
@ -98,16 +98,18 @@ class TestOperations(TestBase):
yield request.param yield request.param
@pytest.mark.tags(CaseLabel.L3) @pytest.mark.tags(CaseLabel.L3)
def test_operations(self, request_duration, is_check): def test_operations(self, request_duration, is_check, collection_name):
# start the monitor threads to check the milvus ops # start the monitor threads to check the milvus ops
log.info("*********************Test Start**********************") log.info("*********************Test Start**********************")
log.info(connections.get_connection_addr('default')) log.info(connections.get_connection_addr('default'))
c_name = cf.gen_unique_str("Checker_") c_name = collection_name if collection_name else cf.gen_unique_str("Checker_")
self.init_health_checkers(collection_name=c_name) self.init_health_checkers(collection_name=c_name)
cc.start_monitor_threads(self.health_checkers) cc.start_monitor_threads(self.health_checkers)
log.info("*********************Load Start**********************") log.info("*********************Load Start**********************")
# wait 200s request_duration = request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")
request_duration = eval(request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")) if request_duration[-1] == "+":
request_duration = request_duration[:-1]
request_duration = eval(request_duration)
for i in range(10): for i in range(10):
sleep(request_duration//10) sleep(request_duration//10)
for k,v in self.health_checkers.items(): for k,v in self.health_checkers.items():

View File

@ -66,8 +66,11 @@ class TestOperations(TestBase):
self.init_health_checkers(collection_name=c_name) self.init_health_checkers(collection_name=c_name)
cc.start_monitor_threads(self.health_checkers) cc.start_monitor_threads(self.health_checkers)
log.info("*********************Load Start**********************") log.info("*********************Load Start**********************")
# wait 200s # wait request_duration
request_duration = eval(request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")) request_duration = request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")
if request_duration[-1] == "+":
request_duration = request_duration[:-1]
request_duration = eval(request_duration)
for i in range(10): for i in range(10):
sleep(request_duration//10) sleep(request_duration//10)
for k,v in self.health_checkers.items(): for k,v in self.health_checkers.items():

View File

@ -90,8 +90,11 @@ class TestOperations(TestBase):
self.init_health_checkers(collection_name=c_name) self.init_health_checkers(collection_name=c_name)
cc.start_monitor_threads(self.health_checkers) cc.start_monitor_threads(self.health_checkers)
log.info("*********************Request Load Start**********************") log.info("*********************Request Load Start**********************")
request_duration = eval(request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")) # wait request_duration for the load request to be finished
# wait 200s for the load request to be finished request_duration = request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")
if request_duration[-1] == "+":
request_duration = request_duration[:-1]
request_duration = eval(request_duration)
for i in range(10): for i in range(10):
sleep(request_duration//10) sleep(request_duration//10)
for k,v in self.health_checkers.items(): for k,v in self.health_checkers.items():