Skip to content

Commit 4067802

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 2ec8622 commit 4067802

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

tests/ha/4gws_create_delete.sh

Lines changed: 53 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,51 @@ 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 at least half of the namespaces if they
135+
# were equally divided among the four ANA groups.
136+
if [ "$(count_namespaces_in_anagrp "$subs" 0 1)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
137+
"$(count_namespaces_in_anagrp "$subs" 0 2)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
138+
"$(count_namespaces_in_anagrp "$subs" 0 3)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
139+
"$(count_namespaces_in_anagrp "$subs" 0 4)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
140+
"$(count_namespaces_in_anagrp "$subs" 1 1)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
141+
"$(count_namespaces_in_anagrp "$subs" 1 2)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
142+
"$(count_namespaces_in_anagrp "$subs" 1 3)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP -o \
143+
"$(count_namespaces_in_anagrp "$subs" 1 4)" -ge $MIN_NUM_NAMESPACES_IN_ANA_GROUP ]; then
144+
145+
echo "Not ready $i $GW_NAME $GW_IP"
146+
sleep 5
147+
continue
148+
fi
149+
echo "✅ verify_num_namespaces ready $i $GW_NAME $GW_IP"
150+
break
151+
done
152+
153+
# Check if the inner loop completed without breaking
154+
if [ $i -eq 10 ]; then
155+
echo "verify_num_namespaces ‼️ Timeout reached for $GW_NAME $GW_IP"
156+
exit 1
157+
fi
158+
done
159+
}
160+
112161
validate_all_active() {
113162
for s in $(seq $NUM_SUBSYSTEMS); do
114163
all_ana_states=$(for g in $(seq $NUM_GATEWAYS); do
@@ -123,6 +172,9 @@ validate_all_active() {
123172
exit 1
124173
fi
125174
done
175+
176+
# ensure namespaces are evenly distributed across ANA groups
177+
verify_num_namespaces
126178
}
127179

128180

@@ -132,6 +184,7 @@ validate_all_active() {
132184

133185
NUM_SUBSYSTEMS=2
134186
NUM_GATEWAYS=4
187+
MIN_NUM_NAMESPACES_IN_ANA_GROUP=4
135188
FAILING_GATEWAYS=2
136189
NUM_OPTIMIZED_FAILOVER=2
137190
NUM_OPTIMIZED_REBALANCE=1

0 commit comments

Comments
 (0)