forked from mtusi2026/mtusi2026lab7
лр7: Docker-прогон, evidence, исправления
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
|
||||
import subprocess
|
||||
|
||||
from common import EVIDENCE, ROOT
|
||||
|
||||
OUTPUT = EVIDENCE / "explain-history.txt"
|
||||
|
||||
|
||||
def main():
|
||||
sql = (ROOT / "student-tests" / "explain.sql").read_bytes()
|
||||
result = subprocess.run(
|
||||
["docker", "compose", "exec", "-T", "postgres",
|
||||
"psql", "-U", "messenger", "-d", "messenger", "-X", "-q", "-v", "ON_ERROR_STOP=1"],
|
||||
cwd=ROOT, input=sql, capture_output=True, check=False,
|
||||
)
|
||||
OUTPUT.parent.mkdir(exist_ok=True)
|
||||
OUTPUT.write_bytes(result.stdout + result.stderr)
|
||||
if result.returncode != 0:
|
||||
print(result.stderr.decode("utf-8", "replace"))
|
||||
raise SystemExit("FAIL: psql returned an error, see output above")
|
||||
for line in result.stdout.decode("utf-8", "replace").splitlines():
|
||||
if line.startswith("===") or "Buffers" in line or "Execution Time" in line or " Scan " in line:
|
||||
print(line)
|
||||
print(f"PASS: full plans saved to {OUTPUT.relative_to(ROOT)}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user