Skip to content

Commit fcdaa60

Browse files
Add test for non retryable error
1 parent 26f11b9 commit fcdaa60

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Diff for: temporal-sdk/src/test/java/io/temporal/workflow/nexus/OperationFailMetricTest.java

+30
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,31 @@ public void failHandlerErrorMetrics() {
337337
});
338338
}
339339

340+
@Test
341+
public void handlerErrorNonRetryableMetrics() {
342+
TestWorkflow1 workflowStub =
343+
testWorkflowRule.newWorkflowStubTimeoutOptions(TestWorkflow1.class);
344+
WorkflowFailedException workflowException =
345+
Assert.assertThrows(
346+
WorkflowFailedException.class, () -> workflowStub.execute("handlererror-nonretryable"));
347+
348+
Map<String, String> execFailedTags =
349+
getOperationTags()
350+
.put(MetricsTag.TASK_FAILURE_TYPE, "handler_error_INTERNAL")
351+
.buildKeepingLast();
352+
Eventually.assertEventually(
353+
Duration.ofSeconds(3),
354+
() -> {
355+
reporter.assertTimer(
356+
MetricsType.NEXUS_SCHEDULE_TO_START_LATENCY, getBaseTags().buildKeepingLast());
357+
reporter.assertTimer(
358+
MetricsType.NEXUS_EXEC_LATENCY, getOperationTags().buildKeepingLast());
359+
reporter.assertTimer(
360+
MetricsType.NEXUS_TASK_E2E_LATENCY, getOperationTags().buildKeepingLast());
361+
reporter.assertCounter(MetricsType.NEXUS_EXEC_FAILED_COUNTER, execFailedTags, 1);
362+
});
363+
}
364+
340365
public static class TestNexus implements TestWorkflow1 {
341366
@Override
342367
public String execute(String operation) {
@@ -382,6 +407,11 @@ public OperationHandler<String, String> operation() {
382407
throw new HandlerException(
383408
HandlerException.ErrorType.BAD_REQUEST,
384409
ApplicationFailure.newFailure("intentional failure", "TestFailure", "foo"));
410+
case "handlererror-nonretryable":
411+
throw new HandlerException(
412+
HandlerException.ErrorType.INTERNAL,
413+
ApplicationFailure.newNonRetryableFailure("intentional failure", "TestFailure"),
414+
HandlerException.RetryBehavior.NON_RETRYABLE);
385415
case "already-started":
386416
throw new WorkflowExecutionAlreadyStarted(
387417
WorkflowExecution.getDefaultInstance(), "TestWorkflowType", null);

0 commit comments

Comments
 (0)