I’m attempting to test that a failed activity is retried. The error returned by the activity is passed back to the workflow leading me to believe the error returned by the activity is intended to be a domain-level error and not a retriable infrastructure error. Having the activity panic also doesn’t trigger the activity to be retried. Is there something akin to activity.ErrResultPending signaling a retriable error? Perhaps I’m I’m not configurations the retry policy correctly?
Thanks again for the help.
func Workflow(context workflow.Context) (bool, error) {
context = workflow.WithActivityOptions(
context,
workflow.ActivityOptions{
StartToCloseTimeout: 10 * time.Second,
ScheduleToCloseTimeout: 10 * time.Second,
RetryPolicy: &temporal.RetryPolicy{
BackoffCoefficient: 2,
MaximumAttempts: 3,
},
})
activityExecution := workflow.ExecuteActivity(context, Activity)
var result bool
err := activityExecution.Get(context, &result)
return result, err
}
var Attempts = 0
func Activity(context context.Context) (bool, error) {
if Attempts == 0 {
Attempts++
println("attempt", Attempts)
return false, errors.New("first attempt fails")
}
Attempts++
println("attempt", Attempts)
return true, nil
}
func (testSuite *MyTestSuite) TestWorkflowWaitingForActivity() {
testSuite.env.RegisterActivity(Activity)
testSuite.env.ExecuteWorkflow(Workflow)
testSuite.NoError(testSuite.env.GetWorkflowError())
testSuite.True(testSuite.env.IsWorkflowCompleted())
testSuite.Equal(2, Attempts)
}
The NoError check fails with:
workflow execution error (type: Workflow, workflowID: default-test-workflow-id, runID: default-test-run-id): activity error (type: Activity, scheduledEventID: 0, startedEventID: 0, identity: ): first attempt fails