Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions scripts/billing-pg-drill.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env bash
# apply_ls_event 실행 검증 드릴(분리 검수 F6) — Docker 불필요.
# Homebrew postgresql의 initdb/pg_ctl로 임시 인스턴스를 띄우고, 실 마이그레이션을 적용해
# test/billing-pg-integration.test.mjs(경계표·권한·동시성)를 돌린 뒤 흔적 없이 정리한다.
# 실 Postgres 드릴(분리 검수 F6) — Docker 불필요. Homebrew postgresql의 initdb/pg_ctl로 임시 인스턴스를 띄우고,
# 배포될 마이그레이션 파일을 그대로 적용해 pg 통합 테스트를 돌린 뒤 흔적 없이 정리한다.
# 대상 파일(순차·파일마다 별도 DB — node --test는 파일을 병렬 프로세스로 돌리므로 한 DB를 공유하면 경합한다):
# test/billing-pg-integration.test.mjs (apply_ls_event·is_pro 만료·대사 쿨다운·동시성)
# test/msgr-pg-integration.test.mjs (팀 메신저 RLS·역할 경계표·좌석·결재 미러·Realtime 방송)
# 요구: psql·initdb·pg_ctl (예: brew install postgresql@14). 포트 충돌 시 ARGO_PG_DRILL_PORT 지정.
# 대안: supabase start 후 ARGO_PG_TEST_URL을 직접 지정해 node --test test/billing-pg-integration.test.mjs
# 대안: supabase start 후 ARGO_PG_TEST_URL을 직접 지정해 node --test test/<파일>
set -euo pipefail
cd "$(dirname "$0")/.."

Expand All @@ -20,8 +22,14 @@ trap cleanup EXIT
echo "[drill] 임시 Postgres 기동 (port $PORT, $DIR)"
initdb -D "$DIR/data" -A trust -U postgres >/dev/null
pg_ctl -D "$DIR/data" -o "-p $PORT -k $DIR -c listen_addresses=127.0.0.1" -l "$DIR/pg.log" start >/dev/null
psql "postgresql://postgres@127.0.0.1:$PORT/postgres" -X -q -c 'create database argo_billing_drill'

ARGO_PG_TEST_URL="postgresql://postgres@127.0.0.1:$PORT/argo_billing_drill" \
node --test test/billing-pg-integration.test.mjs
FILES=("${@:-}")
if [ -z "${FILES[0]}" ]; then FILES=(test/billing-pg-integration.test.mjs test/msgr-pg-integration.test.mjs); fi
i=0
for f in "${FILES[@]}"; do
i=$((i + 1)); db="argo_drill_$i"
psql "postgresql://postgres@127.0.0.1:$PORT/postgres" -X -q -c "create database $db"
echo "[drill] $f → $db"
ARGO_PG_TEST_URL="postgresql://postgres@127.0.0.1:$PORT/$db" node --test "$f"
done
echo "[drill] 통과 — 임시 인스턴스 정리"
Loading
Loading