diff --git a/internal/activity.go b/internal/activity.go index 5a7fe749a..03d2d9f24 100644 --- a/internal/activity.go +++ b/internal/activity.go @@ -100,7 +100,6 @@ type ( // better to rely on the default value. // ScheduleToStartTimeout is always non-retryable. Retrying after this timeout doesn't make sense as it would // just put the Activity Task back into the same Task Queue. - // If ScheduleToClose is not provided then this timeout is required. // Optional: Defaults to unlimited. ScheduleToStartTimeout time.Duration @@ -109,7 +108,7 @@ type ( // to detect that an Activity that didn't complete on time. So this timeout should be as short as the longest // possible execution of the Activity body. Potentially long running Activities must specify HeartbeatTimeout // and call Activity.RecordHeartbeat(ctx, "my-heartbeat") periodically for timely failure detection. - // If ScheduleToClose is not provided then this timeout is required: Defaults to the ScheduleToCloseTimeout value. + // Either this option or ScheduleToClose is required: Defaults to the ScheduleToCloseTimeout value. StartToCloseTimeout time.Duration // HeartbeatTimeout - Heartbeat interval. Activity must call Activity.RecordHeartbeat(ctx, "my-heartbeat") diff --git a/test/integration_test.go b/test/integration_test.go index 88f516962..b06d36c7a 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -1142,6 +1142,22 @@ func (ts *IntegrationTestSuite) TestWorkflowWithParallelSideEffects() { ts.NoError(ts.executeWorkflow("test-wf-parallel-side-effects", ts.workflows.WorkflowWithParallelSideEffects, nil)) } +func (ts *IntegrationTestSuite) TestActivityTimeoutsWorkflow() { + ts.NoError(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{ + ScheduleToCloseTimeout: 5 * time.Second, + })) + + ts.NoError(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{ + StartToCloseTimeout: 5 * time.Second, + })) + + ts.Error(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{})) + ts.Error(ts.executeWorkflow("test-activity-timeout-workflow", ts.workflows.ActivityTimeoutsWorkflow, nil, workflow.ActivityOptions{ + ScheduleToStartTimeout: 5 * time.Second, + })) + +} + func (ts *IntegrationTestSuite) TestWorkflowWithParallelSideEffectsUsingReplay() { replayer := worker.NewWorkflowReplayer() replayer.RegisterWorkflowWithOptions(ts.workflows.WorkflowWithParallelSideEffects, workflow.RegisterOptions{DisableAlreadyRegisteredCheck: true}) diff --git a/test/workflow_test.go b/test/workflow_test.go index 89f303492..8319b17f0 100644 --- a/test/workflow_test.go +++ b/test/workflow_test.go @@ -948,6 +948,10 @@ func (w *Workflows) ConsistentQueryWorkflow(ctx workflow.Context, delay time.Dur return nil } +func (w *Workflows) ActivityTimeoutsWorkflow(ctx workflow.Context, activityOptions workflow.ActivityOptions) error { + activityCtx := workflow.WithActivityOptions(ctx, activityOptions) + return workflow.ExecuteActivity(activityCtx, "Sleep", time.Second).Get(ctx, nil) +} func (w *Workflows) SignalWorkflow(ctx workflow.Context) (*commonpb.WorkflowType, error) { s := workflow.NewSelector(ctx) @@ -2289,6 +2293,7 @@ func (w *Workflows) register(worker worker.Worker) { worker.RegisterWorkflow(w.UpdateInfoWorkflow) worker.RegisterWorkflow(w.SignalWorkflow) worker.RegisterWorkflow(w.CronWorkflow) + worker.RegisterWorkflow(w.ActivityTimeoutsWorkflow) worker.RegisterWorkflow(w.CancelTimerConcurrentWithOtherCommandWorkflow) worker.RegisterWorkflow(w.CancelMultipleCommandsOverMultipleTasks) worker.RegisterWorkflow(w.CancelChildAndExecuteActivityRace)