未验证 提交 5534d384 编写于 作者: Z zhuwenxing 提交者: GitHub

[test] Fix chaos duration is not updated and add target number option (#22346)

Signed-off-by: Nzhuwenxing <wenxing.zhu@zilliz.com>
上级 bddda5bd
......@@ -4,6 +4,7 @@ import pytest
def pytest_addoption(parser):
parser.addoption("--chaos_type", action="store", default="pod_kill", help="chaos_type")
parser.addoption("--target_component", action="store", default="querynode", help="target_component")
parser.addoption("--target_number", action="store", default="1", help="target_number")
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")
......@@ -20,6 +21,11 @@ def target_component(request):
return request.config.getoption("--target_component")
@pytest.fixture
def target_number(request):
return request.config.getoption("--target_number")
@pytest.fixture
def chaos_duration(request):
return request.config.getoption("--chaos_duration")
......
......@@ -54,7 +54,7 @@ class TestChaosApply:
chaos_res.delete(meta_name, raise_ex=False)
sleep(2)
def test_chaos_apply(self, chaos_type, target_component, chaos_duration, chaos_interval):
def test_chaos_apply(self, chaos_type, target_component, target_number, chaos_duration, chaos_interval):
# start the monitor threads to check the milvus ops
log.info("*********************Chaos Test Start**********************")
log.info(connections.get_connection_addr('default'))
......@@ -67,6 +67,7 @@ class TestChaosApply:
update_key_value(chaos_config, "release", release_name)
update_key_value(chaos_config, "app.kubernetes.io/instance", release_name)
update_key_value(chaos_config, "namespaces", [self.milvus_ns])
update_key_value(chaos_config, "value", target_number)
self.chaos_config = chaos_config
if "s" in chaos_interval:
schedule = f"*/{chaos_interval[:-1]} * * * * *"
......@@ -76,6 +77,7 @@ class TestChaosApply:
# update chaos_duration from string to int with unit second
chaos_duration = chaos_duration.replace('h', '*3600+').replace('m', '*60+').replace('s', '*1+') + '+0'
chaos_duration = eval(chaos_duration)
update_key_value(chaos_config, "duration", f"{chaos_duration//60}m")
if self.deploy_by == "milvus-operator":
update_key_name(chaos_config, "component", "app.kubernetes.io/component")
self._chaos_config = chaos_config # cache the chaos config for tear down
......
......@@ -37,7 +37,7 @@ class CustomResourceOperations(object):
try:
api_response = api_instance.create_namespaced_custom_object(self.group, self.version, self.namespace,
plural=self.plural, body=body, pretty=pretty)
log.debug(f"create custom resource response: {api_response}")
log.info(f"create custom resource response: {api_response}")
except ApiException as e:
log.error("Exception when calling CustomObjectsApi->create_namespaced_custom_object: %s\n" % e)
raise Exception(str(e))
......@@ -51,7 +51,7 @@ class CustomResourceOperations(object):
api_response = api_instance.delete_namespaced_custom_object(self.group, self.version, self.namespace,
self.plural,
metadata_name)
log.debug(f"delete custom resource response: {api_response}")
log.info(f"delete custom resource response: {api_response}")
except ApiException as e:
if raise_ex:
log.error("Exception when calling CustomObjectsApi->delete_namespaced_custom_object: %s\n" % e)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册