-
Notifications
You must be signed in to change notification settings - Fork 203
Wait for MARKER_RECORDED to fire version callback on replay #2821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
eamsden
wants to merge
7
commits into
master
Choose a base branch
from
eamsden/interleaved-UpdateCompleted-getversion
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a5d3f33
Add interleaved update replay reproducer
eamsden c436443
Add replay ordering reproducer for interleaved updates
eamsden 3c8d82e
Delay flagged version replay callback to marker match
eamsden 0164b45
Delay version replay callback until marker match
eamsden c7b2d39
Doc comments for new regression tests.
eamsden 43ab9df
Gate VersionStateMachine behavior correction behind new sdk flag
eamsden 1cf683a
Disable recorded-history replay test for interleaved histories, since we
eamsden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...st/java/io/temporal/internal/replay/GetVersionInterleavedUpdateReplayTaskHandlerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| package io.temporal.internal.replay; | ||
|
|
||
| import static org.junit.Assert.assertEquals; | ||
| import static org.junit.Assert.assertFalse; | ||
| import static org.junit.Assert.assertNotNull; | ||
|
|
||
| import com.uber.m3.tally.NoopScope; | ||
| import io.temporal.api.query.v1.WorkflowQuery; | ||
| import io.temporal.api.workflowservice.v1.PollWorkflowTaskQueueResponse; | ||
| import io.temporal.client.WorkflowClient; | ||
| import io.temporal.common.WorkflowExecutionHistory; | ||
| import io.temporal.internal.worker.QueryReplayHelper; | ||
| import io.temporal.serviceclient.WorkflowServiceStubs; | ||
| import io.temporal.testing.TestWorkflowEnvironment; | ||
| import io.temporal.worker.Worker; | ||
| import io.temporal.workflow.versionTests.GetVersionInterleavedUpdateReplayTest; | ||
| import io.temporal.workflow.versionTests.GetVersionInterleavedUpdateReplayTest.GreetingWorkflowImpl; | ||
| import java.lang.reflect.Field; | ||
| import java.lang.reflect.Method; | ||
| import java.util.Arrays; | ||
| import org.junit.Test; | ||
|
|
||
| public class GetVersionInterleavedUpdateReplayTaskHandlerTest { | ||
| private static final String EXPECTED_FIRST_CHANGE_ID = "ChangeId1"; | ||
| private static final String EXPECTED_SECOND_CHANGE_ID = "ChangeId2"; | ||
|
|
||
| /** Regression test for the lower-level replay path behind the public replayer API. */ | ||
| @Test | ||
| public void testReplayDirectQueryWorkflowTaskSucceeds() throws Throwable { | ||
| WorkflowExecutionHistory history = | ||
| GetVersionInterleavedUpdateReplayTest.captureReplayableHistory(); | ||
| assertEquals( | ||
| Arrays.asList(EXPECTED_FIRST_CHANGE_ID, EXPECTED_SECOND_CHANGE_ID), | ||
| GetVersionInterleavedUpdateReplayTest.extractVersionChangeIds(history.getEvents())); | ||
|
|
||
| TestWorkflowEnvironment testEnvironment = TestWorkflowEnvironment.newInstance(); | ||
| ReplayWorkflowRunTaskHandler runTaskHandler = null; | ||
| try { | ||
| Worker worker = testEnvironment.newWorker(GetVersionInterleavedUpdateReplayTest.TASK_QUEUE); | ||
| worker.registerWorkflowImplementationTypes(GreetingWorkflowImpl.class); | ||
|
|
||
| ReplayWorkflowTaskHandler replayTaskHandler = getNonStickyReplayTaskHandler(worker); | ||
| PollWorkflowTaskQueueResponse.Builder replayTask = newReplayTask(history); | ||
| runTaskHandler = createStatefulHandler(replayTaskHandler, replayTask); | ||
|
|
||
| WorkflowServiceStubs service = | ||
| getField(replayTaskHandler, "service", WorkflowServiceStubs.class); | ||
| String namespace = getField(replayTaskHandler, "namespace", String.class); | ||
| ServiceWorkflowHistoryIterator historyIterator = | ||
| new ServiceWorkflowHistoryIterator(service, namespace, replayTask, new NoopScope()); | ||
|
|
||
| QueryResult result = | ||
| runTaskHandler.handleDirectQueryWorkflowTask(replayTask, historyIterator); | ||
| assertNotNull(result); | ||
| assertFalse(result.isWorkflowMethodCompleted()); | ||
| assertFalse(result.getResponsePayloads().isPresent()); | ||
| } finally { | ||
| if (runTaskHandler != null) { | ||
| runTaskHandler.close(); | ||
| } | ||
| testEnvironment.close(); | ||
| } | ||
| } | ||
|
|
||
| private static PollWorkflowTaskQueueResponse.Builder newReplayTask( | ||
| WorkflowExecutionHistory history) { | ||
| return PollWorkflowTaskQueueResponse.newBuilder() | ||
| .setWorkflowExecution(history.getWorkflowExecution()) | ||
| .setWorkflowType( | ||
| history | ||
| .getHistory() | ||
| .getEvents(0) | ||
| .getWorkflowExecutionStartedEventAttributes() | ||
| .getWorkflowType()) | ||
| .setStartedEventId(Long.MAX_VALUE) | ||
| .setPreviousStartedEventId(Long.MAX_VALUE) | ||
| .setHistory(history.getHistory()) | ||
| .setQuery(WorkflowQuery.newBuilder().setQueryType(WorkflowClient.QUERY_TYPE_REPLAY_ONLY)); | ||
| } | ||
|
|
||
| private static ReplayWorkflowTaskHandler getNonStickyReplayTaskHandler(Worker worker) | ||
| throws Exception { | ||
| Object workflowWorker = getField(worker, "workflowWorker", Object.class); | ||
| QueryReplayHelper queryReplayHelper = | ||
| getField(workflowWorker, "queryReplayHelper", QueryReplayHelper.class); | ||
| return getField(queryReplayHelper, "handler", ReplayWorkflowTaskHandler.class); | ||
| } | ||
|
|
||
| private static ReplayWorkflowRunTaskHandler createStatefulHandler( | ||
| ReplayWorkflowTaskHandler replayTaskHandler, PollWorkflowTaskQueueResponse.Builder replayTask) | ||
| throws Exception { | ||
| Method method = | ||
| ReplayWorkflowTaskHandler.class.getDeclaredMethod( | ||
| "createStatefulHandler", | ||
| PollWorkflowTaskQueueResponse.Builder.class, | ||
| com.uber.m3.tally.Scope.class); | ||
| method.setAccessible(true); | ||
| return (ReplayWorkflowRunTaskHandler) | ||
| method.invoke(replayTaskHandler, replayTask, new NoopScope()); | ||
| } | ||
|
|
||
| private static <T> T getField(Object target, String fieldName, Class<T> expectedType) | ||
| throws Exception { | ||
| Field field = target.getClass().getDeclaredField(fieldName); | ||
| field.setAccessible(true); | ||
| return expectedType.cast(field.get(target)); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're getting more of these. We should think ahead at how to make sure this remains maintainable in the future.
Would you mind adding some comments on this flag and others above, indicating: