Skip to content

Commit

Permalink
Fix bugs when using a custom FailureConverter in tests
Browse files Browse the repository at this point in the history
Follow up to temporalio#1484.

1. We weren't correctly threading the failure converter down to
   activities and child workflows, so they were still using the
   default converter.

2. The `NonRetryable` flag on the protobuf failure type wasn't being
   honored for custom errors.
  • Loading branch information
boxofrad committed May 24, 2024
1 parent bf2c79d commit c130b94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/internal_workflow_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ func (env *testWorkflowEnvironmentImpl) newTestWorkflowEnvironmentForChild(param
childEnv.testWorkflowEnvironmentShared = env.testWorkflowEnvironmentShared
childEnv.workerOptions = env.workerOptions
childEnv.dataConverter = params.DataConverter
childEnv.failureConverter = env.failureConverter
childEnv.registry = env.registry
childEnv.detachedChildWaitDisabled = env.detachedChildWaitDisabled

Expand Down Expand Up @@ -1403,8 +1404,14 @@ func (env *testWorkflowEnvironmentImpl) executeActivityWithRetryForTest(

// check if a retry is needed
if request, ok := result.(*workflowservice.RespondActivityTaskFailedRequest); ok && parameters.RetryPolicy != nil {
failure := request.GetFailure()

if failure.GetApplicationFailureInfo().GetNonRetryable() {
break
}

p := fromProtoRetryPolicy(parameters.RetryPolicy)
backoff := getRetryBackoffWithNowTime(p, task.GetAttempt(), env.failureConverter.FailureToError(request.GetFailure()), env.Now(), expireTime)
backoff := getRetryBackoffWithNowTime(p, task.GetAttempt(), env.failureConverter.FailureToError(failure), env.Now(), expireTime)
if backoff > 0 {
// need a retry
waitCh := make(chan struct{})
Expand Down Expand Up @@ -1987,6 +1994,7 @@ func (env *testWorkflowEnvironmentImpl) newTestActivityTaskHandler(taskQueue str
MetricsHandler: env.metricsHandler,
Logger: env.logger,
UserContext: env.workerOptions.BackgroundActivityContext,
FailureConverter: env.failureConverter,
DataConverter: dataConverter,
WorkerStopChannel: env.workerStopChannel,
ContextPropagators: env.contextPropagators,
Expand Down

0 comments on commit c130b94

Please sign in to comment.