Skip to content

Commit 7a150fa

Browse files
committed
test(webapp): move logical-replication suites to replicationContainerTest
1 parent a6ddc85 commit 7a150fa

7 files changed

Lines changed: 46 additions & 46 deletions

apps/webapp/test/runsBackfiller.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ vi.mock("~/db.server", () => ({
77
}));
88

99
import { ClickHouse } from "@internal/clickhouse";
10-
import { containerTest } from "@internal/testcontainers";
10+
import { replicationContainerTest } from "@internal/testcontainers";
1111
import { z } from "zod";
1212
import { RunsBackfillerService } from "~/services/runsBackfiller.server";
1313
import { RunsReplicationService } from "~/services/runsReplicationService.server";
@@ -17,7 +17,7 @@ import { TestReplicationClickhouseFactory } from "./utils/testReplicationClickho
1717
vi.setConfig({ testTimeout: 60_000 });
1818

1919
describe("RunsBackfillerService", () => {
20-
containerTest(
20+
replicationContainerTest(
2121
"should backfill completed runs to clickhouse",
2222
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
2323
const clickhouse = new ClickHouse({

apps/webapp/test/runsReplicationBenchmark.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ClickHouse } from "@internal/clickhouse";
2-
import { containerTest } from "@internal/testcontainers";
2+
import { replicationContainerTest } from "@internal/testcontainers";
33
import { fork, type ChildProcess } from "node:child_process";
44
import { performance, PerformanceObserver } from "node:perf_hooks";
55
import { setTimeout } from "node:timers/promises";
@@ -501,7 +501,7 @@ function compareBenchmarks(baseline: BenchmarkResult, comparison: BenchmarkResul
501501
}
502502

503503
describe("RunsReplicationService Benchmark", () => {
504-
containerTest.skipIf(process.env.BENCHMARKS_ENABLED !== "1")(
504+
replicationContainerTest.skipIf(process.env.BENCHMARKS_ENABLED !== "1")(
505505
"should benchmark error fingerprinting performance impact",
506506
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
507507
// Enable replica identity for TaskRun table

apps/webapp/test/runsReplicationService.part1.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ClickHouse } from "@internal/clickhouse";
2-
import { containerTest } from "@internal/testcontainers";
2+
import { replicationContainerTest } from "@internal/testcontainers";
33
import { setTimeout } from "node:timers/promises";
44
import { z } from "zod";
55
import { TaskRunStatus } from "~/database-types";
@@ -11,7 +11,7 @@ import superjson from "superjson";
1111
vi.setConfig({ testTimeout: 60_000 });
1212

1313
describe("RunsReplicationService (part 1/2)", () => {
14-
containerTest(
14+
replicationContainerTest(
1515
"should replicate runs to clickhouse",
1616
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
1717
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -135,7 +135,7 @@ describe("RunsReplicationService (part 1/2)", () => {
135135
}
136136
);
137137

138-
containerTest(
138+
replicationContainerTest(
139139
"should replicate runs with super json payloads to clickhouse",
140140
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
141141
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -276,7 +276,7 @@ describe("RunsReplicationService (part 1/2)", () => {
276276
}
277277
);
278278

279-
containerTest(
279+
replicationContainerTest(
280280
"should not produce any flush spans when no TaskRun events are produced",
281281
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
282282
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -348,7 +348,7 @@ describe("RunsReplicationService (part 1/2)", () => {
348348
}
349349
);
350350

351-
containerTest(
351+
replicationContainerTest(
352352
"should replicate a new TaskRun to ClickHouse using batching insert strategy",
353353
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
354354
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -452,7 +452,7 @@ describe("RunsReplicationService (part 1/2)", () => {
452452
}
453453
);
454454

455-
containerTest(
455+
replicationContainerTest(
456456
"should insert the payload into ClickHouse when a TaskRun is created",
457457
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
458458
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -553,7 +553,7 @@ describe("RunsReplicationService (part 1/2)", () => {
553553
}
554554
);
555555

556-
containerTest(
556+
replicationContainerTest(
557557
"should insert the payload even if it's very large into ClickHouse when a TaskRun is created",
558558
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
559559
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -659,7 +659,7 @@ describe("RunsReplicationService (part 1/2)", () => {
659659
}
660660
);
661661

662-
containerTest(
662+
replicationContainerTest(
663663
"should replicate updates to an existing TaskRun to ClickHouse",
664664
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
665665
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -766,7 +766,7 @@ describe("RunsReplicationService (part 1/2)", () => {
766766
}
767767
);
768768

769-
containerTest(
769+
replicationContainerTest(
770770
"should replicate deletions of a TaskRun to ClickHouse and mark as deleted",
771771
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
772772
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -866,7 +866,7 @@ describe("RunsReplicationService (part 1/2)", () => {
866866
}
867867
);
868868

869-
containerTest(
869+
replicationContainerTest(
870870
"should gracefully shutdown and allow a new service to pick up from the correct LSN (handover)",
871871
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
872872
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -1017,7 +1017,7 @@ describe("RunsReplicationService (part 1/2)", () => {
10171017
}
10181018
);
10191019

1020-
containerTest(
1020+
replicationContainerTest(
10211021
"should not re-process already handled data if shutdown is called after all transactions are processed",
10221022
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
10231023
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -1160,7 +1160,7 @@ describe("RunsReplicationService (part 1/2)", () => {
11601160
}
11611161
);
11621162

1163-
containerTest(
1163+
replicationContainerTest(
11641164
"should record metrics with correct values when replicating runs",
11651165
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
11661166
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);

apps/webapp/test/runsReplicationService.part2.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ClickHouse, getTaskRunField, getPayloadField } from "@internal/clickhouse";
2-
import { containerTest } from "@internal/testcontainers";
2+
import { replicationContainerTest } from "@internal/testcontainers";
33
import { Logger } from "@trigger.dev/core/logger";
44
import { readFile } from "node:fs/promises";
55
import { setTimeout } from "node:timers/promises";
@@ -11,7 +11,7 @@ import { TestReplicationClickhouseFactory } from "./utils/testReplicationClickho
1111
vi.setConfig({ testTimeout: 60_000 });
1212

1313
describe("RunsReplicationService (part 2/2)", () => {
14-
containerTest(
14+
replicationContainerTest(
1515
"should handover leadership to a second service, and the second service should be able to extend the leader lock",
1616
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
1717
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -141,7 +141,7 @@ describe("RunsReplicationService (part 2/2)", () => {
141141
}
142142
);
143143

144-
containerTest(
144+
replicationContainerTest(
145145
"should replicate all 1,000 TaskRuns inserted in bulk to ClickHouse",
146146
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
147147
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -256,7 +256,7 @@ describe("RunsReplicationService (part 2/2)", () => {
256256
}
257257
);
258258

259-
containerTest(
259+
replicationContainerTest(
260260
"should replicate all 1,000 TaskRuns inserted in bulk to ClickHouse with updates",
261261
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
262262
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -377,7 +377,7 @@ describe("RunsReplicationService (part 2/2)", () => {
377377
}
378378
);
379379

380-
containerTest(
380+
replicationContainerTest(
381381
"should replicate all events in a single transaction (insert, update)",
382382
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
383383
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -511,7 +511,7 @@ describe("RunsReplicationService (part 2/2)", () => {
511511
}
512512
);
513513

514-
containerTest(
514+
replicationContainerTest(
515515
"should be able to handle processing transactions for a long period of time",
516516
{ timeout: 60_000 * 5 },
517517
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
@@ -618,7 +618,7 @@ describe("RunsReplicationService (part 2/2)", () => {
618618
}
619619
);
620620

621-
containerTest(
621+
replicationContainerTest(
622622
"should insert TaskRuns even if there are incomplete Unicode escape sequences in the JSON",
623623
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
624624
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);
@@ -787,7 +787,7 @@ describe("RunsReplicationService (part 2/2)", () => {
787787
}
788788
);
789789

790-
containerTest(
790+
replicationContainerTest(
791791
"should merge duplicate event+run.id combinations keeping the latest version",
792792
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
793793
await prisma.$executeRawUnsafe(`ALTER TABLE public.\"TaskRun\" REPLICA IDENTITY FULL;`);
@@ -912,7 +912,7 @@ describe("RunsReplicationService (part 2/2)", () => {
912912
}
913913
);
914914

915-
containerTest(
915+
replicationContainerTest(
916916
"should sort batch inserts according to table schema ordering for optimal performance",
917917
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
918918
await prisma.$executeRawUnsafe(`ALTER TABLE public.\"TaskRun\" REPLICA IDENTITY FULL;`);
@@ -1125,7 +1125,7 @@ describe("RunsReplicationService (part 2/2)", () => {
11251125
}
11261126
);
11271127

1128-
containerTest(
1128+
replicationContainerTest(
11291129
"should exhaustively replicate all TaskRun columns to ClickHouse",
11301130
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
11311131
await prisma.$executeRawUnsafe(`ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;`);

apps/webapp/test/runsRepository.part1.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ vi.mock("~/db.server", () => ({
66
$replica: {},
77
}));
88

9-
import { containerTest } from "@internal/testcontainers";
9+
import { replicationContainerTest } from "@internal/testcontainers";
1010
import { setTimeout } from "node:timers/promises";
1111
import { RunsRepository } from "~/services/runsRepository/runsRepository.server";
1212
import { setupClickhouseReplication } from "./utils/replicationUtils";
1313

1414
vi.setConfig({ testTimeout: 60_000 });
1515

1616
describe("RunsRepository (part 1/2)", () => {
17-
containerTest(
17+
replicationContainerTest(
1818
"should list runs, using clickhouse as the source",
1919
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
2020
const { clickhouse } = await setupClickhouseReplication({
@@ -90,7 +90,7 @@ describe("RunsRepository (part 1/2)", () => {
9090
}
9191
);
9292

93-
containerTest(
93+
replicationContainerTest(
9494
"should filter runs by task identifiers",
9595
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
9696
const { clickhouse } = await setupClickhouseReplication({
@@ -198,7 +198,7 @@ describe("RunsRepository (part 1/2)", () => {
198198
}
199199
);
200200

201-
containerTest(
201+
replicationContainerTest(
202202
"should filter runs by task versions",
203203
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
204204
const { clickhouse } = await setupClickhouseReplication({
@@ -309,7 +309,7 @@ describe("RunsRepository (part 1/2)", () => {
309309
}
310310
);
311311

312-
containerTest(
312+
replicationContainerTest(
313313
"should filter runs by status",
314314
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
315315
const { clickhouse } = await setupClickhouseReplication({
@@ -420,7 +420,7 @@ describe("RunsRepository (part 1/2)", () => {
420420
}
421421
);
422422

423-
containerTest(
423+
replicationContainerTest(
424424
"should filter runs by tags",
425425
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
426426
const { clickhouse } = await setupClickhouseReplication({
@@ -531,7 +531,7 @@ describe("RunsRepository (part 1/2)", () => {
531531
}
532532
);
533533

534-
containerTest(
534+
replicationContainerTest(
535535
"should filter runs by scheduleId",
536536
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
537537
const { clickhouse } = await setupClickhouseReplication({
@@ -641,7 +641,7 @@ describe("RunsRepository (part 1/2)", () => {
641641
}
642642
);
643643

644-
containerTest(
644+
replicationContainerTest(
645645
"should filter runs by isTest flag",
646646
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
647647
const { clickhouse } = await setupClickhouseReplication({

apps/webapp/test/runsRepository.part2.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ vi.mock("~/db.server", () => ({
66
$replica: {},
77
}));
88

9-
import { containerTest } from "@internal/testcontainers";
9+
import { replicationContainerTest } from "@internal/testcontainers";
1010
import { setTimeout } from "node:timers/promises";
1111
import { RunsRepository } from "~/services/runsRepository/runsRepository.server";
1212
import { setupClickhouseReplication } from "./utils/replicationUtils";
1313

1414
vi.setConfig({ testTimeout: 60_000 });
1515

1616
describe("RunsRepository (part 2/2)", () => {
17-
containerTest(
17+
replicationContainerTest(
1818
"should filter runs by rootOnly flag",
1919
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
2020
const { clickhouse } = await setupClickhouseReplication({
@@ -108,7 +108,7 @@ describe("RunsRepository (part 2/2)", () => {
108108
}
109109
);
110110

111-
containerTest(
111+
replicationContainerTest(
112112
"should filter runs by batchId",
113113
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
114114
const { clickhouse } = await setupClickhouseReplication({
@@ -238,7 +238,7 @@ describe("RunsRepository (part 2/2)", () => {
238238
}
239239
);
240240

241-
containerTest(
241+
replicationContainerTest(
242242
"should filter runs by runFriendlyIds",
243243
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
244244
const { clickhouse } = await setupClickhouseReplication({
@@ -346,7 +346,7 @@ describe("RunsRepository (part 2/2)", () => {
346346
}
347347
);
348348

349-
containerTest(
349+
replicationContainerTest(
350350
"should filter runs by runIds",
351351
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
352352
const { clickhouse } = await setupClickhouseReplication({
@@ -454,7 +454,7 @@ describe("RunsRepository (part 2/2)", () => {
454454
}
455455
);
456456

457-
containerTest(
457+
replicationContainerTest(
458458
"should filter runs by date range (from/to)",
459459
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
460460
const { clickhouse } = await setupClickhouseReplication({
@@ -570,7 +570,7 @@ describe("RunsRepository (part 2/2)", () => {
570570
}
571571
);
572572

573-
containerTest(
573+
replicationContainerTest(
574574
"should handle multiple filters combined",
575575
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
576576
const { clickhouse } = await setupClickhouseReplication({
@@ -694,7 +694,7 @@ describe("RunsRepository (part 2/2)", () => {
694694
}
695695
);
696696

697-
containerTest(
697+
replicationContainerTest(
698698
"should handle pagination correctly",
699699
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
700700
const { clickhouse } = await setupClickhouseReplication({
@@ -790,7 +790,7 @@ describe("RunsRepository (part 2/2)", () => {
790790
}
791791
);
792792

793-
containerTest(
793+
replicationContainerTest(
794794
"should count new runs with listRunIds",
795795
async ({ clickhouseContainer, redisOptions, postgresContainer, prisma }) => {
796796
const { clickhouse } = await setupClickhouseReplication({

0 commit comments

Comments
 (0)