Compare commits

..

1 Commits

Author SHA1 Message Date
9cd3db68b5 Print vitastor-cli help for ls-osds and user-modify aliases
vitastor-cli accepts ls-osds and user-modify, but --help does not list
them, so "vitastor-cli --help ls-osds" printed "Unknown command". Add
them to the help and to the docs, which also lacked the pgs alias in the
Russian version. Test that --help knows every name the CLI accepts.
2026-10-25 16:10:29 +03:00
7 changed files with 24 additions and 58 deletions

View File

@@ -355,7 +355,7 @@ host stump
## ls-osd
`vitastor-cli osds|ls-osd|osd-ls [-l|--long]`
`vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]`
Show current OSDs as list, optionally with I/O statistics if -l is specified.
@@ -508,7 +508,7 @@ the Vitastor authorization model.
## modify-user
`vitastor-cli modify-user --groups <group1,group2,...> <username>`
`vitastor-cli modify-user|user-modify --groups <group1,group2,...> <username>`
Create or update a user with the given name (matching TLS certificate CN).

View File

@@ -373,7 +373,7 @@ host stump
## ls-osd
`vitastor-cli osds|ls-osd|osd-ls [-l|--long]`
`vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]`
Показать список OSD, со статистикой ввода-вывода, если установлено -l.
@@ -403,7 +403,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
## pg-list
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]`
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]`
Вывести список PG с состояними, удовлетворяющими любому из переданных фильтров (^ или !
в начале фильтра означает отрицание). Опции:
@@ -527,7 +527,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
## modify-user
`vitastor-cli modify-user --groups <group1,group2,...> <username>`
`vitastor-cli modify-user|user-modify --groups <group1,group2,...> <username>`
Создать или изменить пользователя с указанным именем (совпадающим с CN TLS-сертификата).

View File

@@ -179,7 +179,7 @@ static const char* help_text =
"vitastor-cli osd-tree [-l|--long]\n"
" Show current OSD tree, optionally with I/O statistics if -l is specified.\n"
"\n"
"vitastor-cli osds|ls-osd|osd-ls [-l|--long]\n"
"vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]\n"
" Show current OSDs as list, optionally with I/O statistics if -l is specified.\n"
"\n"
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
@@ -253,7 +253,7 @@ static const char* help_text =
"vitastor-cli ls-users|user-ls|ls-user|list-users [<name> ...]\n"
" List users (only with specified names if passed).\n"
"\n"
"vitastor-cli modify-user --type <type> --groups group1,group2,... <username>\n"
"vitastor-cli modify-user|user-modify --type <type> --groups group1,group2,... <username>\n"
" Create or update user permissions. User names match CN of their certificates.\n"
" --type TYPE Set user type: client or admin. Default is client.\n"
" --groups GROUPS Set user's groups.\n"

View File

@@ -251,7 +251,7 @@ resume_1:
{ "title", "MISPLACED" },
});
cols.push_back(json11::Json::object{
{ "key", "fmt_degraded" },
{ "key", "fmt_misplaced" },
{ "title", "DEGRADED" },
});
cols.push_back(json11::Json::object{
@@ -273,8 +273,6 @@ resume_1:
load_pg_stats();
if (parent->waiting > 0)
return;
if (state == 100)
return;
format_pgs();
state = 100;
}

View File

@@ -61,7 +61,6 @@ OLD=1 SCHEME=ec ./test_snapshot.sh
OLD=1 ./test_move_reappear.sh
./test_degraded.sh
./test_pg_ls.sh
./test_rm.sh
@@ -96,6 +95,8 @@ OLD=1 SCHEME=ec IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh
./test_dd.sh
./test_cli_help.sh
./test_root_node.sh
./test_switch_primary.sh

14
tests/test_cli_help.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash -ex
# Test that vitastor-cli --help knows every command name and alias the CLI accepts
. `dirname $0`/common.sh
for cmd in $(grep -o 'cmd\[0\] == "[^"]*"' src/cmd/cli.cpp | sed 's/.*== "//; s/"$//'); do
build/src/cmd/vitastor-cli --help $cmd > ./testdata/help.txt 2>&1 || true
if grep -q '^Unknown command' ./testdata/help.txt; then
format_error "vitastor-cli --help $cmd does not know the command"
fi
done
format_green OK

View File

@@ -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