[skip ci]Refine chaos test to support different release name (#12293)

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
This commit is contained in:
zhuwenxing 2021-11-26 10:53:16 +08:00 committed by GitHub
parent 58964621a5
commit 1ca476c747
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View File

@ -12,7 +12,6 @@ elif [[ "$unamestr" == 'Darwin' ]]; then
fi
echo "platform: $platform"
release="milvus-chaos"
ns="chaos-testing"
# switch namespace
@ -20,9 +19,10 @@ kubectl config set-context --current --namespace=${ns}
# set parameters
pod=${1:-"querynode"}
chaos_type=${2:-"pod_kill"}
chaos_type=${2:-"pod_kill"} #pod_kill or pod_failure
chaos_task=${3:-"chaos-test"} # chaos-test or data-consist-test
release="test"-${pod}-${chaos_type/_/-} # replace pod_kill to pod-kill
# install milvus cluster for chaos testing
pushd ./scripts
@ -65,9 +65,17 @@ fi
# run chaos testing
echo "start running testcase ${pod}"
host=$(kubectl get svc/milvus-chaos -o jsonpath="{.spec.clusterIP}")
if [[ $release =~ "milvus" ]]
then
host=$(kubectl get svc/${release} -o jsonpath="{.spec.clusterIP}")
else
host=$(kubectl get svc/${release}-milvus -o jsonpath="{.spec.clusterIP}")
fi
python scripts/hello_milvus.py --host "$host"
# chaos test
export ENABLE_TRACEBACK=False
if [ "$chaos_task" == "chaos-test" ];
then
pytest -s -v test_chaos.py --host "$host" --log-cli-level=INFO --capture=no || echo "chaos test fail"

View File

@ -3,6 +3,7 @@ import threading
import pytest
import os
import time
import json
from time import sleep
from pymilvus import connections
@ -132,15 +133,20 @@ class TestChaos(TestChaosBase):
# parse chaos object
chaos_config = cc.gen_experiment_config(chaos_yaml)
self._chaos_config = chaos_config # cache the chaos config for tear down
log.info(f"chaos_config: {chaos_config}")
# parse the test expectations in testcases.yaml
if self.parser_testcase_config(chaos_yaml) is False:
log.error("Fail to get the testcase info in testcases.yaml")
assert False
# init report
meta_name = chaos_config.get('metadata', None).get('name', None)
release_name = meta_name
chaos_config_str = json.dumps(chaos_config)
chaos_config_str = chaos_config_str.replace("milvus-chaos", release_name)
chaos_config = json.loads(chaos_config_str)
self._chaos_config = chaos_config # cache the chaos config for tear down
log.info(f"chaos_config: {chaos_config}")
# init report
dir_name = "./reports"
file_name = f"./reports/{meta_name}.log"
if not os.path.exists(dir_name):