forked from mtusi2026/mtusi2026lab3
33 lines
796 B
TypeScript
33 lines
796 B
TypeScript
import { resolve } from "node:path";
|
|
const root = resolve(import.meta.dir, "..");
|
|
const p = Bun.spawn(
|
|
[
|
|
resolve(root, "scripts/kube.sh"),
|
|
"exec",
|
|
"-i",
|
|
"deployment/postgres",
|
|
"--",
|
|
"psql",
|
|
"-X",
|
|
"-qAt",
|
|
"-U",
|
|
"messenger",
|
|
"-d",
|
|
"messenger",
|
|
"-v",
|
|
"ON_ERROR_STOP=1",
|
|
],
|
|
{ cwd: root, stdin: "pipe", stdout: "pipe", stderr: "pipe" },
|
|
);
|
|
p.stdin.write("SELECT 'stdin-boundary-ok';\n");
|
|
p.stdin.end();
|
|
const [out, err] = await Promise.all([
|
|
new Response(p.stdout).text(),
|
|
new Response(p.stderr).text(),
|
|
]);
|
|
if ((await p.exited) !== 0 || out.trim() !== "stdin-boundary-ok")
|
|
throw new Error("Kubernetes wrapper did not execute the stdin query");
|
|
console.log(
|
|
"PASS: SQL stdin reaches PostgreSQL through the real scoped wrapper",
|
|
);
|