Skip to content

Commit a05a637

Browse files
authored
chore(workflow): add test for activity retry policies (#1121)
## What changed - Added an integration test to assert fix of #441
1 parent b58a989 commit a05a637

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

packages/test/src/test-integration-workflows.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
} from '@temporalio/worker';
1515
import * as activity from '@temporalio/activity';
1616
import * as workflow from '@temporalio/workflow';
17-
import { CancelReason } from '@temporalio/worker/src/activity';
17+
import { CancelReason } from '@temporalio/worker/lib/activity';
18+
import { tsToMs } from '@temporalio/common/lib/time';
1819
import { test as anyTest, bundlerOptions, Worker } from './helpers';
1920
import { activityStartedSignal } from './workflows/definitions';
2021
import { signalSchedulingWorkflow } from './activities/helpers';
@@ -125,8 +126,8 @@ test('Workflow fails if it tries to start a child with an existing workflow ID',
125126
});
126127
});
127128

128-
export async function runTestActivity(): Promise<void> {
129-
await workflow.proxyActivities({ startToCloseTimeout: '1m' }).testActivity();
129+
export async function runTestActivity(activityOptions?: workflow.ActivityOptions): Promise<void> {
130+
await workflow.proxyActivities({ startToCloseTimeout: '1m', ...activityOptions }).testActivity();
130131
}
131132

132133
test('Worker cancels activities after shutdown has been requested', async (t) => {
@@ -214,3 +215,25 @@ test('Condition 0 patch sets a timer', async (t) => {
214215
const worker = await createWorker();
215216
t.false(await worker.runUntil(executeWorkflow(conditionTimeout0)));
216217
});
218+
219+
test('Activity initialInterval is not getting rounded', async (t) => {
220+
const { createWorker, startWorkflow } = helpers(t);
221+
const worker = await createWorker({
222+
activities: {
223+
testActivity: () => undefined,
224+
},
225+
});
226+
const handle = await startWorkflow(runTestActivity, {
227+
args: [
228+
{
229+
startToCloseTimeout: '5s',
230+
retry: { initialInterval: '50ms', maximumAttempts: 1 },
231+
},
232+
],
233+
});
234+
await worker.runUntil(handle.result());
235+
const { events } = await handle.fetchHistory();
236+
const activityTaskScheduledEvents = events?.find((ev) => ev.activityTaskScheduledEventAttributes);
237+
const retryPolicy = activityTaskScheduledEvents?.activityTaskScheduledEventAttributes?.retryPolicy;
238+
t.is(tsToMs(retryPolicy?.initialInterval), 50);
239+
});

0 commit comments

Comments
 (0)