From d379a23dae4216c79452a5e85a316a07c4a496ff Mon Sep 17 00:00:00 2001 From: zhuwenxing Date: Wed, 21 Sep 2022 16:44:51 +0800 Subject: [PATCH] [test]Fix chaos testcases (#19320) Signed-off-by: zhuwenxing Signed-off-by: zhuwenxing --- tests/python_client/chaos/conftest.py | 13 ++++++++++++- .../testcases/test_all_collections_after_chaos.py | 2 +- .../chaos/testcases/test_concurrent_operation.py | 12 +++++++----- .../testcases/test_single_request_operation.py | 7 +++++-- .../chaos/testcases/test_verify_all_collections.py | 7 +++++-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tests/python_client/chaos/conftest.py b/tests/python_client/chaos/conftest.py index 8f34c78ae9..dc29e3c4d6 100644 --- a/tests/python_client/chaos/conftest.py +++ b/tests/python_client/chaos/conftest.py @@ -7,7 +7,8 @@ def pytest_addoption(parser): 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_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 def milvus_ns(request): @@ -31,3 +32,13 @@ def chaos_duration(request): @pytest.fixture def chaos_interval(request): 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") \ No newline at end of file diff --git a/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py b/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py index d7d7632a14..f6e39adb40 100644 --- a/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py +++ b/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py @@ -26,7 +26,7 @@ class TestAllCollection(TestcaseBase): @pytest.mark.tags(CaseLabel.L1) def test_milvus_default(self, collection_name): # create - name = collection_name + name = collection_name if collection_name else cf.gen_unique_str("Checker_") t0 = time.time() collection_w = self.init_collection_wrap(name=name, active_trace=True) tt = time.time() - t0 diff --git a/tests/python_client/chaos/testcases/test_concurrent_operation.py b/tests/python_client/chaos/testcases/test_concurrent_operation.py index 62ce7ffc14..ca2e09cc62 100644 --- a/tests/python_client/chaos/testcases/test_concurrent_operation.py +++ b/tests/python_client/chaos/testcases/test_concurrent_operation.py @@ -45,7 +45,7 @@ def get_all_collections(): all_collections = data["all"] except Exception as e: log.error(f"get_all_collections error: {e}") - return [] + return [None] return all_collections @@ -98,16 +98,18 @@ class TestOperations(TestBase): yield request.param @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 log.info("*********************Test Start**********************") 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) cc.start_monitor_threads(self.health_checkers) log.info("*********************Load Start**********************") - # wait 200s - 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): sleep(request_duration//10) for k,v in self.health_checkers.items(): diff --git a/tests/python_client/chaos/testcases/test_single_request_operation.py b/tests/python_client/chaos/testcases/test_single_request_operation.py index f2d79bff60..ee429ce473 100644 --- a/tests/python_client/chaos/testcases/test_single_request_operation.py +++ b/tests/python_client/chaos/testcases/test_single_request_operation.py @@ -66,8 +66,11 @@ class TestOperations(TestBase): self.init_health_checkers(collection_name=c_name) cc.start_monitor_threads(self.health_checkers) log.info("*********************Load Start**********************") - # wait 200s - request_duration = eval(request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")) + # wait request_duration + 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): sleep(request_duration//10) for k,v in self.health_checkers.items(): diff --git a/tests/python_client/chaos/testcases/test_verify_all_collections.py b/tests/python_client/chaos/testcases/test_verify_all_collections.py index e07d067b36..d102d6cc2c 100644 --- a/tests/python_client/chaos/testcases/test_verify_all_collections.py +++ b/tests/python_client/chaos/testcases/test_verify_all_collections.py @@ -90,8 +90,11 @@ class TestOperations(TestBase): self.init_health_checkers(collection_name=c_name) cc.start_monitor_threads(self.health_checkers) log.info("*********************Request Load Start**********************") - request_duration = eval(request_duration.replace("h","*3600+").replace("m","*60+").replace("s","")) - # wait 200s for the load request to be finished + # wait request_duration 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): sleep(request_duration//10) for k,v in self.health_checkers.items():