Skip to content

Commit c327f71

Browse files
committed
test(webapp): stop streamBatchItems container tests timing out on cold start
The streamBatchItems suite was intermittently failing with a 30s test timeout. The 30s budget covers container-fixture setup, and each of the 16 cases boots its own per-test Redis container and spins up a full RunEngine; a cold container boot counts against the test's own timeout, so under CI Docker contention whichever test booted while Docker was busiest could exceed 30s. It is not a product-logic hang. Two changes: - Add a containerTestWithIsolatedRedisNoClickhouse fixture (Postgres template-clone + per-test Redis, no ClickHouse) and use it here. These tests never touch ClickHouse, yet the previous fixture's auto resetClickhouse forced a ClickHouse boot + full migration onto the cold-start test. - Raise the suite testTimeout from 30s to 120s, matching the run-engine package convention for tests of this footprint (RunEngine + per-test container).
1 parent f5f29ce commit c327f71

2 files changed

Lines changed: 31 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import { setupAuthenticatedEnvironment } from "@internal/run-engine/tests";
1919
// Per-test redis (isolated): each test spins up its own RunEngine and runs batch work, which leaves
2020
// background activity on redis that outlives the test - sharing a worker redis across the 16 cases
2121
// 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";
22+
// batch tests. The NoClickhouse variant skips the worker-scoped ClickHouse boot+migrate (these tests
23+
// never touch ClickHouse), which the cold-start test would otherwise pay inside its test timeout.
24+
import { containerTestWithIsolatedRedisNoClickhouse as containerTest } from "@internal/testcontainers";
2425
import { trace } from "@opentelemetry/api";
2526
import { PrismaClient } from "@trigger.dev/database";
2627
import { BatchId } from "@trigger.dev/core/v3/isomorphic";
@@ -33,7 +34,12 @@ import {
3334
} from "../../app/runEngine/services/streamBatchItems.server";
3435
import { ServiceValidationError } from "../../app/v3/services/baseService.server";
3536

36-
vi.setConfig({ testTimeout: 30_000 }); // 30 seconds timeout
37+
// 120s (not 30s): each of the 16 cases here boots its own per-test Redis container and spins up a
38+
// full RunEngine, and a cold container boot counts against the test's own timeout. Under CI Docker
39+
// contention that boot can take tens of seconds, so 30s was too tight and the flake landed on
40+
// whichever test happened to boot while Docker was busiest. 120s matches the run-engine package
41+
// convention for tests of this footprint (RunEngine + per-test container).
42+
vi.setConfig({ testTimeout: 120_000 });
3743

3844
describe("StreamBatchItemsService", () => {
3945
/**

internal-packages/testcontainers/src/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,28 @@ 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+
// Postgres (template-clone) + per-test Redis, and NOTHING else. Same Redis isolation as
548+
// containerTestWithIsolatedRedis (for background work that outlives the test body) but without the
549+
// worker-scoped ClickHouse boot+migrate that the `resetClickhouse` auto fixture would otherwise force
550+
// on the first test in the file. Use this for tests that touch Postgres + Redis but never ClickHouse -
551+
// it removes the heaviest item from the cold-start container budget.
552+
export const containerTestWithIsolatedRedisNoClickhouse =
553+
test.extend<ContainerWithIsolatedRedisNoClickhouseContext>({
554+
network,
555+
postgresContainer: clonedPostgresContainer,
556+
prisma: prismaFromContainer,
557+
redisContainer,
558+
redisOptions,
559+
});
560+
539561
// For tests that exercise the Postgres -> ClickHouse logical-replication pipeline (WAL slots,
540562
// publications, REPLICA IDENTITY). These need a dedicated Postgres per test - the worker-scoped +
541563
// template-clone model used by containerTest doesn't carry logical replication across cloned dbs.

0 commit comments

Comments
 (0)