mirror of
https://oauth2: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@github.com/m1ngsama/TNT.git
synced 2026-06-26 05:44:38 +08:00
test: wait for basic health readiness
This commit is contained in:
parent
998da4288f
commit
84e26e3f74
2 changed files with 18 additions and 3 deletions
|
|
@ -58,6 +58,8 @@
|
||||||
as part of `make ci-test`.
|
as part of `make ci-test`.
|
||||||
- Stress testing now uses isolated state, waits for real SSH health, avoids
|
- Stress testing now uses isolated state, waits for real SSH health, avoids
|
||||||
external `timeout` helpers, and is available through `make stress-test`.
|
external `timeout` helpers, and is available through `make stress-test`.
|
||||||
|
- Basic integration tests now wait for real SSH `health` responses instead of
|
||||||
|
sleeping for a fixed startup delay.
|
||||||
- Refreshed README and quick-reference module maps to match the current
|
- Refreshed README and quick-reference module maps to match the current
|
||||||
`cli_text`, `help_text`, `support_text`, i18n, exec, and rate-limit modules.
|
`cli_text`, `help_text`, `support_text`, i18n, exec, and rate-limit modules.
|
||||||
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
- NORMAL mode now opens at the latest visible messages instead of the oldest
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ FAIL=0
|
||||||
BIN="../tnt"
|
BIN="../tnt"
|
||||||
SERVER_PID=""
|
SERVER_PID=""
|
||||||
STATE_DIR=$(mktemp -d "${TMPDIR:-/tmp}/tnt-basic-test.XXXXXX")
|
STATE_DIR=$(mktemp -d "${TMPDIR:-/tmp}/tnt-basic-test.XXXXXX")
|
||||||
|
SSH_HEALTH_OPTS="-n -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -p $PORT"
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
if [ -n "$SERVER_PID" ]; then
|
if [ -n "$SERVER_PID" ]; then
|
||||||
|
|
@ -19,6 +20,19 @@ cleanup() {
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
wait_for_health() {
|
||||||
|
out=""
|
||||||
|
for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
||||||
|
if [ -n "$SERVER_PID" ] && ! kill -0 "$SERVER_PID" 2>/dev/null; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
out=$(ssh $SSH_HEALTH_OPTS localhost health 2>/dev/null || true)
|
||||||
|
[ "$out" = "ok" ] && return 0
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
echo "=== TNT Basic Tests ==="
|
echo "=== TNT Basic Tests ==="
|
||||||
|
|
||||||
if [ ! -f "$BIN" ]; then
|
if [ ! -f "$BIN" ]; then
|
||||||
|
|
@ -34,10 +48,9 @@ fi
|
||||||
# Start server
|
# Start server
|
||||||
"$BIN" -p "$PORT" -d "$STATE_DIR" >"$STATE_DIR/server.log" 2>&1 &
|
"$BIN" -p "$PORT" -d "$STATE_DIR" >"$STATE_DIR/server.log" 2>&1 &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
sleep 2
|
|
||||||
|
|
||||||
# Test 1: Server started
|
# Test 1: Server started and accepts exec health checks
|
||||||
if kill -0 $SERVER_PID 2>/dev/null; then
|
if wait_for_health; then
|
||||||
echo "✓ Server started"
|
echo "✓ Server started"
|
||||||
PASS=$((PASS + 1))
|
PASS=$((PASS + 1))
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue