Migrate PostgreSQL before the identity probe in the real combo
Why: identity ensure no longer creates the schema, so the probe has to follow a real serve that applies migrations. Evidence: SELF python3 -m py_compile tests/test_svc_realcombo.py. GATE run 2663 job 3839 failed on the previous head with identity table missing. Impact: the PostgreSQL check still passes the DSN only through the environment, after serve has migrated. Refs: #485 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,7 +21,9 @@ import shutil
|
||||
import sqlite3
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
import unittest
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
@@ -219,10 +221,40 @@ class RealComboTests(tsr.SvcAutoRecoverTests):
|
||||
命令行);错 id fail-closed。"""
|
||||
rdm_bin = Path(REAL_RDM_BIN).resolve()
|
||||
data = self.root / "pgdata"
|
||||
data.mkdir()
|
||||
plugins = data / "plugins"
|
||||
plugins.mkdir(parents=True)
|
||||
env = dict(os.environ)
|
||||
env["AGENT_SYSTEM_DSN"] = os.environ["AGENT_PG_TEST_DSN"]
|
||||
env["RDM_DISABLE_EXEC_TOOLS"] = "1"
|
||||
env.pop("SVC_STUB_TRACE", None)
|
||||
# 身份命令不建库、不迁移。先让 serve 把库迁到当前 schema,再 ensure/verify。
|
||||
port = 9475
|
||||
log = self.root / "pg-serve.log"
|
||||
serve = subprocess.Popen(
|
||||
[str(rdm_bin), "serve", "--addr", "127.0.0.1:%d" % port,
|
||||
"--data", str(data), "--plugins", str(plugins), "--auth", "auto"],
|
||||
env=env, stdout=log.open("w"), stderr=subprocess.STDOUT)
|
||||
try:
|
||||
up = False
|
||||
for _ in range(50):
|
||||
if serve.poll() is not None:
|
||||
break
|
||||
try:
|
||||
urllib.request.urlopen("http://127.0.0.1:%d/" % port, timeout=1).close()
|
||||
up = True
|
||||
break
|
||||
except urllib.error.HTTPError:
|
||||
up = True
|
||||
break
|
||||
except OSError:
|
||||
time.sleep(0.1)
|
||||
self.assertTrue(up, "serve 未完成迁移:\n%s" % log.read_text(errors="replace")[-1500:])
|
||||
finally:
|
||||
serve.terminate()
|
||||
try:
|
||||
serve.wait(timeout=5)
|
||||
except subprocess.TimeoutExpired:
|
||||
serve.kill()
|
||||
iid = "svc-realcombo-pg-%d" % os.getpid()
|
||||
run = lambda *a: subprocess.run(
|
||||
[str(rdm_bin), "identity", *a, "--instance-id", iid,
|
||||
|
||||
Reference in New Issue
Block a user