From 00b63edfb2dc6ffa3a41203213e913190305434b Mon Sep 17 00:00:00 2001 From: Alexander Indenbaum Date: Mon, 28 Oct 2024 12:46:51 +0000 Subject: [PATCH] wait gateway in ha tests - wait for gateway name to appear - depend on get_subsystems cli exit code example error: https://github.com/ceph/ceph-nvmeof/actions/runs/11553143252/job/32154126711?pr=918 Signed-off-by: Alexander Indenbaum --- tests/ha/main_exit.sh | 11 +++++++---- tests/ha/wait_gateways.sh | 11 ++++++----- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/ha/main_exit.sh b/tests/ha/main_exit.sh index 3502f861..e56d77af 100755 --- a/tests/ha/main_exit.sh +++ b/tests/ha/main_exit.sh @@ -26,11 +26,16 @@ background_task() { docker compose top echo ℹ️ Send nvme-gw create for all gateways + GW_NAME='' GW_GROUP='' i=1 # a single gw index - GW_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | grep -v discovery | awk '$2 ~ /nvmeof/ && $2 ~ /'$i'/ {print $1}') + while [ ! -n "$GW_NAME" ]; do + sleep 1 + GW_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | grep -v discovery | awk '$2 ~ /nvmeof/ && $2 ~ /'$i'/ {print $1}') + done echo 📫 nvme-gw create gateway: \'$GW_NAME\' pool: \'$POOL\', group: \'$GW_GROUP\' docker compose exec -T ceph ceph nvme-gw create $GW_NAME $POOL "$GW_GROUP" + docker compose exec -T ceph ceph nvme-gw show $POOL "$GW_GROUP" echo ℹ️ Wait for gateway to be ready while true; do @@ -43,12 +48,10 @@ background_task() { continue fi GW_IP="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW_NAME")" - if docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems 2>&1 | grep -i failed; then + if ! docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems; then echo "Container $i $GW_NAME $GW_IP no subsystems. Waiting..." continue fi - echo "Container $i $GW_NAME $GW_IP subsystems:" - docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems break done diff --git a/tests/ha/wait_gateways.sh b/tests/ha/wait_gateways.sh index 6edc2f6c..a34a33c5 100755 --- a/tests/ha/wait_gateways.sh +++ b/tests/ha/wait_gateways.sh @@ -15,8 +15,11 @@ if [ $# -ge 1 ]; then fi for i in $(seq $SCALE); do while true; do - sleep 1 # Adjust the sleep duration as needed - GW_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /'$i'/ {print $1}') + GW_NAME='' + while [ ! -n "$GW_NAME" ]; do + sleep 1 # Adjust the sleep duration as needed + GW_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /'$i'/ {print $1}') + done container_status=$(docker inspect -f '{{.State.Status}}' "$GW_NAME") if [ "$container_status" = "running" ]; then echo "Container $i $GW_NAME is now running." @@ -25,12 +28,10 @@ for i in $(seq $SCALE); do continue fi GW_IP="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW_NAME")" - if docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems 2>&1 | grep -i failed; then + if ! docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems; then echo "Container $i $GW_NAME $GW_IP no subsystems. Waiting..." continue fi - echo "Container $i $GW_NAME $GW_IP subsystems:" - docker compose run --rm nvmeof-cli $CLI_TLS_ARGS --server-address $GW_IP --server-port 5500 get_subsystems break; done done