Skip to content

Commit 7b4443a

Browse files
authored
test(webapp): stop streamBatchItems container tests timing out on cold start (#3900)
Fixes an intermittent `Test timed out in 30000ms` in the `streamBatchItems` suite. Not a logic hang — the 30s budget covers container setup, and each case boots its own per-test Redis container + a full `RunEngine`, so under CI Docker contention a cold boot can cross 30s (which is why the failure moved between tests). - New `containerTestWithIsolatedRedisNoClickhouse` fixture (Postgres clone + per-test Redis, no ClickHouse) — this suite never uses ClickHouse, but the old fixture's auto `resetClickhouse` forced a ClickHouse boot + migration onto the cold-start test. - Raised `testTimeout` 30s → 120s, matching the run-engine convention for this footprint.
1 parent 1c7e64a commit 7b4443a

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

apps/webapp/test/engine/streamBatchItems.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ vi.mock("~/services/platform.v3.server", async (importOriginal) => {
1616

1717
import { RunEngine } from "@internal/run-engine";
1818
import { setupAuthenticatedEnvironment } from "@internal/run-engine/tests";
19-
// Per-test redis (isolated): each test spins up its own RunEngine and runs batch work, which leaves
20-
// background activity on redis that outlives the test - sharing a worker redis across the 16 cases
21-
// here caused cross-test interference and 30s seal-timeout flakes. Same carve-out as the run-engine
22-
// batch tests.
23-
import { containerTestWithIsolatedRedis as containerTest } from "@internal/testcontainers";
19+
// Per-test redis isolation: each test runs its own RunEngine whose background work outlives the test
20+
// body. NoClickhouse because this suite never touches ClickHouse - skips the worker-scoped boot+migrate.
21+
import { containerTestWithIsolatedRedisNoClickhouse as containerTest } from "@internal/testcontainers";
2422
import { trace } from "@opentelemetry/api";
2523
import { PrismaClient } from "@trigger.dev/database";
2624
import { BatchId } from "@trigger.dev/core/v3/isomorphic";
@@ -33,7 +31,9 @@ import {
3331
} from "../../app/runEngine/services/streamBatchItems.server";
3432
import { ServiceValidationError } from "../../app/v3/services/baseService.server";
3533

36-
vi.setConfig({ testTimeout: 30_000 }); // 30 seconds timeout
34+
// 120s: a cold per-test container boot counts against the test's own timeout, and under CI Docker
35+
// contention 30s was too tight. Matches the run-engine convention for this footprint.
36+
vi.setConfig({ testTimeout: 120_000 });
3737

3838
describe("StreamBatchItemsService", () => {
3939
/**

internal-packages/testcontainers/src/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,25 @@ export const containerTestWithIsolatedRedis = test.extend<ContainerWithIsolatedR
536536
clickhouseClient: scopedClickhouseClient,
537537
});
538538

539+
type ContainerWithIsolatedRedisNoClickhouseContext = {
540+
network: StartedNetwork;
541+
postgresContainer: StartedPostgreSqlContainer;
542+
prisma: PrismaClient;
543+
redisContainer: StartedRedisContainer;
544+
redisOptions: RedisOptions;
545+
};
546+
547+
// Like containerTestWithIsolatedRedis (template-clone Postgres + per-test Redis) but with no
548+
// ClickHouse - for suites that touch Postgres + Redis but never ClickHouse, avoiding its boot+migrate.
549+
export const containerTestWithIsolatedRedisNoClickhouse =
550+
test.extend<ContainerWithIsolatedRedisNoClickhouseContext>({
551+
network,
552+
postgresContainer: clonedPostgresContainer,
553+
prisma: prismaFromContainer,
554+
redisContainer,
555+
redisOptions,
556+
});
557+
539558
// For tests that exercise the Postgres -> ClickHouse logical-replication pipeline (WAL slots,
540559
// publications, REPLICA IDENTITY). These need a dedicated Postgres per test - the worker-scoped +
541560
// template-clone model used by containerTest doesn't carry logical replication across cloned dbs.

0 commit comments

Comments
 (0)