6a4a5f0cf7
gates / gates (push) Successful in 2s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
49 lines
2.6 KiB
Python
49 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Harness v4 (`09` §6.4 part 10): the pieces of the PostgreSQL conversion that run without Docker.
|
|
Run: python3 scripts/test_pg_conversion.py (exit 0 = all pass)."""
|
|
import importlib.util, os, sys
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, HERE)
|
|
spec = importlib.util.spec_from_file_location("ut", os.path.join(HERE, "upgrade-test.py"))
|
|
ut = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(ut)
|
|
import ladder
|
|
|
|
OLD = """services:
|
|
docmost-postgres:
|
|
image: postgres:16-alpine
|
|
volumes:
|
|
- docmost_postgres_data:/var/lib/postgresql/data
|
|
docmost-redis:
|
|
image: redis:7-alpine
|
|
volumes:
|
|
- docmost_redis_data:/data
|
|
"""
|
|
fails = []
|
|
def check(name, cond):
|
|
print((" ok " if cond else "FAIL ") + name)
|
|
if not cond:
|
|
fails.append(name)
|
|
|
|
new = ut.pg_mounts_for(OLD.replace("postgres:16-alpine", "postgres:18-alpine"))
|
|
check("18 moves the data mount to /var/lib/postgresql", "docmost_postgres_data:/var/lib/postgresql\n" in new)
|
|
check("18 leaves the redis mount alone", "docmost_redis_data:/data" in new)
|
|
check("16 keeps /var/lib/postgresql/data", ut.pg_mounts_for(OLD) == OLD)
|
|
check("back from 18 to 16 restores /data", ut.pg_mounts_for(new.replace("postgres:18-alpine", "postgres:16-alpine")) == OLD)
|
|
check("pg_conversion names the one moving service",
|
|
ut.pg_conversion({"a": "x:1", "db": "postgres:16-alpine"}, {"a": "x:2", "db": "postgres:18-alpine"}) ==
|
|
{"service": "db", "engine": "postgres", "from": 16, "to": 18})
|
|
check("within a major is no conversion", ut.pg_conversion({"db": "postgres:16-alpine"}, {"db": "postgres:16.4-alpine"}) is None)
|
|
check("pgvector's pg16 tag reads 16", ut.pg_major("pgvector/pgvector:pg16") == 16)
|
|
base = {"from": {"db": "postgres:16-alpine"}, "to": {"db": "postgres:18-alpine"}, "digest": {"db": "sha256:" + "a" * 64},
|
|
"verdict": "proven", "tested_at": "2026-09-25T20:00:00Z", "harness_version": 4, "evidence": "x",
|
|
"memory_peak_pct": 10.0, "marks": {"files_may_change": False, "needs_person": None, "memory_tight": False}}
|
|
check("an entry with a good mark is well-formed",
|
|
ladder.check_entry(dict(base, engine_conversion={"service": "db", "engine": "postgres", "from": 16, "to": 18})) == [])
|
|
check("a mark naming a service outside `to` is refused",
|
|
ladder.check_entry(dict(base, engine_conversion={"service": "web", "engine": "postgres", "from": 16, "to": 18})) != [])
|
|
check("a mark going DOWN is refused",
|
|
ladder.check_entry(dict(base, engine_conversion={"service": "db", "engine": "postgres", "from": 18, "to": 16})) != [])
|
|
print("pg conversion tests: %d failed" % len(fails))
|
|
sys.exit(1 if fails else 0)
|