2021-10-22 11:55:14 +00:00
|
|
|
set -e
|
|
|
|
set -x
|
|
|
|
|
|
|
|
|
|
|
|
echo "check os env"
|
|
|
|
platform='unknown'
|
|
|
|
unamestr=$(uname)
|
|
|
|
if [[ "$unamestr" == 'Linux' ]]; then
|
|
|
|
platform='Linux'
|
|
|
|
elif [[ "$unamestr" == 'Darwin' ]]; then
|
|
|
|
platform='Mac'
|
|
|
|
fi
|
|
|
|
echo "platform: $platform"
|
|
|
|
|
2021-10-23 11:05:18 +00:00
|
|
|
# define chaos testing object
|
2021-10-25 12:34:23 +00:00
|
|
|
release=${1:-"milvus-chaos"}
|
2021-11-02 12:51:48 +00:00
|
|
|
ns=${2:-"chaos-testing"}
|
|
|
|
|
|
|
|
# switch namespace
|
|
|
|
kubectl config set-context --current --namespace=${ns}
|
2021-11-05 01:09:39 +00:00
|
|
|
pod="standalone"
|
|
|
|
chaos_type="pod_kill"
|
2021-11-05 08:30:59 +00:00
|
|
|
chaos_task="data-consist-test" # chaos-test or data-consist-test
|
2021-10-22 11:55:14 +00:00
|
|
|
release="milvus-chaos"
|
|
|
|
ns="chaos-testing"
|
|
|
|
|
2021-10-23 11:05:18 +00:00
|
|
|
# install milvus cluster for chaos testing
|
2021-10-22 11:55:14 +00:00
|
|
|
pushd ./scripts
|
|
|
|
echo "uninstall milvus if exist"
|
2021-11-02 12:51:48 +00:00
|
|
|
bash uninstall_milvus.sh ${release} ${ns}|| true
|
2021-10-22 11:55:14 +00:00
|
|
|
echo "install milvus"
|
2021-11-05 01:09:39 +00:00
|
|
|
if [ ${pod} != "standalone" ];
|
|
|
|
then
|
|
|
|
echo "insatll cluster"
|
|
|
|
bash install_milvus.sh ${release} ${ns}
|
|
|
|
fi
|
2021-11-01 09:29:59 +00:00
|
|
|
|
2021-11-05 01:09:39 +00:00
|
|
|
if [ ${pod} == "standalone" ];
|
|
|
|
then
|
|
|
|
echo "install standalone"
|
|
|
|
helm install --wait --timeout 360s ${release} milvus/milvus --set service.type=NodePort -f ../standalone-values.yaml -n=${ns}
|
|
|
|
fi
|
2021-11-01 09:29:59 +00:00
|
|
|
# if chaos_type is pod_failure, update replicas
|
|
|
|
if [ "$chaos_type" == "pod_failure" ];
|
|
|
|
then
|
|
|
|
declare -A pod_map=(["querynode"]="queryNode" ["indexnode"]="indexNode" ["datanode"]="dataNode" ["proxy"]="proxy")
|
|
|
|
helm upgrade ${release} milvus/milvus --set ${pod_map[${pod}]}.replicas=2 --reuse-values
|
|
|
|
fi
|
|
|
|
|
2021-10-22 11:55:14 +00:00
|
|
|
popd
|
|
|
|
|
2021-10-23 11:05:18 +00:00
|
|
|
# replace chaos object as defined
|
2021-10-22 11:55:14 +00:00
|
|
|
if [ "$platform" == "Mac" ];
|
|
|
|
then
|
|
|
|
sed -i "" "s/TESTS_CONFIG_LOCATION =.*/TESTS_CONFIG_LOCATION = \'chaos_objects\/${chaos_type}\/'/g" constants.py
|
2021-11-01 09:29:59 +00:00
|
|
|
sed -i "" "s/ALL_CHAOS_YAMLS =.*/ALL_CHAOS_YAMLS = \'chaos_${pod}_${chaos_type}.yaml\'/g" constants.py
|
2021-10-22 11:55:14 +00:00
|
|
|
else
|
|
|
|
sed -i "s/TESTS_CONFIG_LOCATION =.*/TESTS_CONFIG_LOCATION = \'chaos_objects\/${chaos_type}\/'/g" constants.py
|
2021-11-01 09:29:59 +00:00
|
|
|
sed -i "s/ALL_CHAOS_YAMLS =.*/ALL_CHAOS_YAMLS = \'chaos_${pod}_${chaos_type}.yaml\'/g" constants.py
|
2021-10-22 11:55:14 +00:00
|
|
|
fi
|
|
|
|
|
2021-10-23 11:05:18 +00:00
|
|
|
# run chaos testing
|
2021-10-22 11:55:14 +00:00
|
|
|
echo "start running testcase ${pod}"
|
|
|
|
host=$(kubectl get svc/milvus-chaos -o jsonpath="{.spec.clusterIP}")
|
|
|
|
python scripts/hello_milvus.py --host "$host"
|
2021-11-05 08:30:59 +00:00
|
|
|
# chaos test
|
|
|
|
if [ "$chaos_task" == "chaos-test" ];
|
|
|
|
then
|
|
|
|
pytest -s -v test_chaos.py --host "$host" || echo "chaos test fail"
|
|
|
|
fi
|
|
|
|
# data consist test
|
|
|
|
if [ "$chaos_task" == "data-consist-test" ];
|
|
|
|
then
|
|
|
|
pytest -s -v test_chaos_data_consist.py --host "$host" || echo "chaos test fail"
|
|
|
|
fi
|
2021-10-22 11:55:14 +00:00
|
|
|
sleep 30s
|
|
|
|
echo "start running e2e test"
|
2021-11-05 01:17:44 +00:00
|
|
|
python scripts/hello_milvus.py --host "$host" || echo "e2e test fail"
|
|
|
|
|
|
|
|
# save logs
|
|
|
|
bash ../../scripts/export_log_k8s.sh ${ns} ${release} k8s_log/${pod}
|