Skip to content

test: increase timeout #1873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"go-livepeer": "run-p \"go-livepeer:**\" --",
"go-livepeer:broadcaster": "bin/livepeer -broadcaster -datadir ./bin/broadcaster -orchAddr 127.0.0.1:3086 -rtmpAddr 0.0.0.0:3035 -httpAddr :3085 -cliAddr :3075 -v 6 -authWebhookUrl http://127.0.0.1:3004/api/stream/hook -orchWebhookUrl http://127.0.0.1:3004/api/orchestrator",
"go-livepeer:orchestrator": "bin/livepeer -orchestrator -datadir ./bin/orchestrator -transcoder -serviceAddr 127.0.0.1:3086 -cliAddr :3076 -v 6",
"test": "jest -i --silent \"${PWD}/src\"",
"test": "POSTGRES_CONNECT_TIMEOUT=120000 jest -i --silent \"${PWD}/src\"",
"test:dev": "jest \"${PWD}/src\" -i --silent --watch",
"test:build": "parcel build --no-autoinstall --no-minify --bundle-node-modules -t browser --out-dir ../dist-worker ../src/worker.js",
"coverage": "yarn run test --coverage",
Expand Down Expand Up @@ -184,5 +184,8 @@
"../../node_modules/next-mdx-remote/**/*",
"../../node_modules/livekit-server-sdk/**/*"
]
},
"jest": {
"testTimeout": 30000
}
}
4 changes: 2 additions & 2 deletions packages/api/src/store/db.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuid } from "uuid";
import { DB } from "./db";
import { DB, CONNECT_TIMEOUT } from "./db";
import Table from "./table";
import { Pool } from "pg";

Expand Down Expand Up @@ -43,7 +43,7 @@ describe("DB", () => {
await db.close();
const pool = new Pool({
connectionString: `postgresql://[email protected]/postgres`,
connectionTimeoutMillis: 5000,
connectionTimeoutMillis: CONNECT_TIMEOUT,
});
await pool.query("DROP DATABASE test");
await pool.end();
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/store/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ import ExperimentTable from "./experiment-table";
import AttestationTable from "./attestation-table";

// Should be configurable, perhaps?
const CONNECT_TIMEOUT = 5000;
export const CONNECT_TIMEOUT =
parseInt(process.env.POSTGRES_CONNECT_TIMEOUT) ?? 5000;

export interface PostgresParams {
postgresUrl: string;
Expand Down
4 changes: 3 additions & 1 deletion packages/api/src/test-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export async function clearDatabase(server: TestServer) {
const tables = Object.values(schema.components.schemas)
.map((s) => ("table" in s ? s.table : null))
.filter((t) => !!t);
await Promise.all(tables.map((t) => server.db.query(`TRUNCATE TABLE ${t}`)));
await Promise.all(
tables.map((t) => server?.db?.query(`TRUNCATE TABLE ${t}`))
);
}

export function verifyJwt(
Expand Down