SHA256
CORE/CONTENT test5593 и адаптация UI
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
#!/usr/bin/env bash
|
||||
# B acceptance baseline: build + six independent PostgreSQL suites. No production deploy.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/../.."
|
||||
ROOT=$PWD
|
||||
LOG_DIR=$(realpath -m "${1:-$ROOT/../shine-b0-logs-$(date +%Y%m%d-%H%M%S)}")
|
||||
mkdir -p "$LOG_DIR"
|
||||
# No external database or inherited connection settings are used.
|
||||
unset SHINE_TEST_PG_URL SHINE_TEST_PG_USER SHINE_TEST_PG_PASSWORD SHINE_TEST_PG_DISPOSABLE
|
||||
unset PGHOST PGHOSTADDR PGPORT PGUSER PGDATABASE PGSERVICE PGSERVICEFILE PGPASSWORD PGOPTIONS PGPASSFILE PGSSLMODE
|
||||
step() { local label=$1; shift; echo "=== $label ==="; "$@" 2>&1 | tee "$LOG_DIR/$label.log"; }
|
||||
command -v java >/dev/null; command -v javac >/dev/null; command -v node >/dev/null; command -v python3 >/dev/null
|
||||
node -e 'if(typeof WebSocket!=="function") { console.error("Node.js 22+ with native WebSocket required"); process.exit(2); }'
|
||||
if [[ $(id -u) == 0 ]]; then echo 'Run as a regular local user; initdb refuses root.' >&2; exit 2; fi
|
||||
if ! javac -version 2>&1 | grep -Eq '^javac 17([.]|$)'; then echo 'Set JAVA_HOME/PATH to JDK 17 first.' >&2; exit 2; fi
|
||||
if [[ -z ${PG_BIN:-} ]]; then PG_BIN=$(pg_config --bindir); fi
|
||||
for exe in initdb pg_ctl createdb psql postgres; do
|
||||
[[ -x "$PG_BIN/$exe" ]] || { echo "Missing PostgreSQL program: $PG_BIN/$exe" >&2; exit 2; }
|
||||
done
|
||||
step versions bash -c 'java -version; javac -version; node --version; python3 --version; "$1/postgres" --version' _ "$PG_BIN"
|
||||
# Resolve dependencies, compile all modules and root test sources, build fat jar.
|
||||
# Do NOT use integrationTest, startLocal, cleanServerLogs, or any deploy scripts.
|
||||
step gradle bash gradlew --no-daemon --console=plain \
|
||||
:shine-server-blockchain:test :shine-server-db:test :shine-server-net-protocol:test \
|
||||
:shine-server-crypto:test :shine-server-solana-users-sync:test :shine-server-archive:test \
|
||||
:compileTestJava :shadowJar :shine-server-net-protocol:coreWsGuards :shine-server-net-protocol:coreWsRoutes :shine-server-net-protocol:coreChannelReaders
|
||||
step js node --test shine-UI/tests/*.test.mjs shine-UI/tests/*.test.cjs
|
||||
step docs python3 scripts/check_docs.py
|
||||
step config bash scripts/tests/test_external_config.sh
|
||||
step architecture python3 scripts/tests/check_unified_server.py
|
||||
step legacy python3 scripts/check_legacy_reference.py
|
||||
# Isolated, temporary cluster, not the installed system cluster. Random password.
|
||||
umask 077
|
||||
TMP=$(mktemp -d /tmp/shine-b0.XXXXXXXX)
|
||||
STARTED=0
|
||||
WS_PID=
|
||||
stop_ws() {
|
||||
if [[ -n "$WS_PID" ]]; then
|
||||
kill "$WS_PID" 2>/dev/null || true
|
||||
for _ in {1..50}; do kill -0 "$WS_PID" 2>/dev/null || break; sleep 0.1; done
|
||||
kill -KILL "$WS_PID" 2>/dev/null || true
|
||||
wait "$WS_PID" 2>/dev/null || true
|
||||
WS_PID=
|
||||
fi
|
||||
}
|
||||
cleanup() {
|
||||
local status=$?
|
||||
trap - EXIT
|
||||
stop_ws
|
||||
if [[ "$STARTED" == 1 ]] && "$PG_BIN/pg_ctl" -D "$TMP/data" status >/dev/null 2>&1; then
|
||||
if ! "$PG_BIN/pg_ctl" -D "$TMP/data" -m fast -w stop > "$LOG_DIR/postgres-stop.log" 2>&1; then
|
||||
echo "Could not stop isolated PostgreSQL; inspect $TMP/data manually." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
if [[ -f "$TMP/postgres.log" ]]; then cp "$TMP/postgres.log" "$LOG_DIR/postgres.log"; fi
|
||||
rm -rf -- "$TMP"
|
||||
exit "$status"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'exit 130' INT
|
||||
trap 'exit 143' TERM
|
||||
PASSWORD=$(python3 -c 'import secrets; print(secrets.token_hex(24))')
|
||||
printf '%s\n' "$PASSWORD" > "$TMP/pw"
|
||||
PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()')
|
||||
step initdb "$PG_BIN/initdb" -D "$TMP/data" -U shine_b0 -A scram-sha-256 --pwfile="$TMP/pw" --no-locale -E UTF8
|
||||
rm -f "$TMP/pw"
|
||||
# The private Unix socket dir and unique port isolate this cluster; startup
|
||||
# fails if another process claims the port. No fallback to system PG.
|
||||
STARTED=1
|
||||
"$PG_BIN/pg_ctl" -D "$TMP/data" -l "$TMP/postgres.log" -o "-h 127.0.0.1 -p $PORT -k $TMP -c log_statement=none" -w start
|
||||
export PGPASSWORD=$PASSWORD
|
||||
for db in shine_b0_fixture shine_b0_full shine_b0_old shine_core_b1 shine_core_b2 shine_core_registration shine_core_ws; do
|
||||
"$PG_BIN/createdb" -h "$TMP" -p "$PORT" -U shine_b0 "$db"
|
||||
done
|
||||
unset PGPASSWORD
|
||||
export SHINE_TEST_PG_USER=shine_b0 SHINE_TEST_PG_PASSWORD=$PASSWORD SHINE_TEST_PG_DISPOSABLE=YES
|
||||
run_pg() {
|
||||
local db=$1 task=$2
|
||||
export SHINE_TEST_PG_URL="jdbc:postgresql://127.0.0.1:$PORT/$db"
|
||||
step "$task" bash gradlew --no-daemon --console=plain ":shine-server-blockchain:$task"
|
||||
}
|
||||
run_pg shine_b0_fixture corePgFixture
|
||||
run_pg shine_b0_full corePgFullSchema
|
||||
run_pg shine_b0_old corePgOldRevision
|
||||
run_pg shine_core_b1 corePgB1Runtime
|
||||
run_pg shine_core_b2 corePgB2Rotation
|
||||
export SHINE_TEST_PG_URL="jdbc:postgresql://127.0.0.1:$PORT/shine_core_registration"
|
||||
step corePgRegistration bash gradlew --no-daemon --console=plain :shine-server-archive:corePgRegistration
|
||||
grep -F "CORE registration PostgreSQL checks passed:" "$LOG_DIR/corePgRegistration.log" >/dev/null
|
||||
# JavaExec tasks are separate from JUnit; require explicit success output.
|
||||
for pair in 'corePgFixture:fixture' 'corePgFullSchema:full-schema' 'corePgOldRevision:old-revision' 'corePgB1Runtime:B1 runtime' 'corePgB2Rotation:B2 rotation'; do
|
||||
grep -F "CoreContent PostgreSQL ${pair#*:} checks passed:" "$LOG_DIR/${pair%%:*}.log" >/dev/null
|
||||
done
|
||||
grep -F 'CoreContent full-schema runtime DAO smoke checks passed:' "$LOG_DIR/corePgFullSchema.log" >/dev/null
|
||||
# Run the real unified server with only disposable local config, no external workers.
|
||||
WS_DIR="$TMP/ws"
|
||||
mkdir -p "$WS_DIR"
|
||||
WS_PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("127.0.0.1",0)); print(s.getsockname()[1]); s.close()')
|
||||
cat > "$WS_DIR/application.properties" <<CONFIG
|
||||
db.url=jdbc:postgresql://127.0.0.1:$PORT/shine_core_ws
|
||||
db.user=shine_b0
|
||||
db.password=$PASSWORD
|
||||
server.SHiNE.login=acceptance@shine
|
||||
server.port=$WS_PORT
|
||||
solana.cluster=devnet
|
||||
solana.rpcUrl=
|
||||
solana.users.sync.enabled=false
|
||||
freeRegistration.enabled=false
|
||||
debug.tempApi.enabled=false
|
||||
public.files.enabled=true
|
||||
public.files.storageDir=data/public-files
|
||||
dm.files.enabled=true
|
||||
dm.files.storageDir=data/dm-files
|
||||
CONFIG
|
||||
JAR="$ROOT/SHiNE-server/build/libs/shine-server.jar"
|
||||
[[ -f "$JAR" ]]
|
||||
(
|
||||
cd "$WS_DIR"
|
||||
exec env -i PATH="$PATH" HOME="$WS_DIR" SHINE_CORE_STAGING_DISPOSABLE=YES java -jar "$JAR"
|
||||
) > "$LOG_DIR/ws-server.log" 2>&1 &
|
||||
WS_PID=$!
|
||||
step ws-smoke node "$ROOT/scripts/tests/core_ws_smoke.mjs" "$WS_PORT"
|
||||
kill -0 "$WS_PID" # the server process we launched must still be alive
|
||||
stop_ws
|
||||
# Fail on accidental Frame writes, even on a clean CORE database.
|
||||
step ws-frame-empty env PGPASSWORD="$PASSWORD" "$PG_BIN/psql" -X -h "$TMP" -p "$PORT" -U shine_b0 -d shine_core_ws -v ON_ERROR_STOP=1 -Atc 'SELECT (SELECT count(*) FROM blocks_store)+(SELECT count(*) FROM blockchain_state_store)'
|
||||
grep -Fx '0' "$LOG_DIR/ws-frame-empty.log" >/dev/null
|
||||
printf '%s\n' 'B baseline and live loopback smoke passed. Authenticated WS workflows, external services and full behavioral acceptance are NOT proven by smoke.' | tee "$LOG_DIR/RESULT.txt"
|
||||
echo "Logs: $LOG_DIR"
|
||||
Reference in New Issue
Block a user