Add pinned CPU engine dependencies, retained interrupted-response history, provider admission, offline evaluation and isolated browser tooling. Record Phase 2 acceptance and Phase 3/4 preparation, bounded paid-test accounting and interruption incident findings. Human interruption acceptance, paired OpenAI evaluation and rollback remain pending.
54 lines
2.8 KiB
Python
54 lines
2.8 KiB
Python
"""Provider-free acceptance on a fresh RAM-backed PostgreSQL/pgvector container."""
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from uuid import uuid4
|
|
|
|
ROOT = Path(__file__).resolve().parents[3]
|
|
IMAGE = 'sha256:f1447071e6c8449dcf4056aa0994c81d3566ce5ee232de36b04dc25696a116dd'
|
|
name = 'rag-phase2-acceptance-' + uuid4().hex
|
|
container = None
|
|
try:
|
|
# No published port, inherited .env, provider key, bind mount or durable volume.
|
|
container = subprocess.check_output([
|
|
'docker', 'run', '-d', '--rm', '--name', name,
|
|
'--label', 'rag.phase2.disposable=true', '--network', 'rag-local-s2s-test_default',
|
|
'--memory', '512m', '--memory-swap', '512m', '--cpus', '2', '--pids-limit', '128',
|
|
'--tmpfs', '/var/lib/postgresql/data:rw,nosuid,size=384m',
|
|
'-e', 'POSTGRES_DB=phase2_acceptance_local_s2s_test', '-e', 'POSTGRES_USER=phase2_test',
|
|
'-e', 'POSTGRES_PASSWORD=disposable-test-only', IMAGE,
|
|
], text=True).strip()
|
|
row = json.loads(subprocess.check_output(['docker', 'inspect', container]))[0]
|
|
assert row['Image'] == IMAGE and row['Name'] == '/' + name
|
|
assert not row['HostConfig']['PortBindings']
|
|
assert all(m['Type'] != 'volume' for m in row['Mounts'])
|
|
for _ in range(30):
|
|
ready = subprocess.run(['docker', 'exec', container, 'pg_isready', '-h', '127.0.0.1', '-U', 'phase2_test',
|
|
'-d', 'phase2_acceptance_local_s2s_test'], capture_output=True)
|
|
if ready.returncode == 0:
|
|
break
|
|
time.sleep(1)
|
|
else:
|
|
raise RuntimeError('Disposable PostgreSQL startup deadline')
|
|
ip = next(v['IPAddress'] for v in row['NetworkSettings']['Networks'].values() if v['IPAddress'])
|
|
env = os.environ.copy()
|
|
env['TEST_DATABASE_URL'] = f'postgresql+psycopg://phase2_test:disposable-test-only@{ip}:5432/phase2_acceptance_local_s2s_test'
|
|
env['TRUSTED_HOSTS'] = '["localhost:8000","127.0.0.1:8000"]'
|
|
tests = sys.argv[1:] or ['tests/integration/test_local_s2s_phase2.py',
|
|
'tests/integration/test_phase2_postgres.py']
|
|
print(json.dumps(dict(container=container, image=IMAGE, storage='tmpfs',
|
|
database='phase2_acceptance_local_s2s_test', require_postgres=True)), flush=True)
|
|
result = subprocess.run([str(ROOT/'.venv/bin/python'), '-m', 'pytest', *tests,
|
|
'-m', 'postgres', '--require-postgres', '-q', '--tb=short', '-p', 'no:cacheprovider'],
|
|
cwd=ROOT, env=env, timeout=600)
|
|
finally:
|
|
if container:
|
|
subprocess.run(['docker', 'stop', '--time', '5', container],
|
|
check=True, stdout=subprocess.DEVNULL)
|
|
print('Disposable acceptance container stopped and auto-removed.', flush=True)
|
|
if result.returncode:
|
|
raise SystemExit(result.returncode)
|