Skip to content

Commit

Permalink
add github test for usecase when gw deletes last subsystem
Browse files Browse the repository at this point in the history
Signed-off-by: Leonid Chernin <leonidc@il.ibm.com>
  • Loading branch information
Leonid Chernin committed Sep 19, 2024
1 parent 98e2a47 commit 3c48713
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
75 changes: 75 additions & 0 deletions tests/ha/no_subsystems.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/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)

#####docker compose run --rm nvmeof-cli --server-address $ip2 --server-port 5500 get_listeners --subsystem $NQN

echo "subsystems $subs"
#test that ana group is Active TODO - get listener grep Optimised or call directly nvme-gw show
json=$(docker compose exec -T ceph ceph nvme-gw show rbd '')

#echo ℹ️ ℹ️ " gw show $json "

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

#echo ℹ️ ℹ️ " gw show $gw_show "

done
echo "ℹ️ ℹ️ test passed"

0 comments on commit 3c48713

Please sign in to comment.