/** * AI Software Factory — read the `seed-100k-v1` marker (written by * seed-100k.mjs into the `test_seeds` table) and print shell-exportable env * lines for the TASK-0135 k6 suites: * * K6_WORKSPACE_ID the seeded workspace (api-load / database-load / realtime) * K6_DB_ID the primary database id (database-load target) * K6_DATABASE_IDS all database ids (api-load record-list scenario) * K6_BIG_PAGE_ID the big-block page (api-load open scenario) * K6_PAGE_IDS comma-joined hub page ids (api-load tree/list scenarios) * * Usage (CI): source <(node tests/performance/extract-100k-env.mjs) * Usage (test): node tests/performance/extract-100k-env.mjs # prints the lines * * Exits 1 with a clear error if the marker is absent (run seed-100k.mjs first). * Needs DATABASE_URL (the repo's Prisma client is generated by `pnpm db:generate`). */ import { PrismaClient } from "@prisma/client"; const MARKER = "seed-100k-v1"; const prisma = new PrismaClient(); try { const rows = await prisma.$queryRaw`SELECT value FROM test_seeds WHERE key = ${MARKER}`; if (rows.length === 0) { console.error(`extract-100k-env: marker ${MARKER} not found in test_seeds — run seed-100k.mjs first.`); process.exit(1); } const m = rows[0].value; // `export K6_...=` so a `source <(...)` picks each up; values are single- // quoted (the ids are cuids / db_* / pg_* — no embedded quotes, but be safe). const q = (s) => `'${String(s).replace(/'/g, `'\''`)}'`; console.log(`export K6_WORKSPACE_ID=${q(m.workspaceId)}`); console.log(`export K6_DB_ID=${q(m.databaseId)}`); console.log(`export K6_DATABASE_IDS=${q((m.databaseIds || []).join(","))}`); console.log(`export K6_BIG_PAGE_ID=${q(m.bigPageId)}`); console.log(`export K6_PAGE_IDS=${q((m.pageIds || []).join(","))}`); console.error(`extract-100k-env: workspace=${m.workspaceId} db=${m.databaseId} pages=${(m.pageIds || []).length} records=${m.records}`); } finally { await prisma.$disconnect(); }