feat: harden recording lifecycle and refresh fnOS UI
This commit is contained in:
@@ -26,6 +26,11 @@ ADMIN_PASSWORD='LiveRecorder-Smoke-2026!'
|
||||
PG_ADMIN_PASSWORD='Postgres-Admin-Smoke-2026!'
|
||||
ENROLLMENT_TOKEN='Postgres-Enrollment-Smoke-2026!'
|
||||
MEDIA_PATH="${PATH:-/usr/local/bin:/usr/bin:/bin}"
|
||||
NODEJS_ROOT="$WORK_DIR/nodejs-v22-target"
|
||||
NODEJS_BIN="${NODEJS_SMOKE_BIN:-$(type -P node)}"
|
||||
|
||||
mkdir -p "$NODEJS_ROOT/bin"
|
||||
ln -s "$NODEJS_BIN" "$NODEJS_ROOT/bin/node"
|
||||
|
||||
if ! PATH="$MEDIA_PATH" command -v ffmpeg >/dev/null 2>&1 || \
|
||||
! PATH="$MEDIA_PATH" command -v ffprobe >/dev/null 2>&1; then
|
||||
@@ -38,7 +43,8 @@ fi
|
||||
run_live_control() {
|
||||
TRIM_APPDEST="$LIVE_APP_ROOT" TRIM_PKGVAR="$LIVE_DATA_ROOT" \
|
||||
TRIM_APPDEST_VOL="$LIVE_VOLUME_ROOT" TRIM_SERVICE_PORT="$LIVE_PORT" \
|
||||
POSTGRES_SERVICE_API="http://127.0.0.1:$PG_API_PORT" PATH="$MEDIA_PATH" "$LIVE_CONTROL" "$@"
|
||||
POSTGRES_SERVICE_API="http://127.0.0.1:$PG_API_PORT" NODEJS_ROOT="$NODEJS_ROOT" \
|
||||
PATH="$MEDIA_PATH" "$LIVE_CONTROL" "$@"
|
||||
}
|
||||
|
||||
run_postgres_control() {
|
||||
@@ -55,7 +61,7 @@ cleanup() {
|
||||
printf '%s\n' 'fnOS shared-stack smoke test failed; service logs follow:' >&2
|
||||
for log_file in \
|
||||
"$PG_DATA_ROOT/log/postgresql.log" "$PG_DATA_ROOT/log/postgres-service.log" \
|
||||
"$LIVE_DATA_ROOT/log/postgresql.log" "$LIVE_DATA_ROOT/log/liverecorder.log"; do
|
||||
"$LIVE_DATA_ROOT/log/liverecorder.log"; do
|
||||
if [ -f "$log_file" ]; then
|
||||
printf '%s\n' "--- $log_file ---" >&2
|
||||
tail -n 160 "$log_file" >&2 || true
|
||||
@@ -77,6 +83,12 @@ tar -xzf "$LIVE_PACKAGE" -C "$LIVE_PACKAGE_ROOT"
|
||||
tar -xzf "$LIVE_PACKAGE_ROOT/app.tgz" -C "$LIVE_APP_ROOT"
|
||||
rm -f "$LIVE_PACKAGE_ROOT/app.tgz"
|
||||
|
||||
test ! -e "$LIVE_APP_ROOT/runtime/usr/lib/postgresql"
|
||||
test ! -e "$LIVE_APP_ROOT/runtime/usr/share/postgresql"
|
||||
test ! -e "$LIVE_APP_ROOT/runtime/lib/libLLVM-14.so.1"
|
||||
test ! -e "$LIVE_APP_ROOT/runtime/lib/libz3.so.4"
|
||||
test ! -e "$LIVE_APP_ROOT/runtime/bin/node"
|
||||
|
||||
TRIM_PKGVAR="$PG_DATA_ROOT" \
|
||||
wizard_postgres_admin_password="$PG_ADMIN_PASSWORD" \
|
||||
wizard_postgres_admin_password_confirm="$PG_ADMIN_PASSWORD" \
|
||||
@@ -100,16 +112,13 @@ curl -fsS "$BASE_URL/health/ready" | grep -q '"status":"ready"'
|
||||
curl -fsS "$BASE_URL/" | grep -q '<div id="app"></div>'
|
||||
|
||||
CREDENTIALS="$LIVE_DATA_ROOT/postgres-client.conf"
|
||||
MARKER="$LIVE_DATA_ROOT/postgres-migration/shared-database.active"
|
||||
test -s "$CREDENTIALS"
|
||||
test "$(stat -c '%a' "$CREDENTIALS")" = "600"
|
||||
grep -q '^host=127\.0\.0\.1$' "$CREDENTIALS"
|
||||
grep -q "^port=$PG_PORT$" "$CREDENTIALS"
|
||||
grep -q '^database=appdb_liverecorder_' "$CREDENTIALS"
|
||||
grep -q '^username=app_liverecorder_' "$CREDENTIALS"
|
||||
test -s "$MARKER"
|
||||
grep -q '^fresh_install_at=' "$MARKER"
|
||||
test ! -f "$LIVE_DATA_ROOT/postgres/PG_VERSION"
|
||||
test ! -e "$LIVE_DATA_ROOT/postgres"
|
||||
test ! -e "$LIVE_DATA_ROOT/postgres-enrollment-token.seed"
|
||||
|
||||
login_response=$(curl -fsS -H 'Content-Type: application/json' \
|
||||
@@ -120,13 +129,21 @@ test -n "$token"
|
||||
settings_response=$(curl -fsS -H "Authorization: Bearer $token" "$BASE_URL/api/settings")
|
||||
expected_record_root="$LIVE_VOLUME_ROOT/@appshare/liverecorder/records"
|
||||
printf '%s' "$settings_response" | grep -Fq "\"outputRoot\":\"$expected_record_root\""
|
||||
session_page_response=$(curl -fsS -H "Authorization: Bearer $token" \
|
||||
"$BASE_URL/api/record-sessions/page?skip=0&take=12&state=all")
|
||||
printf '%s' "$session_page_response" | grep -q '"items":\[\]'
|
||||
printf '%s' "$session_page_response" | grep -q '"totalCount":0'
|
||||
printf '%s' "$session_page_response" | grep -q '"take":12'
|
||||
filtered_session_page_response=$(curl -fsS -H "Authorization: Bearer $token" \
|
||||
"$BASE_URL/api/record-sessions/page?skip=0&take=12&state=active&search=needle")
|
||||
printf '%s' "$filtered_session_page_response" | grep -q '"totalCount":0'
|
||||
|
||||
runtime_libs="$LIVE_APP_ROOT/runtime/lib:$LIVE_APP_ROOT/runtime/usr/lib/postgresql/15/lib"
|
||||
runtime_libs="$LIVE_APP_ROOT/runtime/lib"
|
||||
ca_bundle="$LIVE_APP_ROOT/runtime/etc/ssl/certs/ca-certificates.crt"
|
||||
node_bin="$LIVE_APP_ROOT/runtime/bin/node"
|
||||
node_bin="$NODEJS_ROOT/bin/node"
|
||||
curl_bin="$LIVE_APP_ROOT/runtime/bin/curl"
|
||||
signer="$LIVE_APP_ROOT/server/Platforms/Douyin/Signing/sign-xbogus.js"
|
||||
LD_LIBRARY_PATH="$runtime_libs" "$node_bin" --version | grep -q '^v22\.18\.0$'
|
||||
LD_LIBRARY_PATH="$runtime_libs" "$node_bin" --version | grep -Eq '^v[0-9]+\.'
|
||||
signature=$(LD_LIBRARY_PATH="$runtime_libs" "$node_bin" "$signer" \
|
||||
'aid=6383&device_platform=web&room_id=1' 'Mozilla/5.0 LiveRecorder fnOS shared-stack smoke test')
|
||||
test -n "$signature"
|
||||
@@ -145,4 +162,16 @@ run_live_control start
|
||||
run_live_control status
|
||||
curl -fsS "$BASE_URL/health/ready" | grep -q '"status":"ready"'
|
||||
|
||||
run_live_control stop
|
||||
run_postgres_control stop
|
||||
rm -f "$CREDENTIALS" "$LIVE_DATA_ROOT/postgres-enrollment-token.seed"
|
||||
mkdir -p "$LIVE_DATA_ROOT/postgres"
|
||||
printf '15\n' >"$LIVE_DATA_ROOT/postgres/PG_VERSION"
|
||||
if run_live_control start; then
|
||||
printf '%s\n' 'Live Recorder unexpectedly fell back to a legacy private PostgreSQL database' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -q '无法连接 PostgreSQL 共享服务或取得数据库凭据,应用不会启动' \
|
||||
"$LIVE_DATA_ROOT/log/liverecorder.log"
|
||||
|
||||
printf '%s\n' 'fnOS shared-stack smoke test passed: independent PostgreSQL stayed running, Live Recorder enrolled, persisted credentials and restarted without Docker'
|
||||
|
||||
Reference in New Issue
Block a user