8월 7일까지 워킹트리에만 남아 있던 미커밋 작업을 커밋한다. 여러 사본 폴더(worktree·clone)에 흩어져 있던 중간 스냅샷을 정리하기 전에 원본을 git 이력으로 고정하는 것이 목적이다. - contracts/routes/services: measurement, outcome_trajectory, rupture_repair, deliberate_practice, calibration_transfer, supervision_research, multimodal_alliance, continuous_improvement 계열 신규 모듈과 테스트 - infra/db/init: 07~16 마이그레이션(측정 기반~calibration transfer 실행) - apps/web: 세션 리뷰 카드·관리 화면·E2E 스펙 추가 - docs/ops: G0~G8 라이브 통합·배포·롤백 증거 문서와 evidence JSON/PNG - scripts: smoke·ledger·릴리스 에이전트·NAS 프리뷰 운영 스크립트 engine.public 로그 .bak과 apps/web/test-results 산출물은 커밋에서 제외했다.
66 lines
2.4 KiB
Python
66 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
import shutil
|
|
import subprocess
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT = Path(__file__).with_name("cutover-recovered-public-db.ps1")
|
|
|
|
|
|
class CutoverRecoveredPublicDatabaseTest(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.source = SCRIPT.read_text(encoding="utf-8")
|
|
|
|
def test_requires_explicit_confirmation_and_disables_watchdog_first(self) -> None:
|
|
self.assertIn("if (-not $ConfirmCutover)", self.source)
|
|
disable = self.source.index("Disable-ScheduledTask")
|
|
stop = self.source.index("@('stop', $activeName)")
|
|
self.assertLess(disable, stop)
|
|
|
|
def test_preserves_both_old_and_failed_containers(self) -> None:
|
|
self.assertIn("vignette-dev-db-pre-recovery-$stamp", self.source)
|
|
self.assertIn("vignette-recovered-cutover-failed-$stamp", self.source)
|
|
self.assertNotRegex(
|
|
self.source,
|
|
r"(?im)^\s*(?:&\s*)?docker(?:\.exe)?\s+(?:container\s+)?rm\b",
|
|
)
|
|
self.assertNotRegex(
|
|
self.source,
|
|
r"(?im)^\s*(?:&\s*)?docker(?:\.exe)?\s+volume\s+rm\b",
|
|
)
|
|
|
|
def test_gates_public_restart_on_exact_recovered_counts(self) -> None:
|
|
counts = self.source.index("'84|30|705|0|0'")
|
|
restart = self.source.index("Restart-PublicApi", counts)
|
|
self.assertLess(counts, restart)
|
|
self.assertIn("openapi_paths", self.source)
|
|
|
|
def test_recovered_database_survives_docker_restart(self) -> None:
|
|
self.assertIn("'--restart', 'unless-stopped'", self.source)
|
|
|
|
def test_windows_powershell_51_parser_accepts_script(self) -> None:
|
|
powershell = shutil.which("powershell.exe")
|
|
if powershell is None:
|
|
self.skipTest("Windows PowerShell 5.1 is unavailable")
|
|
escaped = str(SCRIPT.resolve()).replace("'", "''")
|
|
command = (
|
|
"$tokens=$null; $errors=$null; "
|
|
"[System.Management.Automation.Language.Parser]::ParseFile("
|
|
f"'{escaped}', [ref]$tokens, [ref]$errors) | Out-Null; "
|
|
"if ($errors.Count -gt 0) { exit 1 }; exit 0"
|
|
)
|
|
completed = subprocess.run(
|
|
[powershell, "-NoProfile", "-Command", command],
|
|
check=False,
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
)
|
|
self.assertEqual(completed.returncode, 0, completed.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|