test(backend): enhance stubs with logging, heartbeat, timed exit, and fake downloads
arma3server_x64 stub: - Logs binary path and all arguments ([STUB] binary=... args=...) - Prints heartbeat every 5 seconds - Accepts -t N flag to exit after N seconds (for auto-exit tests) steamcmd stub: - Parses +force_install_dir and +workshop_download_item args - Creates fake mod directories at the expected workshop content path - Prints fake download progress and success logs New tests: - TestStart_StubLogsArgsAndPath: verifies arg logging via log streamer - TestStart_StubLogsBinaryPath: verifies binary path logging - TestStart_StubHeartbeatLogs: verifies heartbeat lines appear within timeout - TestStart_StubAutoExit: verifies -t flag causes server to auto-exit - TestDownloadMods_StubCreatesModDirs: verifies single mod dir creation - TestDownloadMods_StubCreatesMultipleModDirs: verifies multi-mod dir creation - TestDownloadMods_StubLogsAppear: verifies fake download logs on channel - TestDownloadMods_StubSteamcmdArgsLogged: verifies install_dir logging
This commit is contained in:
+29
-3
@@ -1,5 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Stub arma3server binary for testing.
|
||||
# Logs args to stdout then sleeps until killed (simulates a running server).
|
||||
echo "[STUB] arma3server_x64 called with: $@"
|
||||
sleep 3600
|
||||
# Logs binary path and all arguments, prints heartbeat every 5s.
|
||||
# Use -t N to exit after N seconds (for auto-exit tests).
|
||||
echo "[STUB] binary=$0 args=$*"
|
||||
|
||||
DURATION=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-t) DURATION="$2"; shift 2 ;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$DURATION" -gt 0 ] 2>/dev/null; then
|
||||
ELAPSED=0
|
||||
while [ "$ELAPSED" -lt "$DURATION" ]; do
|
||||
REMAINING=$((DURATION - ELAPSED))
|
||||
WAIT=5
|
||||
if [ "$REMAINING" -lt 5 ]; then WAIT=$REMAINING; fi
|
||||
sleep "$WAIT"
|
||||
ELAPSED=$((ELAPSED + WAIT))
|
||||
echo "[STUB] heartbeat elapsed=${ELAPSED}s remaining=$((REMAINING - WAIT))s"
|
||||
done
|
||||
echo "[STUB] server exiting after ${DURATION}s"
|
||||
else
|
||||
while true; do
|
||||
sleep 5
|
||||
echo "[STUB] heartbeat running..."
|
||||
done
|
||||
fi
|
||||
|
||||
+28
-2
@@ -1,5 +1,31 @@
|
||||
#!/bin/sh
|
||||
# Stub steamcmd binary for testing.
|
||||
# Logs args to stdout then exits immediately.
|
||||
echo "[STUB] steamcmd called with: $@"
|
||||
# Parses +force_install_dir and +workshop_download_item args.
|
||||
# Creates fake mod directories and prints fake download logs.
|
||||
|
||||
INSTALL_DIR=""
|
||||
MOD_IDS=""
|
||||
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
+force_install_dir) INSTALL_DIR="$2"; shift 2 ;;
|
||||
+workshop_download_item)
|
||||
APP_ID="$2"; MOD_ID="$3"; shift 3
|
||||
MOD_IDS="$MOD_IDS $MOD_ID"
|
||||
;;
|
||||
*) shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "[STUB] steamcmd install_dir=$INSTALL_DIR mods=$MOD_IDS"
|
||||
|
||||
for MOD_ID in $MOD_IDS; do
|
||||
MOD_DIR="$INSTALL_DIR/steamapps/workshop/content/107410/$MOD_ID"
|
||||
echo "[STUB] Downloading item $MOD_ID (App $APP_ID)..."
|
||||
echo "[STUB] Downloading 100% [//////////]"
|
||||
mkdir -p "$MOD_DIR"
|
||||
echo "[STUB] Success! App $APP_ID item $MOD_ID installed to $MOD_DIR"
|
||||
done
|
||||
|
||||
echo "[STUB] steamcmd exiting"
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user