fix(tests): устранение SIGPIPE broken pipe при проверках пайплайнов под set -eo pipefail
This commit is contained in:
@@ -117,7 +117,7 @@ for expected in \
|
||||
"OOM_DETECTED=oom.detected" \
|
||||
"SMARTDETECT_CANDIDATE=smartdetect.candidate"
|
||||
do
|
||||
printf '%s\n' "$types" | grep -qx "$expected" || fail "event vocabulary missing $expected"
|
||||
grep -qxF "$expected" <<< "$types" || fail "event vocabulary missing $expected"
|
||||
done
|
||||
|
||||
# --- publication layer: the OOM replay guard ---
|
||||
|
||||
@@ -94,11 +94,11 @@ $out"
|
||||
}
|
||||
rm -f "$driver"
|
||||
|
||||
printf '%s\n' "$out" | grep -q 'singbox.stopped' \
|
||||
grep -q 'singbox.stopped' <<< "$out" \
|
||||
|| fail "handle_ubus_service_stop published nothing (got: $out)"
|
||||
printf '%s\n' "$out" | grep -q 'firewall.reloaded' \
|
||||
grep -q 'firewall.reloaded' <<< "$out" \
|
||||
|| fail "handle_ubus_firewall_reload published nothing (got: $out)"
|
||||
printf '%s\n' "$out" | grep -q 'honeypot.hit' \
|
||||
grep -q 'honeypot.hit' <<< "$out" \
|
||||
|| fail "handle_honeypot_line published nothing (got: $out)"
|
||||
|
||||
printf 'forward reference checks passed\n'
|
||||
|
||||
@@ -96,16 +96,16 @@ for healer in heal_dns_stall heal_proxy_connectivity heal_proxy_health; do
|
||||
' "$WATCHDOG_UC")"
|
||||
[ -n "$body" ] || fail "$healer not found"
|
||||
|
||||
printf '%s\n' "$body" | grep -q 'if (!safe_proxy_restart(' \
|
||||
grep -q 'if (!safe_proxy_restart(' <<< "$body" \
|
||||
|| fail "$healer does not check the safe_proxy_restart() return value; a skipped restart would report as a repair"
|
||||
printf '%s\n' "$body" | grep -q '"skipped");' \
|
||||
grep -q '"skipped");' <<< "$body" \
|
||||
|| fail "$healer does not report a skipped outcome when the restart never ran"
|
||||
printf '%s\n' "$body" | grep -q 'watch_recovery(' \
|
||||
grep -q 'watch_recovery(' <<< "$body" \
|
||||
|| fail "$healer restarts without registering a recovery watch; its outcome is unknowable"
|
||||
|
||||
# The literal "fixed" is what the old code passed unconditionally. An
|
||||
# asynchronous healer cannot know that at call time.
|
||||
if printf '%s\n' "$body" | grep -q '"fixed"'; then
|
||||
if grep -q '"fixed"' <<< "$body"; then
|
||||
fail "$healer still claims a fixed outcome for an asynchronous restart"
|
||||
fi
|
||||
done
|
||||
@@ -119,7 +119,7 @@ for healer in heal_dns_continuous heal_rpcd; do
|
||||
inside && /^}$/ { exit }
|
||||
' "$WATCHDOG_UC")"
|
||||
[ -n "$body" ] || fail "$healer not found"
|
||||
printf '%s\n' "$body" | grep -q 'rc == 0 ? "fixed" : "failed"' \
|
||||
grep -q 'rc == 0 ? "fixed" : "failed"' <<< "$body" \
|
||||
|| fail "$healer reports a fixed outcome without checking the command's exit status"
|
||||
done
|
||||
|
||||
@@ -127,12 +127,12 @@ done
|
||||
# diagnostics/status.uc:1178 and telegram.uc:1823 read this file; ai-status must
|
||||
# keep answering with the same shape whether or not an incident exists.
|
||||
status_json="$(ucode -L "$TACHYON_LIB" "$WATCHDOG_UC" ai-status)"
|
||||
printf '%s' "$status_json" | grep -q '"ai_active"' \
|
||||
grep -q '"ai_active"' <<< "$status_json" \
|
||||
|| fail "ai-status no longer reports ai_active: $status_json"
|
||||
|
||||
full_json="$(ucode -L "$TACHYON_LIB" "$WATCHDOG_UC" ai-status-full)"
|
||||
for key in '"status"' '"ai_active"' '"last_incident"' '"incidents_total"'; do
|
||||
printf '%s' "$full_json" | grep -q "$key" \
|
||||
grep -q "$key" <<< "$full_json" \
|
||||
|| fail "ai-status-full lost $key from its contract"
|
||||
done
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ assert_rejects() {
|
||||
if output="$(ucode "$PARSER" parse-source-entry-tsv "$entry" 2>/dev/null)"; then
|
||||
fail "entry should be rejected: $entry"
|
||||
fi
|
||||
printf '%s\n' "$output" | grep -q "$expected" || fail "expected reject message containing $expected"
|
||||
grep -q "$expected" <<< "$output" || fail "expected reject message containing $expected"
|
||||
}
|
||||
|
||||
assert_tsv ' https://example.com/sub.txt ' 'https://example.com/sub.txt' ''
|
||||
|
||||
@@ -54,7 +54,7 @@ done
|
||||
vocabulary="$(ucode -L "$TACHYON_LIB" "$CONTROLLER_UC" event-types \
|
||||
| sed 's/=.*//' | sort -u)"
|
||||
for ev in $emitted $subscribed; do
|
||||
printf '%s\n' "$vocabulary" | grep -qx "$ev" \
|
||||
grep -qxF "$ev" <<< "$vocabulary" \
|
||||
|| fail "EV.$ev is used but missing from the exported event vocabulary"
|
||||
done
|
||||
|
||||
@@ -67,7 +67,7 @@ for required in \
|
||||
OOM_DETECTED OOM_RECOVERABLE MEMORY_LOW RPCD_FD_LEAK ANOMALY_RECONNECTS \
|
||||
SMARTDETECT_CANDIDATE URLTEST_SWITCHED HONEYPOT_HIT
|
||||
do
|
||||
printf '%s\n' "$subscribed" | grep -qx "$required" \
|
||||
grep -qxF "$required" <<< "$subscribed" \
|
||||
|| fail "no subscriber for EV.$required (was repaired on a timer before the refactor)"
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user