Skip to content

Commit c54499d

Browse files
committed
Fix test server and tests for Temporal Server 1.31.0 compatibility
- Update test server nexus failure wrapping to match real server behavior: remove ApplicationFailureInfo wrapping for non-temporal failures and remove redundant message from handler error top-level failure - Fix NexusWorkflowTest assertions for updated failure structure - Fix testNexusOperationTimeout_AfterCancel to handle intermediate WFTs caused by NEXUS_OPERATION_CANCEL_REQUEST_FAILED events - Fix testNexusOperationScheduleToStartTimeout timing for real server - Use unique workflow IDs in WorkflowIdConflictPolicyTest for real server - Add component.callbacks.allowedAddresses config to CI server startup
1 parent 1a5005e commit c54499d

4 files changed

Lines changed: 28 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ jobs:
9494
--search-attribute CustomBoolField=Bool \
9595
--dynamic-config-value system.enableActivityEagerExecution=true \
9696
--dynamic-config-value frontend.workerVersioningDataAPIs=true \
97-
--dynamic-config-value history.enableRequestIdRefLinks=true &
97+
--dynamic-config-value history.enableRequestIdRefLinks=true \
98+
--dynamic-config-value 'component.callbacks.allowedAddresses=[{"Pattern":"localhost:7243","AllowInsecure":true}]' &
9899
sleep 10s
99100
100101
- name: Run unit tests

temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,6 @@ public void completeNexusOperation(
11711171

11721172
private static Failure handlerErrorToFailure(HandlerError err) {
11731173
return Failure.newBuilder()
1174-
.setMessage(err.getFailure().getMessage())
11751174
.setNexusHandlerFailureInfo(
11761175
NexusHandlerFailureInfo.newBuilder()
11771176
.setType(err.getErrorType())
@@ -1196,13 +1195,6 @@ private static Failure nexusFailureToAPIFailure(
11961195
} catch (InvalidProtocolBufferException e) {
11971196
throw new RuntimeException(e);
11981197
}
1199-
} else {
1200-
Payloads payloads = nexusFailureMetadataToPayloads(failure);
1201-
ApplicationFailureInfo.Builder applicationFailureInfo = ApplicationFailureInfo.newBuilder();
1202-
applicationFailureInfo.setType("NexusFailure");
1203-
applicationFailureInfo.setDetails(payloads);
1204-
applicationFailureInfo.setNonRetryable(!retryable);
1205-
apiFailure.setApplicationFailureInfo(applicationFailureInfo.build());
12061198
}
12071199
apiFailure.setMessage(failure.getMessage());
12081200
return apiFailure.build();

temporal-test-server/src/test/java/io/temporal/testserver/functional/NexusWorkflowTest.java

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public void testNexusOperationTimeout_AfterStart() {
628628
}
629629
}
630630

631-
@Test(timeout = 30000)
631+
@Test(timeout = 60000)
632632
public void testNexusOperationTimeout_AfterCancel() {
633633
String operationId = UUID.randomUUID().toString();
634634
CompletableFuture<?> nexusPoller =
@@ -644,7 +644,7 @@ public void testNexusOperationTimeout_AfterCancel() {
644644
pollResp.getTaskToken(),
645645
newScheduleOperationCommand(
646646
defaultScheduleOperationAttributes()
647-
.setScheduleToCloseTimeout(Durations.fromSeconds(22))));
647+
.setScheduleToCloseTimeout(Durations.fromSeconds(10))));
648648
testWorkflowRule.assertHistoryEvent(
649649
execution.getWorkflowId(), EventType.EVENT_TYPE_NEXUS_OPERATION_SCHEDULED);
650650

@@ -669,24 +669,21 @@ public void testNexusOperationTimeout_AfterCancel() {
669669
.build();
670670
completeWorkflowTask(pollResp.getTaskToken(), cancelCmd);
671671

672-
// Poll for cancellation task but do not complete it
673-
PollNexusTaskQueueResponse nexusPollResp = pollNexusTask().get();
674-
Assert.assertTrue(nexusPollResp.getRequest().hasCancelOperation());
675-
676-
// Request timeout and long poll deadline are both 10s, so sleep to give some buffer so poll
677-
// request doesn't timeout.
678-
Thread.sleep(2000);
679-
680-
// Poll for cancellation task again
681-
nexusPollResp = pollNexusTask().get();
682-
Assert.assertTrue(nexusPollResp.getRequest().hasCancelOperation());
683-
684-
// Request timeout and long poll deadline are both 10s, so sleep to give some buffer so poll
685-
// request doesn't timeout.
686-
Thread.sleep(2000);
672+
// The cancel task may not be completed in time, causing a
673+
// NEXUS_OPERATION_CANCEL_REQUEST_FAILED event and a new WFT. Handle any intermediate WFTs
674+
// until the operation actually times out.
675+
while (true) {
676+
pollResp = pollWorkflowTask();
677+
events =
678+
testWorkflowRule.getHistoryEvents(
679+
execution.getWorkflowId(), EventType.EVENT_TYPE_NEXUS_OPERATION_TIMED_OUT);
680+
if (!events.isEmpty()) {
681+
break;
682+
}
683+
// Not timed out yet, acknowledge the WFT and keep waiting
684+
completeWorkflowTask(pollResp.getTaskToken());
685+
}
687686

688-
// Poll to wait for new task after operation times out
689-
pollResp = pollWorkflowTask();
690687
completeWorkflow(pollResp.getTaskToken());
691688

692689
events =
@@ -710,18 +707,21 @@ public void testNexusOperationTimeout_AfterCancel() {
710707
}
711708
}
712709

713-
@Test
710+
@Test(timeout = 30000)
714711
public void testNexusOperationScheduleToStartTimeout() {
715712
WorkflowStub stub = newWorkflowStub("TestNexusOperationScheduleToStartTimeoutWorkflow");
716713
WorkflowExecution execution = stub.start();
717714

715+
// Use a longer schedule-to-start timeout so the nexus poll has time to return on real server
716+
int scheduleToStartSeconds = testWorkflowRule.isUseExternalService() ? 10 : 1;
717+
718718
// Get first WFT and respond with ScheduleNexusOperation command with schedule-to-start timeout
719719
PollWorkflowTaskQueueResponse pollResp = pollWorkflowTask();
720720
completeWorkflowTask(
721721
pollResp.getTaskToken(),
722722
newScheduleOperationCommand(
723723
defaultScheduleOperationAttributes()
724-
.setScheduleToStartTimeout(Durations.fromSeconds(1))
724+
.setScheduleToStartTimeout(Durations.fromSeconds(scheduleToStartSeconds))
725725
.setScheduleToCloseTimeout(Durations.fromSeconds(30))));
726726
testWorkflowRule.assertHistoryEvent(
727727
execution.getWorkflowId(), EventType.EVENT_TYPE_NEXUS_OPERATION_SCHEDULED);
@@ -746,7 +746,7 @@ public void testNexusOperationScheduleToStartTimeout() {
746746
Assert.assertTrue("OPERATION_TIMEOUT should be positive", operationTimeoutMs > 0);
747747

748748
// Sleep longer than schedule-to-start timeout to trigger the timeout
749-
testWorkflowRule.sleep(Duration.ofSeconds(2));
749+
testWorkflowRule.sleep(Duration.ofSeconds(scheduleToStartSeconds + 1));
750750
} catch (Exception e) {
751751
Assert.fail(e.getMessage());
752752
}
@@ -885,8 +885,6 @@ public void testNexusOperationError() {
885885
Assert.assertEquals("nexus operation completed unsuccessfully", failure.getMessage());
886886
io.temporal.api.failure.v1.Failure cause = failure.getCause();
887887
Assert.assertEquals("deliberate test failure", cause.getMessage());
888-
Assert.assertTrue(cause.hasApplicationFailureInfo());
889-
Assert.assertEquals("NexusFailure", cause.getApplicationFailureInfo().getType());
890888
} catch (Exception e) {
891889
Assert.fail(e.getMessage());
892890
} finally {
@@ -947,9 +945,9 @@ public void testNexusOperationHandlerError() {
947945
assertOperationFailureInfo(failure.getNexusOperationExecutionFailureInfo());
948946
Assert.assertEquals("nexus operation completed unsuccessfully", failure.getMessage());
949947
io.temporal.api.failure.v1.Failure cause = failure.getCause();
950-
Assert.assertTrue(cause.getMessage().endsWith("deliberate terminal error"));
951948
Assert.assertTrue(cause.hasNexusHandlerFailureInfo());
952949
Assert.assertEquals("BAD_REQUEST", cause.getNexusHandlerFailureInfo().getType());
950+
Assert.assertEquals("deliberate terminal error", cause.getCause().getMessage());
953951
} catch (Exception e) {
954952
Assert.fail(e.getMessage());
955953
} finally {
@@ -1016,9 +1014,9 @@ public void testNexusOperationHandlerTemporalFailure() {
10161014
assertOperationFailureInfo(failure.getNexusOperationExecutionFailureInfo());
10171015
Assert.assertEquals("nexus operation completed unsuccessfully", failure.getMessage());
10181016
io.temporal.api.failure.v1.Failure cause = failure.getCause();
1019-
Assert.assertTrue(cause.getMessage().endsWith("deliberate terminal error"));
10201017
Assert.assertTrue(cause.hasNexusHandlerFailureInfo());
10211018
Assert.assertEquals("BAD_REQUEST", cause.getNexusHandlerFailureInfo().getType());
1019+
Assert.assertEquals("deliberate terminal error", cause.getCause().getMessage());
10221020
} catch (Exception e) {
10231021
Assert.fail(e.getMessage());
10241022
} finally {

temporal-test-server/src/test/java/io/temporal/testserver/functional/WorkflowIdConflictPolicyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class WorkflowIdConflictPolicyTest {
4141

4242
@Test
4343
public void conflictPolicyUseExisting() {
44-
String workflowId = "conflict-policy-use-existing";
44+
String workflowId = "conflict-policy-use-existing-" + randomUUID();
4545
String requestId = randomUUID().toString();
4646

4747
// Start workflow
@@ -232,7 +232,7 @@ public void conflictPolicyUseExisting() {
232232

233233
@Test
234234
public void conflictPolicyFail() {
235-
String workflowId = "conflict-policy-fail";
235+
String workflowId = "conflict-policy-fail-" + randomUUID();
236236
WorkflowOptions options =
237237
WorkflowOptions.newBuilder()
238238
.setWorkflowId(workflowId)

0 commit comments

Comments
 (0)