Skip to content

Commit 48b752f

Browse files
committed
chore: remove deno.lock files and improve SQL queue handling in tests (#352)
# Remove deno.lock files and improve test cleanup This PR removes the `deno.lock` files from the `cpu_intensive` and `max_concurrency` edge worker functions, which helps prevent dependency version conflicts. It also improves the cleanup process in the end-to-end tests: - Replaces try/catch blocks with conditional queue drops using SQL EXISTS checks - Adds cleanup for stale worker entries in the `pgflow.workers` table - Ensures proper queue recreation sequence in the performance test These changes make the tests more reliable by ensuring a clean environment before each test run.
1 parent 72e199c commit 48b752f

File tree

4 files changed

+16
-79
lines changed

4 files changed

+16
-79
lines changed

pkgs/edge-worker/supabase/functions/cpu_intensive/deno.lock

Lines changed: 0 additions & 38 deletions
This file was deleted.

pkgs/edge-worker/supabase/functions/max_concurrency/deno.lock

Lines changed: 0 additions & 34 deletions
This file was deleted.

pkgs/edge-worker/tests/e2e/performance.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,17 @@ Deno.test(
2020
await withSql(async (sql) => {
2121
await sql`CREATE SEQUENCE IF NOT EXISTS test_seq`;
2222
await sql`ALTER SEQUENCE test_seq RESTART WITH 1`;
23+
await sql`
24+
SELECT * FROM pgmq.drop_queue(${WORKER_NAME})
25+
WHERE EXISTS (
26+
SELECT 1 FROM pgmq.list_queues() WHERE queue_name = ${WORKER_NAME}
27+
)
28+
`;
2329
await sql`SELECT pgmq.create(${WORKER_NAME})`;
24-
await sql`SELECT pgmq.drop_queue(${WORKER_NAME})`;
25-
await sql`SELECT pgmq.create(${WORKER_NAME})`;
30+
await sql`
31+
DELETE FROM pgflow.workers
32+
WHERE last_heartbeat_at < NOW() - INTERVAL '6 seconds'
33+
`;
2634
await startWorker(WORKER_NAME);
2735
await waitFor(
2836
async () => {

pkgs/edge-worker/tests/e2e/restarts.test.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ Deno.test(
2424
await withSql(async (sql) => {
2525
await sql`CREATE SEQUENCE IF NOT EXISTS test_seq`;
2626
await sql`ALTER SEQUENCE test_seq RESTART WITH 1`;
27-
try {
28-
await sql`SELECT pgmq.drop_queue(${WORKER_NAME})`;
29-
} catch {
30-
// ignore
31-
}
27+
await sql`
28+
SELECT * FROM pgmq.drop_queue(${WORKER_NAME})
29+
WHERE EXISTS (
30+
SELECT 1 FROM pgmq.list_queues() WHERE queue_name = ${WORKER_NAME}
31+
)
32+
`;
3233
await sql`SELECT pgmq.create(${WORKER_NAME})`;
3334
await sql`
3435
DELETE FROM pgflow.workers

0 commit comments

Comments
 (0)