mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Add session-scoped dual-session smoke test and harness updates
This commit is contained in:
parent
e4d71d970b
commit
b665ebfeac
4 changed files with 272 additions and 73 deletions
|
|
@ -12,7 +12,7 @@ usage() {
|
|||
cat <<'EOF'
|
||||
Usage: reset_shared_test_state.sh [--all | <server-dir>...]
|
||||
|
||||
Kills shared tmux test sessions and removes stale stdin pipes.
|
||||
Kills shared server tmux test sessions and removes stale server stdin pipes.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
@ -26,8 +26,6 @@ kill_named_session() {
|
|||
tmux kill-session -t "$session_name" 2>/dev/null || true
|
||||
}
|
||||
|
||||
kill_named_session "mcc-debug"
|
||||
|
||||
if [[ $# -eq 0 || "${1:-}" == "--all" ]]; then
|
||||
while IFS= read -r session_name; do
|
||||
[[ -z "$session_name" ]] && continue
|
||||
|
|
@ -46,5 +44,3 @@ else
|
|||
remove_stale_stdin_pipe "$version"
|
||||
done
|
||||
fi
|
||||
|
||||
rm -f "$MCC_REPO/mcc_input.txt"
|
||||
|
|
|
|||
|
|
@ -17,23 +17,22 @@ RUN_ROOT="${TMPDIR:-/tmp}/mcc-integration-testing"
|
|||
RUN_ID="$(date +%Y%m%d-%H%M%S)"
|
||||
RUN_DIR="$RUN_ROOT/$RUN_ID"
|
||||
SERVER_LOG_FILE="$MCC_SERVERS/$VERSION/logs/latest.log"
|
||||
MCC_LOG="$RUN_DIR/mcc.log"
|
||||
SESSION_NAME="full-spectrum-${MC_VERSION//[^a-zA-Z0-9]/_}"
|
||||
TEST_USERNAME="CursorBot"
|
||||
MCC_LOG="$(_mcc_session_log_file "$SESSION_NAME")"
|
||||
BUILD_LOG="$RUN_DIR/build.log"
|
||||
SERVER_TMUX_LOG="$RUN_DIR/server-tmux.log"
|
||||
SERVER_FILE_LOG="$RUN_DIR/server-latest.log"
|
||||
INPUT_FILE="$REPO_ROOT/mcc_input.txt"
|
||||
INPUT_FILE="$(_mcc_session_input_file "$SESSION_NAME")"
|
||||
CFG="$RUN_DIR/MinecraftClient.$MC_VERSION.ini"
|
||||
MCC_PID=""
|
||||
|
||||
mkdir -p "$RUN_DIR"
|
||||
|
||||
cleanup() {
|
||||
if [[ -n "${MCC_PID:-}" ]] && kill -0 "$MCC_PID" 2>/dev/null; then
|
||||
mcc-cmd "quit" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
kill "$MCC_PID" 2>/dev/null || true
|
||||
wait "$MCC_PID" 2>/dev/null || true
|
||||
fi
|
||||
mcc-cmd --session "$SESSION_NAME" "quit" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
mcc-kill --session "$SESSION_NAME" >/dev/null 2>&1 || true
|
||||
|
||||
mc-stop "$VERSION" >/dev/null 2>&1 || true
|
||||
wait_for_server_stop "$VERSION" 20 >/dev/null 2>&1 || true
|
||||
|
|
@ -41,7 +40,7 @@ cleanup() {
|
|||
trap cleanup EXIT
|
||||
|
||||
prepare_config() {
|
||||
bash "$SCRIPT_DIR/prepare_offline_mcc_config.sh" "$CFG" "$MC_VERSION" CursorBot >/dev/null
|
||||
bash "$SCRIPT_DIR/prepare_offline_mcc_config.sh" "$CFG" "$MC_VERSION" "$TEST_USERNAME" >/dev/null
|
||||
}
|
||||
|
||||
wait_for_server_log_pattern() {
|
||||
|
|
@ -129,19 +128,22 @@ run_server_command() {
|
|||
run_mcc_command() {
|
||||
local cmd="$1"
|
||||
echo "MCC> $cmd"
|
||||
mcc-cmd "$cmd"
|
||||
mcc-cmd --session "$SESSION_NAME" "$cmd"
|
||||
sleep 2
|
||||
}
|
||||
|
||||
bash "$SCRIPT_DIR/preflight_test_env.sh" "$VERSION" >/dev/null
|
||||
bash "$SCRIPT_DIR/reset_shared_test_state.sh" "$VERSION" >/dev/null
|
||||
"$SCRIPT_DIR/ensure_offline_server.sh" "$VERSION"
|
||||
mcc-reset-session --session "$SESSION_NAME" >/dev/null
|
||||
echo "Building MCC..."
|
||||
mcc-build > "$BUILD_LOG" 2>&1 || fail "mcc-build failed"
|
||||
prepare_config
|
||||
SERVER_PORT="$(bash "$SCRIPT_DIR/get_server_port.sh" "$VERSION")"
|
||||
|
||||
mkdir -p "$(dirname "$INPUT_FILE")" "$(dirname "$MCC_LOG")"
|
||||
: > "$INPUT_FILE"
|
||||
rm -f "$MCC_LOG"
|
||||
|
||||
echo "Starting server..."
|
||||
mc-start "$VERSION" >/dev/null
|
||||
|
|
@ -150,14 +152,15 @@ wait_for_server_ready "$VERSION" || fail "Server did not become ready"
|
|||
echo "Starting MCC..."
|
||||
(
|
||||
cd "$REPO_ROOT"
|
||||
MCC_FILE_INPUT=1 dotnet run --project MinecraftClient -c Release --no-build -- "$CFG" CursorBot - "localhost:$SERVER_PORT" > "$MCC_LOG" 2>&1
|
||||
MCC_FILE_INPUT=1 MCC_INPUT_FILE="$INPUT_FILE" \
|
||||
dotnet run --project MinecraftClient -c Release --no-build -- "$CFG" "$TEST_USERNAME" - "localhost:$SERVER_PORT" > "$MCC_LOG" 2>&1
|
||||
) &
|
||||
MCC_PID=$!
|
||||
|
||||
wait_for_file_pattern "$MCC_LOG" "Server was successfully joined." "MCC join success" 90 || fail "MCC failed to join"
|
||||
wait_for_server_log_pattern "CursorBot joined the game" "server join entry" 30 || fail "Server never logged the join"
|
||||
wait_for_server_log_pattern "$TEST_USERNAME joined the game" "server join entry" 30 || fail "Server never logged the join"
|
||||
|
||||
run_server_command "op CursorBot"
|
||||
run_server_command "op $TEST_USERNAME"
|
||||
run_server_command "gamerule sendCommandFeedback true"
|
||||
run_server_command "gamerule logAdminCommands true"
|
||||
run_server_command "time set day"
|
||||
|
|
@ -176,7 +179,7 @@ run_mcc_command "/time query daytime"
|
|||
run_mcc_command "smoke_test_from_mcc_full_spectrum"
|
||||
|
||||
# ── Phase 2: Movement and look commands ──
|
||||
run_mcc_command "/tp CursorBot 0 -60 0"
|
||||
run_mcc_command "/tp $TEST_USERNAME 0 -60 0"
|
||||
sleep 3
|
||||
run_mcc_command "look up"
|
||||
sleep 1
|
||||
|
|
@ -193,35 +196,35 @@ run_mcc_command "inventory creativeclear 38"
|
|||
run_mcc_command "inventory player list"
|
||||
|
||||
# ── Phase 4: Block placement and interaction ──
|
||||
run_server_command "execute as CursorBot at @s run fill ~1 ~ ~1 ~3 ~2 ~3 minecraft:stone"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run fill ~1 ~ ~1 ~3 ~2 ~3 minecraft:stone"
|
||||
sleep 2
|
||||
run_server_command "execute as CursorBot at @s run setblock ~5 ~ ~5 minecraft:chest"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run setblock ~5 ~ ~5 minecraft:chest"
|
||||
sleep 1
|
||||
run_server_command "execute as CursorBot at @s run setblock ~5 ~1 ~5 minecraft:furnace"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run setblock ~5 ~1 ~5 minecraft:furnace"
|
||||
sleep 1
|
||||
run_server_command "execute as CursorBot at @s run setblock ~6 ~ ~5 minecraft:crafting_table"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run setblock ~6 ~ ~5 minecraft:crafting_table"
|
||||
sleep 1
|
||||
|
||||
# ── Phase 5: Entity spawning (expanded coverage) ──
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:cow ~2 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:zombie ~4 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:creeper ~6 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:skeleton ~8 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:villager ~-2 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:allay ~-4 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:armor_stand ~ ~ ~2"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:item_display ~-6 ~ ~ {item:{id:\"minecraft:diamond\",count:1}}"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:spider ~10 ~ ~"
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:pig ~-8 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:cow ~2 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:zombie ~4 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:creeper ~6 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:skeleton ~8 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:villager ~-2 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:allay ~-4 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:armor_stand ~ ~ ~2"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:item_display ~-6 ~ ~ {item:{id:\"minecraft:diamond\",count:1}}"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:spider ~10 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:pig ~-8 ~ ~"
|
||||
|
||||
sleep 2
|
||||
run_mcc_command "entity"
|
||||
|
||||
# ── Phase 6: Effects and environment ──
|
||||
run_server_command "effect give CursorBot minecraft:speed 30 1"
|
||||
run_server_command "effect give $TEST_USERNAME minecraft:speed 30 1"
|
||||
sleep 2
|
||||
run_mcc_command "health"
|
||||
run_server_command "effect give CursorBot minecraft:regeneration 10 1"
|
||||
run_server_command "effect give $TEST_USERNAME minecraft:regeneration 10 1"
|
||||
sleep 2
|
||||
run_mcc_command "health"
|
||||
|
||||
|
|
@ -233,39 +236,39 @@ run_mcc_command "/gamemode creative"
|
|||
sleep 2
|
||||
|
||||
# ── Phase 8: Dimension change (nether) ──
|
||||
run_server_command "execute in minecraft:the_nether run tp CursorBot 0 64 0"
|
||||
run_server_command "execute in minecraft:the_nether run tp $TEST_USERNAME 0 64 0"
|
||||
sleep 4
|
||||
run_mcc_command "health"
|
||||
run_server_command "execute in minecraft:overworld run tp CursorBot 0 -60 0"
|
||||
run_server_command "execute in minecraft:overworld run tp $TEST_USERNAME 0 -60 0"
|
||||
sleep 4
|
||||
|
||||
# ── Phase 9: Server chat and whisper ──
|
||||
run_server_command "say Hello from the server console"
|
||||
sleep 2
|
||||
run_server_command "msg CursorBot This is a private whisper"
|
||||
run_server_command "msg $TEST_USERNAME This is a private whisper"
|
||||
sleep 2
|
||||
run_mcc_command "integration_test_chat_response"
|
||||
|
||||
# ── Phase 10: Particles, sounds, and explosions ──
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:happy_villager ~ ~1 ~ 0.5 0.5 0.5 0 12 force"
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:end_rod ~ ~1 ~ 0.5 0.5 0.5 0.01 20 force"
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:explosion ~ ~1 ~ 0 0 0 0 1 force"
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:totem_of_undying ~ ~1 ~ 0.5 0.5 0.5 0.1 20 force"
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:flame ~ ~1 ~ 0.2 0.2 0.2 0.02 30 force"
|
||||
run_server_command "execute as CursorBot at @s run particle minecraft:heart ~ ~2 ~ 0.3 0.3 0.3 0 5 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:happy_villager ~ ~1 ~ 0.5 0.5 0.5 0 12 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:end_rod ~ ~1 ~ 0.5 0.5 0.5 0.01 20 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:explosion ~ ~1 ~ 0 0 0 0 1 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:totem_of_undying ~ ~1 ~ 0.5 0.5 0.5 0.1 20 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:flame ~ ~1 ~ 0.2 0.2 0.2 0.02 30 force"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run particle minecraft:heart ~ ~2 ~ 0.3 0.3 0.3 0 5 force"
|
||||
|
||||
run_server_command "execute as CursorBot at @s run playsound minecraft:entity.lightning_bolt.thunder master CursorBot ~ ~ ~ 1 1 0"
|
||||
run_server_command "execute as CursorBot at @s run playsound minecraft:block.note_block.bell master CursorBot ~ ~ ~ 1 1 0"
|
||||
run_server_command "execute as CursorBot at @s run playsound minecraft:entity.experience_orb.pickup master CursorBot ~ ~ ~ 1 1 0"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run playsound minecraft:entity.lightning_bolt.thunder master $TEST_USERNAME ~ ~ ~ 1 1 0"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run playsound minecraft:block.note_block.bell master $TEST_USERNAME ~ ~ ~ 1 1 0"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run playsound minecraft:entity.experience_orb.pickup master $TEST_USERNAME ~ ~ ~ 1 1 0"
|
||||
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:tnt ~3 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:tnt ~3 ~ ~"
|
||||
sleep 2
|
||||
run_server_command "execute as CursorBot at @s run summon minecraft:tnt ~6 ~ ~"
|
||||
run_server_command "execute as $TEST_USERNAME at @s run summon minecraft:tnt ~6 ~ ~"
|
||||
|
||||
# ── Phase 11: Kill and respawn cycle ──
|
||||
run_mcc_command "/gamemode survival"
|
||||
sleep 2
|
||||
run_server_command "kill CursorBot"
|
||||
run_server_command "kill $TEST_USERNAME"
|
||||
sleep 4
|
||||
run_mcc_command "respawn"
|
||||
sleep 4
|
||||
|
|
@ -295,14 +298,14 @@ assert_not_contains "$MCC_LOG" "Failed to load settings" "MCC failed to reload i
|
|||
assert_not_contains "$MCC_LOG" "NullReferenceException" "A NullReferenceException occurred during the test"
|
||||
|
||||
# ── Assertions: Server log ──
|
||||
assert_contains "$SERVER_FILE_LOG" "CursorBot joined the game" "Server never saw CursorBot join"
|
||||
assert_contains "$SERVER_FILE_LOG" "$TEST_USERNAME joined the game" "Server never saw $TEST_USERNAME join"
|
||||
assert_contains "$SERVER_FILE_LOG" "smoke_test_from_mcc_full_spectrum" "Server never received the client chat message"
|
||||
assert_contains "$SERVER_FILE_LOG" "Displaying particle minecraft:happy_villager" "Particle events were not recorded on the server"
|
||||
assert_contains "$SERVER_FILE_LOG" "Played sound minecraft:block.note_block.bell to CursorBot" "Sound events were not recorded on the server"
|
||||
assert_contains "$SERVER_FILE_LOG" "Played sound minecraft:block.note_block.bell to $TEST_USERNAME" "Sound events were not recorded on the server"
|
||||
assert_contains "$SERVER_FILE_LOG" "Summoned new Primed TNT" "TNT summon did not occur on the server"
|
||||
assert_contains "$SERVER_FILE_LOG" "integration_test_chat_response" "Server never received the chat response test message"
|
||||
assert_contains "$SERVER_FILE_LOG" "Hello from the server console" "Server say command was not logged"
|
||||
assert_contains "$SERVER_FILE_LOG" "Killed CursorBot" "Server kill command did not execute"
|
||||
assert_contains "$SERVER_FILE_LOG" "Killed $TEST_USERNAME" "Server kill command did not execute"
|
||||
assert_not_contains "$SERVER_FILE_LOG" "Sending unknown packet 'clientbound/minecraft:disconnect'" "Server hit the disconnect packet regression during the test"
|
||||
|
||||
cat <<EOF
|
||||
|
|
|
|||
197
.skills/mcc-integration-testing/scripts/run_parallel_session_smoke_test.sh
Executable file
197
.skills/mcc-integration-testing/scripts/run_parallel_session_smoke_test.sh
Executable file
|
|
@ -0,0 +1,197 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
||||
# shellcheck source=tools/mcc-env.sh
|
||||
source "$REPO_ROOT/tools/mcc-env.sh"
|
||||
# shellcheck source=.skills/mcc-integration-testing/scripts/common.sh
|
||||
source "$SCRIPT_DIR/common.sh"
|
||||
|
||||
VERSION="${1:-1.21.11-Vanilla}"
|
||||
MC_VERSION="${VERSION%-Vanilla}"
|
||||
if [[ "$MC_VERSION" == "$VERSION" ]]; then
|
||||
MC_VERSION="$VERSION"
|
||||
fi
|
||||
|
||||
SESSION_A="parallel-smoke-a-${MC_VERSION//[^a-zA-Z0-9]/_}"
|
||||
SESSION_B="parallel-smoke-b-${MC_VERSION//[^a-zA-Z0-9]/_}"
|
||||
USERNAME_A="SmokeA"
|
||||
USERNAME_B="SmokeB"
|
||||
|
||||
RUN_ROOT="${TMPDIR:-/tmp}/mcc-integration-testing"
|
||||
RUN_ID="$(date +%Y%m%d-%H%M%S)"
|
||||
RUN_DIR="$RUN_ROOT/parallel-smoke-$RUN_ID"
|
||||
BUILD_LOG="$RUN_DIR/build.log"
|
||||
SERVER_TMUX_LOG="$RUN_DIR/server-tmux.log"
|
||||
SERVER_FILE_LOG="$RUN_DIR/server-latest.log"
|
||||
SERVER_LOG_FILE="$MCC_SERVERS/$VERSION/logs/latest.log"
|
||||
|
||||
LOG_A="$(_mcc_session_log_file "$SESSION_A")"
|
||||
LOG_B="$(_mcc_session_log_file "$SESSION_B")"
|
||||
INPUT_A="$(_mcc_session_input_file "$SESSION_A")"
|
||||
INPUT_B="$(_mcc_session_input_file "$SESSION_B")"
|
||||
PID_A_FILE="$(_mcc_session_pid_file "$SESSION_A")"
|
||||
PID_B_FILE="$(_mcc_session_pid_file "$SESSION_B")"
|
||||
|
||||
mkdir -p "$RUN_DIR"
|
||||
|
||||
wait_for_file_pattern() {
|
||||
local file="$1"
|
||||
local pattern="$2"
|
||||
local description="$3"
|
||||
local timeout="${4:-60}"
|
||||
local elapsed=0
|
||||
|
||||
while (( elapsed < timeout )); do
|
||||
if [[ -f "$file" ]] && grep -Fq "$pattern" "$file"; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
((elapsed += 1))
|
||||
done
|
||||
|
||||
echo "Timed out waiting for: $description" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_for_server_log_pattern() {
|
||||
local pattern="$1"
|
||||
local description="$2"
|
||||
local timeout="${3:-60}"
|
||||
local elapsed=0
|
||||
|
||||
while (( elapsed < timeout )); do
|
||||
if [[ -f "$SERVER_LOG_FILE" ]] && grep -Fq "$pattern" "$SERVER_LOG_FILE"; then
|
||||
return 0
|
||||
fi
|
||||
sleep 1
|
||||
((elapsed += 1))
|
||||
done
|
||||
|
||||
echo "Timed out waiting for server log: $description" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
capture_server_logs() {
|
||||
mc-log "$VERSION" 400 > "$SERVER_TMUX_LOG" 2>/dev/null || true
|
||||
if [[ -f "$SERVER_LOG_FILE" ]]; then
|
||||
cp "$SERVER_LOG_FILE" "$SERVER_FILE_LOG"
|
||||
fi
|
||||
}
|
||||
|
||||
fail() {
|
||||
capture_server_logs
|
||||
echo "FAIL: $1" >&2
|
||||
echo "Run directory: $RUN_DIR" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
mcc-cmd --session "$SESSION_A" "quit" >/dev/null 2>&1 || true
|
||||
mcc-cmd --session "$SESSION_B" "quit" >/dev/null 2>&1 || true
|
||||
sleep 1
|
||||
mcc-kill --session "$SESSION_A" >/dev/null 2>&1 || true
|
||||
mcc-kill --session "$SESSION_B" >/dev/null 2>&1 || true
|
||||
mc-stop "$VERSION" >/dev/null 2>&1 || true
|
||||
wait_for_server_stop "$VERSION" 20 >/dev/null 2>&1 || true
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
assert_session_alive() {
|
||||
local session="$1"
|
||||
local pid_file="$2"
|
||||
if [[ -s "$pid_file" ]]; then
|
||||
local pid
|
||||
pid="$(tr -cd '0-9' < "$pid_file")"
|
||||
if [[ -n "$pid" ]] && kill -0 "$pid" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
tmux has-session -t "$(_mcc_tmux_session_name "$session")" 2>/dev/null
|
||||
}
|
||||
|
||||
assert_server_alive() {
|
||||
server_running "$VERSION" || fail "Shared server session is not alive"
|
||||
}
|
||||
|
||||
start_file_input_session() {
|
||||
local session="$1"
|
||||
local username="$2"
|
||||
bash "$REPO_ROOT/tools/mcc-debug.sh" \
|
||||
--version "$VERSION" \
|
||||
--file-input \
|
||||
--no-build \
|
||||
--session "$session" \
|
||||
--username "$username" >/dev/null
|
||||
}
|
||||
|
||||
bash "$SCRIPT_DIR/preflight_test_env.sh" "$VERSION" >/dev/null
|
||||
bash "$SCRIPT_DIR/reset_shared_test_state.sh" "$VERSION" >/dev/null
|
||||
"$SCRIPT_DIR/ensure_offline_server.sh" "$VERSION" >/dev/null
|
||||
mcc-reset-session --session "$SESSION_A" >/dev/null
|
||||
mcc-reset-session --session "$SESSION_B" >/dev/null
|
||||
|
||||
echo "Building MCC..."
|
||||
mcc-build > "$BUILD_LOG" 2>&1 || fail "mcc-build failed"
|
||||
|
||||
echo "Starting shared server..."
|
||||
mc-start "$VERSION" >/dev/null
|
||||
wait_for_server_ready "$VERSION" || fail "Server did not become ready"
|
||||
SERVER_PORT="$(bash "$SCRIPT_DIR/get_server_port.sh" "$VERSION")"
|
||||
if [[ -z "$SERVER_PORT" ]]; then
|
||||
fail "Failed to resolve server port"
|
||||
fi
|
||||
|
||||
echo "Starting MCC session A..."
|
||||
start_file_input_session "$SESSION_A" "$USERNAME_A"
|
||||
echo "Starting MCC session B..."
|
||||
start_file_input_session "$SESSION_B" "$USERNAME_B"
|
||||
|
||||
wait_for_file_pattern "$LOG_A" "Server was successfully joined." "session A join success" 90 || fail "Session A failed to join"
|
||||
wait_for_file_pattern "$LOG_B" "Server was successfully joined." "session B join success" 90 || fail "Session B failed to join"
|
||||
wait_for_server_log_pattern "$USERNAME_A joined the game" "server join for session A" 30 || fail "Server never logged $USERNAME_A join"
|
||||
wait_for_server_log_pattern "$USERNAME_B joined the game" "server join for session B" 30 || fail "Server never logged $USERNAME_B join"
|
||||
|
||||
echo "Sending debug state to both sessions..."
|
||||
mcc-cmd --session "$SESSION_A" "debug state"
|
||||
mcc-cmd --session "$SESSION_B" "debug state"
|
||||
sleep 2
|
||||
wait_for_file_pattern "$LOG_A" "[FileInput] > debug state" "session A debug state command" 20 || fail "Session A did not consume debug state"
|
||||
wait_for_file_pattern "$LOG_B" "[FileInput] > debug state" "session B debug state command" 20 || fail "Session B did not consume debug state"
|
||||
|
||||
echo "Killing session A..."
|
||||
mcc-kill --session "$SESSION_A" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
|
||||
assert_session_alive "$SESSION_B" "$PID_B_FILE" || fail "Session B is not alive after killing session A"
|
||||
assert_server_alive
|
||||
|
||||
echo "Verifying session B still responds..."
|
||||
mcc-cmd --session "$SESSION_B" "health"
|
||||
wait_for_file_pattern "$LOG_B" "[FileInput] > health" "session B health command after session A kill" 20 || fail "Session B stopped responding after session A kill"
|
||||
|
||||
if [[ -s "$PID_A_FILE" ]]; then
|
||||
pid_a="$(tr -cd '0-9' < "$PID_A_FILE")"
|
||||
if [[ -n "$pid_a" ]] && kill -0 "$pid_a" 2>/dev/null; then
|
||||
fail "Session A is still alive after mcc-kill"
|
||||
fi
|
||||
fi
|
||||
|
||||
capture_server_logs
|
||||
|
||||
cat <<EOF
|
||||
PASS
|
||||
Run directory: $RUN_DIR
|
||||
Server version: $VERSION
|
||||
Server port: $SERVER_PORT
|
||||
Session A: $SESSION_A ($USERNAME_A)
|
||||
Session A input: $INPUT_A
|
||||
Session A log: $LOG_A
|
||||
Session B: $SESSION_B ($USERNAME_B)
|
||||
Session B input: $INPUT_B
|
||||
Session B log: $LOG_B
|
||||
Server log: $SERVER_FILE_LOG
|
||||
Build log: $BUILD_LOG
|
||||
EOF
|
||||
Loading…
Add table
Add a link
Reference in a new issue