Skip to content

Commit 8c6bf23

Browse files
committed
test(run-engine): build the replica-lag test's middle snapshot on the primary
startRunAttempt resolves the background worker task through readOnlyPrisma, and this test configures a deliberately empty schema-only replica, so using it to add a snapshot failed on the replica read instead of exercising the lag scenario. Write the snapshot with the file's own primary-side helper.
1 parent 9ff3113 commit 8c6bf23

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

internal-packages/run-engine/src/engine/tests/getSnapshotsSince.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { PrismaClient } from "@trigger.dev/database";
77
import { RunEngine } from "../index.js";
88
import { getExecutionSnapshotsSince } from "../systems/executionSnapshotSystem.js";
99
import { copySnapshotsToReplica, createTestMetricsMeter } from "./helpers/replicaTestHelpers.js";
10-
import { setupTestScenario } from "./helpers/snapshotTestHelpers.js";
10+
import { createTestSnapshot, setupTestScenario } from "./helpers/snapshotTestHelpers.js";
1111
import { setupAuthenticatedEnvironment, setupBackgroundWorker } from "./setup.js";
1212

1313
vi.setConfig({ testTimeout: 120_000 });
@@ -1149,14 +1149,18 @@ describe("RunEngine getSnapshotsSince", () => {
11491149
);
11501150

11511151
await setTimeout(500);
1152-
const dequeued = await engine.dequeueFromWorkerQueue({
1152+
await engine.dequeueFromWorkerQueue({
11531153
consumerId: "test_replica_stale_tail",
11541154
workerQueue: "main",
11551155
});
11561156

1157-
await engine.startRunAttempt({
1158-
runId: dequeued[0].run.id,
1159-
snapshotId: dequeued[0].snapshot.id,
1157+
await createTestSnapshot(prisma, {
1158+
runId: run.id,
1159+
status: "EXECUTING",
1160+
environmentId: authenticatedEnvironment.id,
1161+
environmentType: authenticatedEnvironment.type,
1162+
projectId: authenticatedEnvironment.project.id,
1163+
organizationId: authenticatedEnvironment.organization.id,
11601164
});
11611165

11621166
const allSnapshots = await prisma.taskRunExecutionSnapshot.findMany({

0 commit comments

Comments
 (0)