test: add PostgreSQL migration integration coverage
CI / verify (pull_request) Successful in 19s
CI / infrastructure-smoke (pull_request) Successful in 21s
CI / migration-smoke (pull_request) Failing after 16s

This commit is contained in:
ekklesia
2026-07-21 09:37:15 -05:00
parent b38f85f438
commit 831a48187c
16 changed files with 1690 additions and 96 deletions
+70 -14
View File
@@ -21,6 +21,17 @@ interface PackageDocument {
scripts?: Record<string, string>;
}
interface WorkflowJob {
needs?: string;
steps?: WorkflowStep[];
"timeout-minutes"?: number;
}
interface WorkflowStep {
run?: string;
uses?: string;
}
interface TurboDocument {
tasks?: Record<string, unknown>;
}
@@ -64,19 +75,28 @@ describe("development infrastructure", () => {
"utf8",
);
const workflow = parse(source) as {
jobs?: {
"infrastructure-smoke"?: { steps?: Array<{ run?: string }> };
verify?: { steps?: Array<{ run?: string }> };
};
jobs?: Record<string, WorkflowJob>;
name?: string;
};
const commands = workflow.jobs?.verify?.steps?.flatMap((step) => step.run ?? []) ?? [];
const infrastructureCommands =
workflow.jobs?.["infrastructure-smoke"]?.steps?.flatMap((step) => step.run ?? []) ?? [];
const verify = workflow.jobs?.verify;
const infrastructure = workflow.jobs?.["infrastructure-smoke"];
const migration = workflow.jobs?.["migration-smoke"];
const commands = verify?.steps?.flatMap((step) => step.run ?? []) ?? [];
const infrastructureCommands = infrastructure?.steps?.flatMap((step) => step.run ?? []) ?? [];
const migrationCommands = migration?.steps?.flatMap((step) => step.run ?? []) ?? [];
const verifyActions = verify?.steps?.flatMap((step) => step.uses ?? []) ?? [];
const migrationActions = migration?.steps?.flatMap((step) => step.uses ?? []) ?? [];
expect(workflow.jobs?.verify).toBeDefined();
expect(workflow.name).toBe("CI");
expect(verify).toBeDefined();
expect(commands).toContain("pnpm install --frozen-lockfile");
expect(commands).toContain("pnpm ci:verify");
expect(infrastructureCommands).toContain("bash scripts/smoke-infrastructure.sh");
expect(migration?.needs).toBe("verify");
expect(migration?.["timeout-minutes"]).toBe(15);
expect(migrationActions).toEqual(verifyActions);
expect(migrationCommands).toContain("pnpm install --frozen-lockfile");
expect(migrationCommands).toContain("pnpm test:migrations:integration");
});
it("routes containerized S3 smoke checks through the isolated Compose network", async () => {
@@ -84,18 +104,54 @@ describe("development infrastructure", () => {
path.join(repositoryRoot, "scripts", "smoke-infrastructure.sh"),
"utf8",
);
const helper = await readFile(
path.join(repositoryRoot, "scripts", "lib", "compose-job-network.sh"),
"utf8",
);
expect(source).toContain("[[ -f /.dockerenv ]]");
expect(source).toContain(`object_storage_container="$("\${compose[@]}" ps -q object-storage)"`);
expect(source).toContain("docker inspect");
expect(source).toContain('docker network connect "$compose_network" "$current_container"');
expect(source).toContain('docker network disconnect "$compose_network" "$current_container"');
expect(source).toContain('source "$repository_root/scripts/lib/compose-job-network.sh"');
expect(source).toContain(`compose_job_network_connect object-storage "\${compose[@]}"`);
expect(source).toContain('s3_endpoint="http://object-storage:8333"');
expect(source).toContain('s3_endpoint="http://127.0.0.1:$s3_port"');
expect(source).not.toContain("0.0.0.0:${S3_PORT");
expect(source.indexOf("docker network disconnect")).toBeLessThan(
expect(source.indexOf("compose_job_network_disconnect")).toBeLessThan(
source.indexOf(`"\${compose[@]}" down`),
);
expect(helper).toContain("[[ ! -f /.dockerenv ]]");
expect(helper).toContain('"$@" ps -q "$service"');
expect(helper).toContain("docker inspect");
expect(helper).toContain("docker network connect");
expect(helper).toContain("docker network disconnect");
});
it("provisions isolated PostgreSQL for the live migration suite", async () => {
const packageSource = await readFile(path.join(repositoryRoot, "package.json"), "utf8");
const packageDocument = JSON.parse(packageSource) as PackageDocument;
const source = await readFile(
path.join(repositoryRoot, "scripts", "test-migrations-integration.sh"),
"utf8",
);
expect(packageDocument.scripts?.["test:migrations:integration"]).toBe(
"bash scripts/test-migrations-integration.sh",
);
expect(source).toContain('source "$repository_root/scripts/lib/compose-job-network.sh"');
expect(source).toContain('export POSTGRES_PORT="0"');
expect(source).toContain("up --detach --wait --wait-timeout 120 postgres");
expect(source).toContain(`compose_job_network_connect postgres "\${compose[@]}"`);
expect(source).toContain('database_host="postgres"');
expect(source).toContain('database_port="5432"');
expect(source).toContain('database_host="127.0.0.1"');
expect(source).toContain(
'EKKLESIA_MIGRATION_TEST_DATABASE_URL="postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$database_host:$database_port/$POSTGRES_DB"',
);
expect(source).toContain("--config vitest.migrations.integration.config.ts");
expect(source).not.toContain("0.0.0.0");
expect(source).not.toContain('compose[@]}" logs');
expect(source.indexOf("compose_job_network_disconnect")).toBeLessThan(
source.indexOf("down --volumes --remove-orphans"),
);
});
it("includes every official platform layer in the workspace", async () => {