Skip to content

Commit 454ba9e

Browse files
author
Alexander Indenbaum
committed
tests/ha/4gws_create_delete.sh: add verify number of namespaces per ana group in all active step
Signed-off-by: Alexander Indenbaum <aindenba@redhat.com>
1 parent e2bc8d8 commit 454ba9e

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/ha/4gws_create_delete.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ gw_name() {
5858
docker ps --format '{{.ID}}\t{{.Names}}' --filter status=running --filter status=exited | awk '$2 ~ /nvmeof/ && $2 ~ /'$i'/ {print $1}'
5959
}
6060

61+
gw_ip() {
62+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$(gw_name $1)"
63+
}
64+
6165
# Function to access numbers by index
6266
access_number_by_index() {
6367
numbers=$1
@@ -109,6 +113,50 @@ choose_n_m() {
109113
done
110114
}
111115

116+
count_namespaces_in_anagrp() {
117+
json="$1" # subsystems json data
118+
subsystem_idx="$2" # subsystem index (e.g., 0, 1)
119+
ana_group="$3" # ana group id
120+
121+
echo "$json" | jq ".subsystems[$subsystem_idx].namespaces | map(select(.anagrpid == $ana_group)) | length"
122+
}
123+
124+
verify_num_namespaces() {
125+
# verify initial distribution of namespaces
126+
for g in $(seq $NUM_GATEWAYS); do
127+
for i in $(seq 10); do
128+
echo "verify_num_namespaces $i $GW_NAME $GW_IP"
129+
GW_NAME=$(gw_name $g)
130+
GW_IP=$(gw_ip $g)
131+
subs=$(docker compose run --rm nvmeof-cli --server-address $GW_IP --server-port 5500 get_subsystems 2>&1 | sed 's/Get subsystems://')
132+
133+
# ensure namespaces are evenly distributed across ANA groups.
134+
# each subsystem should have 32 namespaces divided equally among four ANA groups.
135+
if [ "$(count_namespaces_in_anagrp "$subs" 0 1)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
136+
"$(count_namespaces_in_anagrp "$subs" 0 2)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
137+
"$(count_namespaces_in_anagrp "$subs" 0 3)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
138+
"$(count_namespaces_in_anagrp "$subs" 0 4)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
139+
"$(count_namespaces_in_anagrp "$subs" 1 1)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
140+
"$(count_namespaces_in_anagrp "$subs" 1 2)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
141+
"$(count_namespaces_in_anagrp "$subs" 1 3)" -ne $NUM_NAMESPACES_IN_ANA_GROUP -o \
142+
"$(count_namespaces_in_anagrp "$subs" 1 4)" -ne $NUM_NAMESPACES_IN_ANA_GROUP ]; then
143+
144+
echo "Not ready $i $GW_NAME $GW_IP"
145+
sleep 5
146+
continue
147+
fi
148+
echo "✅ verify_num_namespaces ready $i $GW_NAME $GW_IP"
149+
break
150+
done
151+
152+
# Check if the inner loop completed without breaking
153+
if [ $i -eq 10 ]; then
154+
echo "verify_num_namespaces ‼️ Timeout reached for $GW_NAME $GW_IP"
155+
exit 1
156+
fi
157+
done
158+
}
159+
112160
validate_all_active() {
113161
for s in $(seq $NUM_SUBSYSTEMS); do
114162
all_ana_states=$(for g in $(seq $NUM_GATEWAYS); do
@@ -123,6 +171,9 @@ validate_all_active() {
123171
exit 1
124172
fi
125173
done
174+
175+
# ensure namespaces are evenly distributed across ANA groups
176+
verify_num_namespaces
126177
}
127178

128179

@@ -132,6 +183,7 @@ validate_all_active() {
132183

133184
NUM_SUBSYSTEMS=2
134185
NUM_GATEWAYS=4
186+
NUM_NAMESPACES_IN_ANA_GROUP=8
135187
FAILING_GATEWAYS=2
136188
NUM_OPTIMIZED_FAILOVER=2
137189
NUM_OPTIMIZED_REBALANCE=1

0 commit comments

Comments
 (0)