From 301e1290726d8dfa598adece9a39a9b577bbe2ca Mon Sep 17 00:00:00 2001 From: Quinn Klassen Date: Mon, 21 Oct 2024 08:16:43 -0700 Subject: [PATCH] Fix test server operation timeout (#2282) --- .../temporal/workflow/nexus/AsyncWorkflowOperationTest.java | 6 +----- .../io/temporal/internal/testservice/StateMachines.java | 3 ++- .../internal/testservice/TestWorkflowMutableStateImpl.java | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java index 9697e24b6..f702cf36d 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java @@ -30,7 +30,6 @@ import io.temporal.workflow.*; import io.temporal.workflow.shared.TestNexusServices; import io.temporal.workflow.shared.TestWorkflows; -import java.time.Duration; import org.junit.Assert; import org.junit.Rule; import org.junit.Test; @@ -65,10 +64,7 @@ public void testWorkflowOperationReplay() throws Exception { public static class TestNexus implements TestWorkflows.TestWorkflow1 { @Override public String execute(String input) { - NexusOperationOptions options = - NexusOperationOptions.newBuilder() - .setScheduleToCloseTimeout(Duration.ofSeconds(10)) - .build(); + NexusOperationOptions options = NexusOperationOptions.newBuilder().build(); NexusServiceOptions serviceOptions = NexusServiceOptions.newBuilder() .setEndpoint(getEndpointName()) diff --git a/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java index d878cd588..c5e41d07b 100644 --- a/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java +++ b/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java @@ -661,7 +661,8 @@ private static void scheduleNexusOperation( long workflowTaskCompletedId) { Duration expirationInterval = attr.getScheduleToCloseTimeout(); Timestamp expirationTime = - (attr.hasScheduleToCloseTimeout()) + (attr.hasScheduleToCloseTimeout() + && Durations.toMillis(attr.getScheduleToCloseTimeout()) > 0) ? Timestamps.add(ctx.currentTime(), expirationInterval) : Timestamp.getDefaultInstance(); TestServiceRetryState retryState = new TestServiceRetryState(data.retryPolicy, expirationTime); diff --git a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java index 1ff929294..f47c5bd53 100644 --- a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java +++ b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java @@ -786,7 +786,8 @@ private void processScheduleNexusOperation( timeoutNexusRequest( scheduleEventId, "StartNexusOperation", operation.getData().getAttempt()), "StartNexusOperation request timeout"); - if (attr.hasScheduleToCloseTimeout()) { + if (attr.hasScheduleToCloseTimeout() + && Durations.toMillis(attr.getScheduleToCloseTimeout()) > 0) { ctx.addTimer( ProtobufTimeUtils.toJavaDuration(attr.getScheduleToCloseTimeout()), () ->