Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 30 additions & 26 deletions packages/openworkflow/testing/backend.testsuite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,33 +421,37 @@ export function testBackend(options: TestBackendOptions): void {
await teardown(backend);
});

test("collapses concurrent creates with same key to one run id", async () => {
const backend = await setup();
const workflowName = randomUUID();
const version = "v1";
const idempotencyKey = randomUUID();

const runs = await Promise.all(
Array.from({ length: 10 }, (_, i) =>
backend.createWorkflowRun({
workflowName,
version,
idempotencyKey,
input: { i },
config: {},
context: null,
parentStepAttemptNamespaceId: null,
parentStepAttemptId: null,
availableAt: null,
deadlineAt: null,
}),
),
);
test(
"collapses concurrent creates with same key to one run id",
{ timeout: 15_000 },
async () => {
const backend = await setup();
const workflowName = randomUUID();
const version = "v1";
const idempotencyKey = randomUUID();

const runs = await Promise.all(
Array.from({ length: 10 }, (_, i) =>
backend.createWorkflowRun({
workflowName,
version,
idempotencyKey,
input: { i },
config: {},
context: null,
parentStepAttemptNamespaceId: null,
parentStepAttemptId: null,
availableAt: null,
deadlineAt: null,
}),
),
);

const uniqueRunIds = new Set(runs.map((run) => run.id));
expect(uniqueRunIds.size).toBe(1);
await teardown(backend);
});
const uniqueRunIds = new Set(runs.map((run) => run.id));
expect(uniqueRunIds.size).toBe(1);
await teardown(backend);
},
);

test("returns existing completed run for matching key", async () => {
const backend = await setup();
Expand Down
Loading
Loading