Separate database connections from file-backed host information and document handoff
Verify databases and deploy Aster VM / verify-and-deploy (push) Successful in 7m25s

This commit is contained in:
2026-10-19 02:07:36 +08:00
parent 18cd24a203
commit e52d2e1e4b
50 changed files with 935 additions and 442 deletions
+19 -11
View File
@@ -19,7 +19,6 @@ def run(*args, env):
def main():
env = os.environ.copy()
env.pop("DATABASE_URL", None)
run("cargo", "build", "--workspace", "--locked", env=env)
# Cargo may use a configured CARGO_TARGET_DIR; discover the actual binaries.
metadata = json.loads(run("cargo", "metadata", "--no-deps", "--format-version", "1", env=env))
@@ -27,18 +26,23 @@ def main():
cli = str(binary_dir / "cli")
server = str(binary_dir / "server")
with tempfile.TemporaryDirectory(prefix="aster-smoke-") as directory:
env["ASTER_STATE_DIR"] = str(Path(directory) / "host-info")
env["SQLITE_PATH"] = str(Path(directory) / "nested" / "aster.db")
# This must succeed even when an explicit database URL is invalid.
isolated_env = {**env, "DATABASE_URL": "invalid-database-url"}
bootstrap = run(cli, "bootstrap", env=isolated_env)
# Neither executable may use database settings for basic VM information.
env["DATABASE_URL"] = "invalid-database-url"
bootstrap = run(cli, "bootstrap", env=env)
assert "runtime=EndorObject type_system=disabled" in bootstrap, bootstrap
assert "objects_distinct=true heap_objects=2" in bootstrap, bootstrap
assert "released heap_objects=0" in bootstrap, bootstrap
assert not Path(env["SQLITE_PATH"]).exists(), "bootstrap must not open storage"
assert "sqlite" in run(cli, "metadata", "put", "smoke", "持久化成功", env=env)
assert run(cli, "metadata", "get", "smoke", env=env) == "持久化成功"
failed = subprocess.run([cli, "metadata", "get", "smoke"], cwd=ROOT, env=isolated_env, capture_output=True)
assert failed.returncode != 0, "invalid explicit DB config must fail"
assert "stored (file)" in run(cli, "metadata", "put", "project.note", "日本語・中文・😀", env=env)
assert run(cli, "metadata", "get", "project.note", env=env) == "日本語・中文・😀"
legacy = json.dumps([{"key": "project.note", "value": "old"},
{"key": "legacy.note", "value": "preserved"}])
subprocess.run([cli, "metadata", "import"], input=legacy, cwd=ROOT, env=env,
check=True, text=True, capture_output=True)
assert run(cli, "metadata", "get", "project.note", env=env) == "日本語・中文・😀"
assert run(cli, "metadata", "get", "legacy.note", env=env) == "preserved"
assert not Path(env["SQLITE_PATH"]).exists(), "CLI must not open a database"
with socket.socket() as sock:
sock.bind(("127.0.0.1", 0))
@@ -58,7 +62,7 @@ def main():
log.seek(0)
raise AssertionError(f"server did not become healthy: {log.read()}")
time.sleep(0.1)
assert health == {"status": "ok", "storage": "sqlite"}, health
assert health == {"status": "ok"}, health
for _ in range(2):
with urllib.request.urlopen(f"http://127.0.0.1:{port}/bootstrap", timeout=2) as response:
info = json.load(response)
@@ -72,8 +76,12 @@ def main():
process.wait()
raise AssertionError("server did not shut down gracefully")
assert process.returncode == 0, process.returncode
assert not Path(env["SQLITE_PATH"]).exists(), "Server must not open a database"
assert run(cli, "metadata", "get", "host.version", env=env) == "0.1.0"
print("PASS: bootstrap isolation; SQLite persistence; config failure; HTTP health/bootstrap; SIGTERM shutdown")
record = json.loads((Path(env["ASTER_STATE_DIR"]) / "host.version.json").read_text(encoding="utf-8"))
assert record == {"format_version": 1, "key": "host.version", "value": "0.1.0"}
assert run(cli, "metadata", "get", "project.note", env=env) == "日本語・中文・😀"
print("PASS: no implicit database access; file metadata persistence; HTTP health/bootstrap; SIGTERM shutdown")
if __name__ == "__main__":