|
3 | 3 |
|
4 | 4 | GATEWAYS=$1 # exmaple "nvmeof.a,nvmeof.b" |
5 | 5 | DELAY="${SCALING_DELAYS:-50}" |
| 6 | +POOL="${RBD_POOL:-mypool}" |
| 7 | +GROUP="${NVMEOF_GROUP:-mygroup0}" |
| 8 | +source /etc/ceph/nvmeof.env |
6 | 9 |
|
7 | 10 | if [ -z "$GATEWAYS" ]; then |
8 | 11 | echo "At least one gateway needs to be defined for scalability test" |
9 | 12 | exit 1 |
10 | 13 | fi |
11 | 14 |
|
12 | | -pip3 install yq |
13 | | - |
14 | 15 | status_checks() { |
15 | | - ceph nvme-gw show mypool '' |
16 | | - ceph orch ls |
17 | | - ceph orch ps |
18 | | - ceph -s |
| 16 | + expected_count=$1 |
| 17 | + |
| 18 | + output=$(ceph nvme-gw show $POOL $GROUP) |
| 19 | + nvme_show=$(echo $output | grep -o '"AVAILABLE"' | wc -l) |
| 20 | + if [ "$nvme_show" -ne "$expected_count" ]; then |
| 21 | + return 1 |
| 22 | + fi |
| 23 | + |
| 24 | + orch_ls=$(ceph orch ls) |
| 25 | + if ! echo "$orch_ls" | grep -q "$expected_count/$expected_count"; then |
| 26 | + return 1 |
| 27 | + fi |
| 28 | + |
| 29 | + output=$(ceph orch ps --service-name nvmeof.$POOL.$GROUP) |
| 30 | + orch_ps=$(echo $output | grep -o 'running' | wc -l) |
| 31 | + if [ "$orch_ps" -ne "$expected_count" ]; then |
| 32 | + return 1 |
| 33 | + fi |
| 34 | + |
| 35 | + ceph_status=$(ceph -s) |
| 36 | + if ! echo "$ceph_status" | grep -q "HEALTH_OK"; then |
| 37 | + return 1 |
| 38 | + fi |
19 | 39 | } |
20 | 40 |
|
| 41 | +total_gateways_count=$(( $(echo "$NVMEOF_GATEWAY_IP_ADDRESSES" | tr -cd ',' | wc -c) + 1 )) |
| 42 | +scaled_down_gateways_count=$(( total_gateways_count - $(echo "$GATEWAYS" | tr -cd ',' | wc -c) - 1 )) |
| 43 | + |
21 | 44 |
|
22 | 45 | echo "[nvmeof.scale] Setting up config to remove gateways ${GATEWAYS}" |
| 46 | +ceph orch ls --service-name nvmeof.$POOL.$GROUP --export > /tmp/nvmeof-gw.yaml |
23 | 47 | ceph orch ls nvmeof --export > /tmp/nvmeof-gw.yaml |
24 | 48 | cat /tmp/nvmeof-gw.yaml |
25 | | -yq "del(.placement.hosts[] | select(. | test(\".*($(echo $GATEWAYS | sed 's/,/|/g'))\")))" /tmp/nvmeof-gw.yaml > /tmp/nvmeof-gw-new.yaml |
| 49 | + |
| 50 | +pattern=$(echo $GATEWAYS | sed 's/,/\\|/g') |
| 51 | +sed "/$pattern/d" /tmp/nvmeof-gw.yaml > /tmp/nvmeof-gw-new.yaml |
26 | 52 | cat /tmp/nvmeof-gw-new.yaml |
27 | 53 |
|
28 | 54 | echo "[nvmeof.scale] Starting scale testing by removing ${GATEWAYS}" |
29 | | -status_checks |
30 | | -ceph orch rm nvmeof.mypool && sleep 20 # temp workaround |
| 55 | +status_checks $total_gateways_count |
31 | 56 | ceph orch apply -i /tmp/nvmeof-gw-new.yaml # downscale |
| 57 | +ceph orch redeploy nvmeof.$POOL.$GROUP |
32 | 58 | sleep $DELAY |
33 | | -status_checks |
34 | | -ceph orch rm nvmeof.mypool && sleep 20 # temp workaround |
| 59 | +status_checks $scaled_down_gateways_count |
| 60 | +echo "[nvmeof.scale] Downscale complete - removed gateways (${GATEWAYS}); now scaling back up" |
35 | 61 | ceph orch apply -i /tmp/nvmeof-gw.yaml #upscale |
| 62 | +ceph orch redeploy nvmeof.$POOL.$GROUP |
36 | 63 | sleep $DELAY |
37 | | -status_checks |
| 64 | +status_checks $total_gateways_count |
38 | 65 |
|
39 | 66 | echo "[nvmeof.scale] Scale testing passed for ${GATEWAYS}" |
0 commit comments