Skip to content

Commit ed16bc6

Browse files
committed
test(worker): stabilize workflow parallelism assertion
Signed-off-by: zebbern <185730623+zebbern@users.noreply.github.com>
1 parent 28f3f56 commit ed16bc6

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

worker/src/temporal/__tests__/workflow-runner.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,17 @@ describe('executeWorkflow', () => {
252252
const branchStartDelta = Math.abs(branchA.startedAt - branchB.startedAt);
253253
expect(branchStartDelta).toBeLessThan(75);
254254

255-
const branchAElapsed = branchA.endedAt - branchA.startedAt;
256-
const branchBElapsed = branchB.endedAt - branchB.startedAt;
257-
expect(branchAElapsed).toBeGreaterThanOrEqual(190);
258-
expect(branchBElapsed).toBeGreaterThanOrEqual(190);
255+
const branchesOverlap =
256+
Math.max(branchA.startedAt, branchB.startedAt) < Math.min(branchA.endedAt, branchB.endedAt);
257+
expect(branchesOverlap).toBe(true);
258+
259+
expect(merge.startedAt).toBeGreaterThanOrEqual(Math.max(branchA.endedAt, branchB.endedAt) - 5);
259260

260261
const totalElapsed = merge.endedAt - start.startedAt;
261-
expect(totalElapsed).toBeLessThan(350);
262+
// A serial execution would take roughly 450ms before merge overhead
263+
// (50ms start + 200ms branchA + 200ms branchB). Keep the assertion about
264+
// scheduler behavior, not timer precision.
265+
expect(totalElapsed).toBeLessThan(450);
262266
});
263267

264268
it('produces a deterministic trace sequence across repeated runs', async () => {

0 commit comments

Comments
 (0)