monitoring: WARN badge yellow, red only for errors
This commit is contained in:
parent
4b19a31a34
commit
db90ddcce5
1 changed files with 120 additions and 12 deletions
|
|
@ -376,12 +376,13 @@ else
|
||||||
B=$'\e[1m' # bold section
|
B=$'\e[1m' # bold section
|
||||||
N=$'\e[0m' # reset
|
N=$'\e[0m' # reset
|
||||||
# Badge fill: bright text on solid background
|
# Badge fill: bright text on solid background
|
||||||
BG_OK=$'\e[1;30;42m' # black on green
|
# WARN = yellow only (never red). ERROR/BLOCKER use red/magenta.
|
||||||
BG_INFO=$'\e[1;30;46m' # black on cyan
|
BG_OK=$'\e[1;30;42m' # black on green
|
||||||
BG_WARN=$'\e[1;30;43m' # black on yellow
|
BG_INFO=$'\e[1;30;46m' # black on cyan
|
||||||
BG_ERR=$'\e[1;37;41m' # white on red
|
BG_WARN=$'\e[1;30;103m' # black on bright yellow (clearly not red)
|
||||||
BG_BLK=$'\e[1;37;45m' # white on magenta
|
BG_ERR=$'\e[1;37;41m' # white on red — errors only
|
||||||
BG_SEC=$'\e[1;37;44m' # white on blue (section)
|
BG_BLK=$'\e[1;37;45m' # white on magenta — blockers
|
||||||
|
BG_SEC=$'\e[1;37;44m' # white on blue (section)
|
||||||
BOX=1
|
BOX=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -393,14 +394,23 @@ BLOCKERS=() # human-readable payment/withdraw blockers
|
||||||
ERRORS=() # all ERROR lines (component scope)
|
ERRORS=() # all ERROR lines (component scope)
|
||||||
|
|
||||||
# Grouped test IDs: area.group-NN (e.g. www.exchange-01, e2e.pay-03)
|
# Grouped test IDs: area.group-NN (e.g. www.exchange-01, e2e.pay-03)
|
||||||
|
# plus global run number: #042 (monotonic for the whole ./taler-monitoring.sh run)
|
||||||
# set_area www # phase: www | e2e | inside | versions | …
|
# set_area www # phase: www | e2e | inside | versions | …
|
||||||
# set_group exchange # resets counter + prints group box → www.exchange-01
|
# set_group exchange # → www.exchange-01
|
||||||
# set_group bank # → www.bank-01
|
# set_group bank # → www.bank-01
|
||||||
# Without set_group: area-01, area-02, … (flat within area)
|
# Without set_group: area-01, area-02, … (flat within area)
|
||||||
|
# Line shape: ┌ OK ┐ #003 www.exchange-02 label · detail
|
||||||
TEST_AREA=""
|
TEST_AREA=""
|
||||||
TEST_GROUP=""
|
TEST_GROUP=""
|
||||||
TEST_N=0
|
TEST_N=0
|
||||||
LAST_TID=""
|
LAST_TID=""
|
||||||
|
GLOBAL_N=0
|
||||||
|
LAST_GLOBAL=""
|
||||||
|
# Progress: set_progress_total N (0 = unknown → bar shows done only)
|
||||||
|
PROGRESS_DONE=0
|
||||||
|
PROGRESS_TOTAL="${PROGRESS_TOTAL:-0}"
|
||||||
|
PROGRESS_SHOW_EVERY="${PROGRESS_SHOW_EVERY:-8}"
|
||||||
|
PROGRESS_LAST_SHOWN=0
|
||||||
# Per-group counters so re-entering www.exchange after perf continues NN
|
# Per-group counters so re-entering www.exchange after perf continues NN
|
||||||
# (shell vars TEST_CNT_<area>_<group>).
|
# (shell vars TEST_CNT_<area>_<group>).
|
||||||
_tid_key() {
|
_tid_key() {
|
||||||
|
|
@ -453,13 +463,69 @@ set_group() {
|
||||||
else
|
else
|
||||||
printf -- '-- %s --\n' "$tag"
|
printf -- '-- %s --\n' "$tag"
|
||||||
fi
|
fi
|
||||||
|
# show progress when entering a new group (if totals known)
|
||||||
|
_progress_maybe_show 1
|
||||||
|
}
|
||||||
|
set_progress_total() {
|
||||||
|
# Optional: expected number of numbered checks in this run (or remaining phase).
|
||||||
|
# PROGRESS_TOTAL=0 → no percent, only "done=N".
|
||||||
|
PROGRESS_TOTAL="${1:-0}"
|
||||||
|
PROGRESS_DONE=0
|
||||||
|
PROGRESS_LAST_SHOWN=0
|
||||||
|
}
|
||||||
|
add_progress_total() {
|
||||||
|
local n="${1:-0}"
|
||||||
|
PROGRESS_TOTAL=$((PROGRESS_TOTAL + n))
|
||||||
|
}
|
||||||
|
_progress_bar_line() {
|
||||||
|
local done="$1" total="$2" width=24 pct=0 filled empty i bar
|
||||||
|
if [ "$total" -gt 0 ]; then
|
||||||
|
pct=$((done * 100 / total))
|
||||||
|
[ "$pct" -gt 100 ] && pct=100
|
||||||
|
filled=$((pct * width / 100))
|
||||||
|
[ "$filled" -gt "$width" ] && filled=$width
|
||||||
|
empty=$((width - filled))
|
||||||
|
bar=""
|
||||||
|
i=0
|
||||||
|
while [ "$i" -lt "$filled" ]; do bar="${bar}█"; i=$((i + 1)); done
|
||||||
|
i=0
|
||||||
|
while [ "$i" -lt "$empty" ]; do bar="${bar}░"; i=$((i + 1)); done
|
||||||
|
if [ "${BOX:-0}" = "1" ]; then
|
||||||
|
printf '%s%s┌ PROG ┐%s %s%s%s %s%3d%%%s %s%d/%d%s\n' \
|
||||||
|
"$D" "$C" "$N" "$C" "$bar" "$N" "$W" "$pct" "$N" "$D" "$done" "$total" "$N"
|
||||||
|
else
|
||||||
|
printf -- '[ PROG ] [%s] %3d%% %d/%d\n' "$bar" "$pct" "$done" "$total"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "${BOX:-0}" = "1" ]; then
|
||||||
|
printf '%s%s┌ PROG ┐%s %sdone=%d%s (total unknown — set PROGRESS_TOTAL=)\n' \
|
||||||
|
"$D" "$C" "$N" "$D" "$done" "$N"
|
||||||
|
else
|
||||||
|
printf -- '[ PROG ] done=%d (total unknown)\n' "$done"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
_progress_maybe_show() {
|
||||||
|
local force="${1:-0}"
|
||||||
|
[ "${PROGRESS_OFF:-0}" = "1" ] && return 0
|
||||||
|
[ "$PROGRESS_DONE" -le 0 ] && [ "$force" != "1" ] && return 0
|
||||||
|
if [ "$force" = "1" ] || \
|
||||||
|
[ $((PROGRESS_DONE - PROGRESS_LAST_SHOWN)) -ge "$PROGRESS_SHOW_EVERY" ] || \
|
||||||
|
{ [ "$PROGRESS_TOTAL" -gt 0 ] && [ "$PROGRESS_DONE" -ge "$PROGRESS_TOTAL" ]; }; then
|
||||||
|
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
|
||||||
|
PROGRESS_LAST_SHOWN=$PROGRESS_DONE
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# Assign next id into LAST_TID (must not run in a subshell).
|
# Assign next id into LAST_TID (must not run in a subshell).
|
||||||
_take_tid() {
|
_take_tid() {
|
||||||
LAST_TID=""
|
LAST_TID=""
|
||||||
|
LAST_GLOBAL=""
|
||||||
if [ -z "${TEST_AREA:-}" ]; then
|
if [ -z "${TEST_AREA:-}" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
# Global monotonic number for the whole monitoring run (#001 …)
|
||||||
|
GLOBAL_N=$((GLOBAL_N + 1))
|
||||||
|
LAST_GLOBAL=$(printf '#%03d' "$GLOBAL_N")
|
||||||
TEST_N=$((TEST_N + 1))
|
TEST_N=$((TEST_N + 1))
|
||||||
if [ -n "${TEST_GROUP:-}" ]; then
|
if [ -n "${TEST_GROUP:-}" ]; then
|
||||||
LAST_TID=$(printf '%s.%s-%02d' "$TEST_AREA" "$TEST_GROUP" "$TEST_N")
|
LAST_TID=$(printf '%s.%s-%02d' "$TEST_AREA" "$TEST_GROUP" "$TEST_N")
|
||||||
|
|
@ -467,9 +533,14 @@ _take_tid() {
|
||||||
else
|
else
|
||||||
LAST_TID=$(printf '%s-%02d' "$TEST_AREA" "$TEST_N")
|
LAST_TID=$(printf '%s-%02d' "$TEST_AREA" "$TEST_N")
|
||||||
fi
|
fi
|
||||||
|
PROGRESS_DONE=$((PROGRESS_DONE + 1))
|
||||||
|
_progress_maybe_show 0
|
||||||
}
|
}
|
||||||
# Dim test id: "www.exchange-01 " or empty
|
# Dim ids: "#003 www.exchange-01 " or empty
|
||||||
_fmt_tid() {
|
_fmt_tid() {
|
||||||
|
if [ -n "${LAST_GLOBAL:-}" ]; then
|
||||||
|
printf '%s%s%s ' "$D" "$LAST_GLOBAL" "$N"
|
||||||
|
fi
|
||||||
if [ -n "${LAST_TID:-}" ]; then
|
if [ -n "${LAST_TID:-}" ]; then
|
||||||
printf '%s%s%s ' "$D" "$LAST_TID" "$N"
|
printf '%s%s%s ' "$D" "$LAST_TID" "$N"
|
||||||
fi
|
fi
|
||||||
|
|
@ -537,7 +608,8 @@ warn() {
|
||||||
head="$a1"
|
head="$a1"
|
||||||
detail=""
|
detail=""
|
||||||
fi
|
fi
|
||||||
_msg_line "$BG_WARN" "WARN" "$W" "$head" "$detail"
|
# Label in yellow text; badge yellow — never red (red = ERROR only)
|
||||||
|
_msg_line "$BG_WARN" "WARN" "$Y" "$head" "$detail"
|
||||||
WARN_N=$((WARN_N + 1))
|
WARN_N=$((WARN_N + 1))
|
||||||
}
|
}
|
||||||
info() {
|
info() {
|
||||||
|
|
@ -581,6 +653,13 @@ section() {
|
||||||
|
|
||||||
summary() {
|
summary() {
|
||||||
echo ""
|
echo ""
|
||||||
|
# final progress line (no _take_tid — plain printf)
|
||||||
|
if [ "${PROGRESS_OFF:-0}" != "1" ] && [ "$PROGRESS_DONE" -gt 0 ]; then
|
||||||
|
_progress_bar_line "$PROGRESS_DONE" "$PROGRESS_TOTAL"
|
||||||
|
fi
|
||||||
|
if [ "$GLOBAL_N" -gt 0 ]; then
|
||||||
|
printf -- '%s numbered checks this run: #001…#%03d\n' "$D" "$GLOBAL_N"
|
||||||
|
fi
|
||||||
if [ "${#BLOCKERS[@]}" -gt 0 ]; then
|
if [ "${#BLOCKERS[@]}" -gt 0 ]; then
|
||||||
if [ "${BOX:-0}" = "1" ]; then
|
if [ "${BOX:-0}" = "1" ]; then
|
||||||
printf -- '%s┌ BLOCKERS · pay/withdraw cannot finish ┐%s\n' "$BG_BLK" "$N"
|
printf -- '%s┌ BLOCKERS · pay/withdraw cannot finish ┐%s\n' "$BG_BLK" "$N"
|
||||||
|
|
@ -832,12 +911,41 @@ read_secret() {
|
||||||
# Human hint when secrets missing (e2e prereq)
|
# Human hint when secrets missing (e2e prereq)
|
||||||
secrets_hint() {
|
secrets_hint() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Set SECRETS_ROOT to koopa-admin-secrets/koopa/host-root (contains taler-bank/),
|
Prefer a local secrets file (not committed):
|
||||||
or KOOPA_ADMIN_SECRETS to the secrets repo root, or export E2E_BANK_ADMIN_PASS.
|
cp scripts/taler-monitoring/secrets.env.example scripts/taler-monitoring/secrets.env
|
||||||
Example (this machine): SECRETS_ROOT=\$HOME/taler/src/koopa-admin-secrets/koopa/host-root
|
\$EDITOR scripts/taler-monitoring/secrets.env
|
||||||
|
Or set SECRETS_ROOT=\$HOME/src/koopa/koopa-admin-secrets/koopa/host-root
|
||||||
|
Or export E2E_BANK_ADMIN_PASS / E2E_MERCHANT_TOKEN for one shot.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Load optional secrets.env next to this suite (gitignored). Safe KEY=value only.
|
||||||
|
# Call once from taler-monitoring.sh after source lib.sh (or any check_*.sh entry).
|
||||||
|
load_monitoring_secrets_env() {
|
||||||
|
local mon_dir f
|
||||||
|
mon_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
f="${MONITORING_SECRETS_ENV:-${mon_dir}/secrets.env}"
|
||||||
|
if [ ! -f "$f" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
set -a
|
||||||
|
# Only simple KEY=VALUE lines; ignore comments / blanks
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
. "$f"
|
||||||
|
set +a
|
||||||
|
# Map common aliases → e2e vars if not already set
|
||||||
|
: "${E2E_BANK_ADMIN_PASS:=${BANK_ADMIN_PASS:-${BANK_ADMIN_PASSWORD:-}}}"
|
||||||
|
: "${E2E_MERCHANT_TOKEN:=${MERCHANT_TOKEN:-${MERCHANT_INSTANCE_PASSWORD:-}}}"
|
||||||
|
: "${SECRETS_ROOT:=${KOOPA_SECRETS_HOST_ROOT:-}}"
|
||||||
|
if [ -z "${SECRETS_ROOT:-}" ] && [ -n "${KOOPA_ADMIN_SECRETS:-}" ]; then
|
||||||
|
if [ -d "${KOOPA_ADMIN_SECRETS}/koopa/host-root/taler-bank" ]; then
|
||||||
|
SECRETS_ROOT="${KOOPA_ADMIN_SECRETS}/koopa/host-root"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
export E2E_BANK_ADMIN_PASS E2E_MERCHANT_TOKEN SECRETS_ROOT KOOPA_ADMIN_SECRETS
|
||||||
|
}
|
||||||
|
|
||||||
find_wallet_cli() {
|
find_wallet_cli() {
|
||||||
# Must return a path suitable for: node "$WALLET_CLI" …
|
# Must return a path suitable for: node "$WALLET_CLI" …
|
||||||
# Prefer *.mjs / bundled entry; plain /usr/bin/taler-wallet-cli is often a
|
# Prefer *.mjs / bundled entry; plain /usr/bin/taler-wallet-cli is often a
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue