| 6 | // source from the API. Avoids hardcoding PORT+3 / PORT+4 offsets which would |
| 7 | // break if discovery picks the "test" sample instance instead of "prod". |
| 8 | export async function getInstancePgPort( |
| 9 | env: TestEnv & { api: BytebaseApiClient }, |
| 10 | ): Promise<string> { |
| 11 | const instance = await env.api.getInstance(env.instance); |
| 12 | const port = instance.dataSources?.[0]?.port; |
| 13 | if (!port) { |
| 14 | throw new Error(`Instance ${env.instance} has no data source port`); |
| 15 | } |
| 16 | return port; |
| 17 | } |
| 18 | |
| 19 | // Execute SQL via psql over the Unix socket on the sample Postgres instance. |
| 20 | // Used for DDL/DML setup and teardown — Bytebase's query API is read-only. |