Skip to content

Commit dca6f83

Browse files
authored
Merge pull request #871 from leonidc/test_no_subsystems
add github test for usecase when gw deletes last subsystem
2 parents 98e2a47 + 0d9a5c0 commit dca6f83

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

.github/workflows/build-container.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ jobs:
737737
strategy:
738738
fail-fast: false
739739
matrix:
740-
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"]
740+
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"]
741741
runs-on: ubuntu-latest
742742
env:
743743
HUGEPAGES: 1024 # 4 spdk instances

tests/ha/no_subsystems.sh

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/bash
2+
set -xe
3+
# See
4+
# - https://github.com/spdk/spdk/blob/master/doc/jsonrpc.md
5+
# - https://spdk.io/doc/nvmf_multipath_howto.html
6+
7+
GW1_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /1/ {print $1}')
8+
GW2_NAME=$(docker ps --format '{{.ID}}\t{{.Names}}' | awk '$2 ~ /nvmeof/ && $2 ~ /2/ {print $1}')
9+
10+
ip="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW1_NAME")"
11+
ip2="$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$GW2_NAME")"
12+
13+
NQN="nqn.2016-06.io.spdk:cnode1"
14+
15+
verify_gw_exists_and_no_subs()
16+
{
17+
IP=$1
18+
subs=$(docker compose run -T --rm nvmeof-cli --server-address $IP --server-port 5500 --output stdio --format json get_subsystems)
19+
echo "show subsystems after del : $subs"
20+
if echo "$subs" | grep -q '"subsystems": \[\]'; then
21+
echo "The string contains 'subsystems:[]' on GW ip $IP"
22+
else
23+
echo "The string does not contain 'subsystems:[]'on GW ip $IP "
24+
exit 1
25+
fi
26+
}
27+
28+
29+
echo "ℹ️ ℹ️ Start test: Delete the last subsystem:"
30+
31+
for i in $(seq 2); do
32+
33+
docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 subsystem del -n $NQN --force
34+
sleep 2
35+
verify_gw_exists_and_no_subs $ip
36+
verify_gw_exists_and_no_subs $ip2
37+
38+
echo "ℹ️ ℹ️ next : Create subsystem:"
39+
40+
docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 subsystem add -n $NQN
41+
docker compose run --rm nvmeof-cli --server-address $ip --server-port 5500 listener add --subsystem $NQN --host-name $GW1_NAME --traddr $ip --trsvcid 4420
42+
docker compose run --rm nvmeof-cli --server-address $ip2 --server-port 5500 listener add --subsystem $NQN --host-name $GW2_NAME --traddr $ip2 --trsvcid 4420
43+
44+
sleep 5
45+
subs=$(docker compose run -T --rm nvmeof-cli --server-address $ip --server-port 5500 --output stdio --format json get_subsystems)
46+
47+
echo "subsystems $subs"
48+
#test that ana group is Active
49+
json=$(docker compose exec -T ceph ceph nvme-gw show rbd '')
50+
51+
states=$(echo "$json" | jq -r '.["Created Gateways:"][] | ."ana states"')
52+
echo "$states"
53+
54+
if echo "$states" | grep -q '1: ACTIVE'; then
55+
echo "state found ACTIVE in group 1"
56+
else
57+
echo "ACTIVE state not found for group 1"
58+
exit 1
59+
fi
60+
if echo "$states" | grep -q '2: ACTIVE'; then
61+
echo "state found ACTIVE in group 2"
62+
else
63+
echo "ACTIVE state not found for group 2"
64+
exit 1
65+
fi
66+
67+
done
68+
echo "ℹ️ ℹ️ test passed"

0 commit comments

Comments
 (0)