Skip to content

Commit ff980d3

Browse files
authored
Propagate memo on continue-as-new in the test server (#2943)
The in-memory test server carried over search attributes and header on continue-as-new but dropped the memo, so a workflow that sets a memo on continue-as-new could not read it back on the new run under the test environment even though it works against a real server. Set the memo on the ContinuedAsNew event attributes and on the new run start request, mirroring the existing search attribute handling, and extend ContinueAsNewTest to assert the memo is visible after continue-as-new. Closes #2863
1 parent 0192576 commit ff980d3

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

temporal-sdk/src/test/java/io/temporal/workflow/ContinueAsNewTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ public int execute(int count, String continueAsNewTaskQueue) {
7777
assertEquals(5, Workflow.getInfo().getRetryOptions().getMaximumAttempts());
7878
assertEquals("foo1", Workflow.getTypedSearchAttributes().get(CUSTOM_KEYWORD_SA));
7979
}
80+
// The memo is set on every continue-as-new below, so every run after the
81+
// first one should observe it once the test server propagates it.
82+
if (count <= INITIAL_COUNT - 2) {
83+
assertEquals("MyValue", Workflow.getMemo("myKey", String.class));
84+
} else {
85+
Assert.assertNull(Workflow.getMemo("myKey", String.class));
86+
}
8087
if (count == 0) {
8188
assertEquals(continueAsNewTaskQueue, taskQueue);
8289
return 111;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,9 @@ private static void continueAsNewWorkflow(
14671467
if (d.hasSearchAttributes()) {
14681468
a.setSearchAttributes(d.getSearchAttributes());
14691469
}
1470+
if (d.hasMemo()) {
1471+
a.setMemo(d.getMemo());
1472+
}
14701473
a.setNewExecutionRunId(UUID.randomUUID().toString());
14711474
HistoryEvent event =
14721475
HistoryEvent.newBuilder()

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,9 @@ public String continueAsNew(
17571757
if (ea.hasSearchAttributes()) {
17581758
startRequestBuilder.setSearchAttributes(ea.getSearchAttributes());
17591759
}
1760+
if (ea.hasMemo()) {
1761+
startRequestBuilder.setMemo(ea.getMemo());
1762+
}
17601763
StartWorkflowExecutionRequest startRequest = startRequestBuilder.build();
17611764
lock.lock();
17621765
Optional<Failure> lastFail =

0 commit comments

Comments
 (0)