From db90ddcce564125afff08bed256aa91ab653c6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hern=C3=A2ni=20Marques?= Date: Fri, 17 Jul 2026 18:18:09 +0200 Subject: [PATCH] monitoring: WARN badge yellow, red only for errors --- scripts/taler-monitoring/lib.sh | 132 +++++++++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 12 deletions(-) diff --git a/scripts/taler-monitoring/lib.sh b/scripts/taler-monitoring/lib.sh index 938be14..1ef6f9a 100755 --- a/scripts/taler-monitoring/lib.sh +++ b/scripts/taler-monitoring/lib.sh @@ -376,12 +376,13 @@ else B=$'\e[1m' # bold section N=$'\e[0m' # reset # Badge fill: bright text on solid background - BG_OK=$'\e[1;30;42m' # black on green - BG_INFO=$'\e[1;30;46m' # black on cyan - BG_WARN=$'\e[1;30;43m' # black on yellow - BG_ERR=$'\e[1;37;41m' # white on red - BG_BLK=$'\e[1;37;45m' # white on magenta - BG_SEC=$'\e[1;37;44m' # white on blue (section) + # WARN = yellow only (never red). ERROR/BLOCKER use red/magenta. + BG_OK=$'\e[1;30;42m' # black on green + BG_INFO=$'\e[1;30;46m' # black on cyan + BG_WARN=$'\e[1;30;103m' # black on bright yellow (clearly not red) + BG_ERR=$'\e[1;37;41m' # white on red — errors only + BG_BLK=$'\e[1;37;45m' # white on magenta — blockers + BG_SEC=$'\e[1;37;44m' # white on blue (section) BOX=1 fi @@ -393,14 +394,23 @@ BLOCKERS=() # human-readable payment/withdraw blockers ERRORS=() # all ERROR lines (component scope) # 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_group exchange # resets counter + prints group box → www.exchange-01 +# set_group exchange # → www.exchange-01 # set_group bank # → www.bank-01 # Without set_group: area-01, area-02, … (flat within area) +# Line shape: ┌ OK ┐ #003 www.exchange-02 label · detail TEST_AREA="" TEST_GROUP="" TEST_N=0 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 # (shell vars TEST_CNT__). _tid_key() { @@ -453,13 +463,69 @@ set_group() { else printf -- '-- %s --\n' "$tag" 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). _take_tid() { LAST_TID="" + LAST_GLOBAL="" if [ -z "${TEST_AREA:-}" ]; then return 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)) if [ -n "${TEST_GROUP:-}" ]; then LAST_TID=$(printf '%s.%s-%02d' "$TEST_AREA" "$TEST_GROUP" "$TEST_N") @@ -467,9 +533,14 @@ _take_tid() { else LAST_TID=$(printf '%s-%02d' "$TEST_AREA" "$TEST_N") 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() { + if [ -n "${LAST_GLOBAL:-}" ]; then + printf '%s%s%s ' "$D" "$LAST_GLOBAL" "$N" + fi if [ -n "${LAST_TID:-}" ]; then printf '%s%s%s ' "$D" "$LAST_TID" "$N" fi @@ -537,7 +608,8 @@ warn() { head="$a1" detail="" 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)) } info() { @@ -581,6 +653,13 @@ section() { summary() { 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 [ "${BOX:-0}" = "1" ]; then 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) secrets_hint() { cat <