From e5335450a4a9333215bae8ed03442d1ac258ec63 Mon Sep 17 00:00:00 2001 From: Anis Eleuch Date: Wed, 19 Jun 2024 17:00:38 +0100 Subject: [PATCH] test: Healing test to avoid infinite waiting for servers to be up (#19954) tests: Healing test to avoid infinite waiting for servers to be up Quit after 15 minutes and print server logs instead --- .../verify-healing-empty-erasure-set.sh | 47 +++++++----------- buildscripts/verify-healing.sh | 48 +++++++------------ 2 files changed, 33 insertions(+), 62 deletions(-) diff --git a/buildscripts/verify-healing-empty-erasure-set.sh b/buildscripts/verify-healing-empty-erasure-set.sh index 3a9217bae..035fb7cfd 100755 --- a/buildscripts/verify-healing-empty-erasure-set.sh +++ b/buildscripts/verify-healing-empty-erasure-set.sh @@ -39,7 +39,7 @@ function start_minio_3_node() { export MC_HOST_myminio="http://minio:minio123@127.0.0.1:$((start_port + 1))" - /tmp/mc ready myminio + timeout 15m /tmp/mc ready myminio || fail # Wait for all drives to be online and formatted while [ $(/tmp/mc admin info --json myminio | jq '.info.servers[].drives[].state | select(. != "ok")' | wc -l) -gt 0 ]; do sleep 1; done @@ -62,48 +62,23 @@ function start_minio_3_node() { fi # Failure - for i in $(seq 1 3); do - echo "server$i log:" - cat "${WORK_DIR}/dist-minio-server$i.log" - done - pkill -9 minio - echo "FAILED" - purge "$WORK_DIR" - exit 1 + fail done if ! ps -p $pid1 1>&2 >/dev/null; then - echo "server1 log:" - cat "${WORK_DIR}/dist-minio-server1.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio-server-1 is not running." && fail fi if ! ps -p $pid2 1>&2 >/dev/null; then - echo "server2 log:" - cat "${WORK_DIR}/dist-minio-server2.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio-server-2 is not running." && fail fi if ! ps -p $pid3 1>&2 >/dev/null; then - echo "server3 log:" - cat "${WORK_DIR}/dist-minio-server3.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio-server-3 is not running." && fail fi if ! pkill minio; then - for i in $(seq 1 3); do - echo "server$i log:" - cat "${WORK_DIR}/dist-minio-server$i.log" - done - echo "FAILED" - purge "$WORK_DIR" - exit 1 + fail fi sleep 1 @@ -115,6 +90,16 @@ function start_minio_3_node() { fi } +function fail() { + for i in $(seq 1 3); do + echo "server$i log:" + cat "${WORK_DIR}/dist-minio-server$i.log" + done + echo "FAILED" + purge "$WORK_DIR" + exit 1 +} + function check_online() { if ! grep -q 'Status:' ${WORK_DIR}/dist-minio-*.log; then echo "1" diff --git a/buildscripts/verify-healing.sh b/buildscripts/verify-healing.sh index ba1cd21c8..aa26b2dd7 100755 --- a/buildscripts/verify-healing.sh +++ b/buildscripts/verify-healing.sh @@ -47,43 +47,25 @@ function start_minio_3_node() { disown $pid3 export MC_HOST_myminio="http://minio:minio123@127.0.0.1:$((start_port + 1))" - /tmp/mc ready myminio + timeout 15m /tmp/mc ready myminio || fail [ ${first_time} -eq 0 ] && upload_objects [ ${first_time} -ne 0 ] && sleep 120 if ! ps -p $pid1 1>&2 >/dev/null; then - echo "server1 log:" - cat "${WORK_DIR}/dist-minio-server1.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio server 1 is not running" && fail fi if ! ps -p $pid2 1>&2 >/dev/null; then - echo "server2 log:" - cat "${WORK_DIR}/dist-minio-server2.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio server 2 is not running" && fail fi if ! ps -p $pid3 1>&2 >/dev/null; then - echo "server3 log:" - cat "${WORK_DIR}/dist-minio-server3.log" - echo "FAILED" - purge "$WORK_DIR" - exit 1 + echo "minio server 3 is not running" && fail fi if ! pkill minio; then - for i in $(seq 1 3); do - echo "server$i log:" - cat "${WORK_DIR}/dist-minio-server$i.log" - done - echo "FAILED" - purge "$WORK_DIR" - exit 1 + fail fi sleep 1 @@ -118,6 +100,17 @@ function purge() { rm -rf "$1" } +function fail() { + for i in $(seq 1 3); do + echo "server$i log:" + cat "${WORK_DIR}/dist-minio-server$i.log" + done + pkill -9 minio + echo "FAILED" + purge "$WORK_DIR" + exit 1 +} + function __init__() { echo "Initializing environment" mkdir -p "$WORK_DIR" @@ -155,14 +148,7 @@ function perform_test() { check_heal ${1} rv=$? if [ "$rv" == "1" ]; then - for i in $(seq 1 3); do - echo "server$i log:" - cat "${WORK_DIR}/dist-minio-server$i.log" - done - pkill -9 minio - echo "FAILED" - purge "$WORK_DIR" - exit 1 + fail fi }