Skip to content

Commit 8062870

Browse files
committed
Add test replaying history with VERSION_WAIT_FOR_MARKER set in
`sdkMetadata.langUsedFlags`
1 parent 908aa38 commit 8062870

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

temporal-sdk/src/test/java/io/temporal/workflow/versionTests/GetVersionInterleavedUpdateReplayTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.temporal.internal.history.VersionMarkerUtils;
2020
import io.temporal.internal.statemachines.WorkflowStateMachines;
2121
import io.temporal.testing.TestWorkflowEnvironment;
22+
import io.temporal.testing.WorkflowHistoryLoader;
2223
import io.temporal.testing.WorkflowReplayer;
2324
import io.temporal.testing.internal.SDKTestWorkflowRule;
2425
import io.temporal.worker.Worker;
@@ -44,6 +45,8 @@
4445
public class GetVersionInterleavedUpdateReplayTest {
4546
private static final String HISTORY_RESOURCE =
4647
"testGetVersionInterleavedUpdateReplayHistory.json";
48+
private static final String WAIT_FOR_MARKER_HISTORY_RESOURCE =
49+
"testGetVersionInterleavedUpdateReplayWaitForMarkerHistory.json";
4750
public static final String TASK_QUEUE = "get-version-interleaved-update-replay";
4851
private static final String EXPECTED_FIRST_CHANGE_ID = "ChangeId1";
4952
private static final String EXPECTED_SECOND_CHANGE_ID = "ChangeId2";
@@ -91,6 +94,25 @@ public void testReproducedHistoryReplays() throws Exception {
9194
WorkflowReplayer.replayWorkflowExecution(history, GreetingWorkflowImpl.class);
9295
}
9396

97+
@Test
98+
public void testReplayHistoryWithWaitForMarkerFlagReplaysWithoutDefaultEnable() throws Exception {
99+
WorkflowExecutionHistory history =
100+
WorkflowHistoryLoader.readHistoryFromResource(WAIT_FOR_MARKER_HISTORY_RESOURCE);
101+
assertTrue(
102+
"The recorded history must advertise VERSION_WAIT_FOR_MARKER.",
103+
hasSdkFlag(history, SdkFlag.VERSION_WAIT_FOR_MARKER));
104+
105+
List<SdkFlag> savedInitialFlags = WorkflowStateMachines.initialFlags;
106+
List<SdkFlag> replayFlags = new ArrayList<>(savedInitialFlags);
107+
replayFlags.remove(SdkFlag.VERSION_WAIT_FOR_MARKER);
108+
WorkflowStateMachines.initialFlags = Collections.unmodifiableList(replayFlags);
109+
try {
110+
WorkflowReplayer.replayWorkflowExecution(history, GreetingWorkflowImpl.class);
111+
} finally {
112+
WorkflowStateMachines.initialFlags = savedInitialFlags;
113+
}
114+
}
115+
94116
public static WorkflowExecutionHistory captureReplayableHistory() {
95117
List<SdkFlag> savedInitialFlags = WorkflowStateMachines.initialFlags;
96118
List<SdkFlag> replayableFlags = new ArrayList<>(savedInitialFlags);

0 commit comments

Comments
 (0)