|
|
|
|
@@ -1,47 +0,0 @@
|
|
|
|
|
#!/bin/bash -ex
|
|
|
|
|
|
|
|
|
|
# Test vitastor-cli ls-pgs on degraded PGs
|
|
|
|
|
|
|
|
|
|
PG_COUNT=4
|
|
|
|
|
PG_SIZE=3
|
|
|
|
|
PG_MINSIZE=2
|
|
|
|
|
# Keep degraded objects until the checks are done
|
|
|
|
|
GLOBAL_CONFIG=',"no_recovery":true'
|
|
|
|
|
. `dirname $0`/run_3osds.sh
|
|
|
|
|
|
|
|
|
|
$VITASTOR_CLI create -s 32M testimg
|
|
|
|
|
|
|
|
|
|
# Data written while OSD 3 is down is degraded when it comes back
|
|
|
|
|
kill -9 $OSD3_PID
|
|
|
|
|
$ETCDCTL del /vitastor/osd/state/3
|
|
|
|
|
wait_condition 60 "$ETCDCTL get --prefix /vitastor/pg/state/ --print-value-only | jq -s -e '[ .[] | select(.state | index(\"degraded\")) ] | length == $PG_COUNT'" "PG peering without OSD 3"
|
|
|
|
|
$VITASTOR_CLI dd if=/dev/urandom oimg=testimg bs=1M count=32
|
|
|
|
|
start_osd 3
|
|
|
|
|
wait_condition 60 "$ETCDCTL get --prefix /vitastor/pgstats/ --print-value-only | jq -s -e '[ .[] | select(.degraded_count > 0) ] | length == $PG_COUNT'" "PG degradation"
|
|
|
|
|
|
|
|
|
|
$VITASTOR_CLI ls-pgs
|
|
|
|
|
|
|
|
|
|
# NUM and DEGRADED of every PG from the table, and degraded_count from JSON
|
|
|
|
|
$VITASTOR_CLI ls-pgs | awk 'NR == 1 { n = index($0, "NUM"); d = index($0, "DEGRADED"); e = index($0, "INCOMPLETE") }
|
|
|
|
|
NR > 1 { num = substr($0, n); sub(/ .*/, "", num); deg = substr($0, d, e-d); sub(/ +$/, "", deg); print num " " deg }' > ./testdata/pg_ls.txt
|
|
|
|
|
$VITASTOR_CLI ls-pgs --json | jq -r '.[] | "\(.pg_num) \(.degraded_count // 0)"' > ./testdata/pg_ls_json.txt
|
|
|
|
|
|
|
|
|
|
if [[ $(wc -l < ./testdata/pg_ls.txt) != $PG_COUNT ]]; then
|
|
|
|
|
format_error "ls-pgs should list $PG_COUNT PGs"
|
|
|
|
|
fi
|
|
|
|
|
while read num count; do
|
|
|
|
|
shown=$(awk '$1 == '$num' { $1 = ""; sub(/^ /, ""); print }' ./testdata/pg_ls.txt)
|
|
|
|
|
if [[ -z "$shown" || $count -gt 0 && "$shown" = "0 B" || $count -eq 0 && "$shown" != "0 B" ]]; then
|
|
|
|
|
format_error "ls-pgs shows DEGRADED=$shown for PG $num with $count degraded objects"
|
|
|
|
|
fi
|
|
|
|
|
done < ./testdata/pg_ls_json.txt
|
|
|
|
|
|
|
|
|
|
# An unknown pool is an error, not an empty table
|
|
|
|
|
if out=$($VITASTOR_CLI ls-pgs --pool nosuchpool 2>&1); then
|
|
|
|
|
format_error "ls-pgs should fail for an unknown pool"
|
|
|
|
|
fi
|
|
|
|
|
if [[ "$out" != "Pool nosuchpool not found" ]]; then
|
|
|
|
|
format_error "ls-pgs prints '$out' instead of the unknown pool error"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
format_green OK
|