Skip to content

Commit

Permalink
wait gateway in ha tests
Browse files Browse the repository at this point in the history
- 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 <[email protected]>
  • Loading branch information
Alexander Indenbaum authored and baum committed Oct 29, 2024
1 parent 8672db1 commit 00b63ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 7 additions & 4 deletions tests/ha/main_exit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
11 changes: 6 additions & 5 deletions tests/ha/wait_gateways.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand All @@ -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

0 comments on commit 00b63ed

Please sign in to comment.