From 0d9a5c05be7300ed07f3bca5cb3c6c372c58c59e Mon Sep 17 00:00:00 2001 From: Leonid Chernin Date: Thu, 19 Sep 2024 07:10:24 +0000 Subject: [PATCH] add github test for usecase when gw deletes last subsystem Signed-off-by: Leonid Chernin --- .github/workflows/build-container.yml | 2 +- tests/ha/no_subsystems.sh | 68 +++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 tests/ha/no_subsystems.sh diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index 76cde126..b43ed9bc 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -737,7 +737,7 @@ jobs: strategy: fail-fast: false matrix: - test: ["sanity", "ns_lb_change", "state_transitions", "state_transitions_both_gws", "state_transitions_loop", "state_transitions_rand_loop", "late_registration", "late_registration_loop", "4gws", "4gws_loop", "4gws_create_delete", "4gws_create_delete_loop", "namespaces", "namespaces_loop", "mtls", "notify", "ceph_status"] + test: ["sanity", "ns_lb_change", "no_subsystems", "state_transitions", "state_transitions_both_gws", "state_transitions_loop", "state_transitions_rand_loop", "late_registration", "late_registration_loop", "4gws", "4gws_loop", "4gws_create_delete", "4gws_create_delete_loop", "namespaces", "namespaces_loop", "mtls", "notify", "ceph_status"] runs-on: ubuntu-latest env: HUGEPAGES: 1024 # 4 spdk instances diff --git a/tests/ha/no_subsystems.sh b/tests/ha/no_subsystems.sh new file mode 100755 index 00000000..11c2ed35 --- /dev/null +++ b/tests/ha/no_subsystems.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -xe +# See +# - https://github.com/spdk/spdk/blob/master/doc/jsonrpc.md +# - https://spdk.io/doc/nvmf_multipath_howto.html + +GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}') +GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}') + +ip="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")" +ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")" + +NQN="nqn.2016-06.io.spdk:cnode1" + + verify_gw_exists_and_no_subs() + { + IP=$1 + subs=$(docker compose run -T --rm nvmeof-cli --server-address $IP --server-port 5500 --output stdio --format json get_subsystems) + echo "show subsystems after del : $subs" + if echo "$subs" | grep -q '"subsystems": \[\]'; then + echo "The string contains 'subsystems:[]' on GW ip $IP" + else + echo "The string does not contain 'subsystems:[]'on GW ip $IP " + exit 1 + fi + } + + + echo "ℹ️ ℹ️ Start test: Delete the last subsystem:" + + for i in $(seq 2); do + + docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 subsystem del -n $NQN --force + sleep 2 + verify_gw_exists_and_no_subs $ip + verify_gw_exists_and_no_subs $ip2 + + echo "ℹ️ ℹ️ next : Create subsystem:" + + docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 subsystem add -n $NQN + docker compose run --rm nvmeof-cli --server-address $ip --server-port 5500 listener add --subsystem $NQN --host-name $GW1_NAME --traddr $ip --trsvcid 4420 + docker compose run --rm nvmeof-cli --server-address $ip2 --server-port 5500 listener add --subsystem $NQN --host-name $GW2_NAME --traddr $ip2 --trsvcid 4420 + + sleep 5 + subs=$(docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 --output stdio --format json get_subsystems) + + echo "subsystems $subs" + #test that ana group is Active + json=$(docker compose exec -T ceph ceph nvme-gw show rbd '') + + states=$(echo "$json" | jq -r '.["Created Gateways:"][] | ."ana states"') + echo "$states" + + if echo "$states" | grep -q '1: ACTIVE'; then + echo "state found ACTIVE in group 1" + else + echo "ACTIVE state not found for group 1" + exit 1 + fi + if echo "$states" | grep -q '2: ACTIVE'; then + echo "state found ACTIVE in group 2" + else + echo "ACTIVE state not found for group 2" + exit 1 + fi + + done + echo "ℹ️ ℹ️ test passed"