-
Notifications
You must be signed in to change notification settings - Fork 148
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
Don't schedule LA on completed workflow #1902
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 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 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 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
60 changes: 60 additions & 0 deletions
60
temporal-sdk/src/test/java/io/temporal/workflow/CommandInTheLastWorkflowTaskTest.java
This file contains 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,60 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.workflow; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import io.temporal.testing.internal.SDKTestWorkflowRule; | ||
import io.temporal.workflow.shared.TestActivities; | ||
import io.temporal.workflow.shared.TestWorkflows; | ||
import java.util.Objects; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class CommandInTheLastWorkflowTaskTest { | ||
@Rule | ||
public SDKTestWorkflowRule testWorkflowRule = | ||
SDKTestWorkflowRule.newBuilder() | ||
.setWorkflowTypes(TestWorkflowImpl.class) | ||
.setActivityImplementations(new TestActivities.TestActivitiesImpl()) | ||
.build(); | ||
|
||
@Test | ||
public void testCommandInTheLastWorkflowTask() { | ||
TestWorkflows.TestWorkflowReturnString client = | ||
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class); | ||
assertEquals("done", client.execute()); | ||
} | ||
|
||
public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString { | ||
|
||
@Override | ||
public String execute() { | ||
Async.procedure( | ||
() -> { | ||
Workflow.mutableSideEffect( | ||
"id1", Integer.class, (o, n) -> Objects.equals(n, o), () -> 0); | ||
}); | ||
|
||
return "done"; | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...k/src/test/java/io/temporal/workflow/activityTests/ActivityInTheLastWorkflowTaskTest.java
This file contains 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,65 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.workflow.activityTests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import io.temporal.activity.ActivityOptions; | ||
import io.temporal.testing.internal.SDKTestWorkflowRule; | ||
import io.temporal.workflow.Async; | ||
import io.temporal.workflow.Workflow; | ||
import io.temporal.workflow.shared.TestActivities; | ||
import io.temporal.workflow.shared.TestWorkflows; | ||
import java.time.Duration; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class ActivityInTheLastWorkflowTaskTest { | ||
@Rule | ||
public SDKTestWorkflowRule testWorkflowRule = | ||
SDKTestWorkflowRule.newBuilder() | ||
.setWorkflowTypes(TestWorkflowImpl.class) | ||
.setActivityImplementations(new TestActivities.TestActivitiesImpl()) | ||
.build(); | ||
|
||
@Test | ||
public void testActivityInTheLastWorkflowTask() { | ||
TestWorkflows.TestWorkflowReturnString client = | ||
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class); | ||
assertEquals("done", client.execute()); | ||
} | ||
|
||
public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString { | ||
|
||
private final TestActivities.VariousTestActivities activities = | ||
Workflow.newActivityStub( | ||
TestActivities.VariousTestActivities.class, | ||
ActivityOptions.newBuilder() | ||
.setScheduleToCloseTimeout(Duration.ofSeconds(200)) | ||
.build()); | ||
|
||
@Override | ||
public String execute() { | ||
Async.procedure(activities::sleepActivity, (long) 1000, 0); | ||
return "done"; | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
.../test/java/io/temporal/workflow/activityTests/LocalActivityInTheLastWorkflowTaskTest.java
This file contains 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,65 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.workflow.activityTests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import io.temporal.activity.LocalActivityOptions; | ||
import io.temporal.testing.internal.SDKTestWorkflowRule; | ||
import io.temporal.workflow.Async; | ||
import io.temporal.workflow.Workflow; | ||
import io.temporal.workflow.shared.TestActivities; | ||
import io.temporal.workflow.shared.TestWorkflows; | ||
import java.time.Duration; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class LocalActivityInTheLastWorkflowTaskTest { | ||
@Rule | ||
public SDKTestWorkflowRule testWorkflowRule = | ||
SDKTestWorkflowRule.newBuilder() | ||
.setWorkflowTypes(TestWorkflowImpl.class) | ||
.setActivityImplementations(new TestActivities.TestActivitiesImpl()) | ||
.build(); | ||
|
||
@Test | ||
public void testLocalActivityInTheLastWorkflowTask() { | ||
TestWorkflows.TestWorkflowReturnString client = | ||
testWorkflowRule.newWorkflowStub(TestWorkflows.TestWorkflowReturnString.class); | ||
assertEquals("done", client.execute()); | ||
} | ||
|
||
public static class TestWorkflowImpl implements TestWorkflows.TestWorkflowReturnString { | ||
|
||
private final TestActivities.VariousTestActivities activities = | ||
Workflow.newLocalActivityStub( | ||
TestActivities.VariousTestActivities.class, | ||
LocalActivityOptions.newBuilder() | ||
.setScheduleToCloseTimeout(Duration.ofSeconds(200)) | ||
.build()); | ||
|
||
@Override | ||
public String execute() { | ||
Async.procedure(activities::sleepActivity, (long) 1000, 0); | ||
return "done"; | ||
} | ||
} | ||
} |
This file contains 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
71 changes: 71 additions & 0 deletions
71
...va/io/temporal/workflow/signalTests/SignalWithLocalActivityInTheLastWorkflowTaskTest.java
This file contains 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,71 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.temporal.workflow.signalTests; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import io.temporal.activity.LocalActivityOptions; | ||
import io.temporal.client.WorkflowStub; | ||
import io.temporal.testing.internal.SDKTestWorkflowRule; | ||
import io.temporal.workflow.Workflow; | ||
import io.temporal.workflow.shared.TestActivities; | ||
import io.temporal.workflow.shared.TestWorkflows; | ||
import java.time.Duration; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
public class SignalWithLocalActivityInTheLastWorkflowTaskTest { | ||
@Rule | ||
public SDKTestWorkflowRule testWorkflowRule = | ||
SDKTestWorkflowRule.newBuilder() | ||
.setWorkflowTypes(TestSignalWorkflowImpl.class) | ||
.setActivityImplementations(new TestActivities.TestActivitiesImpl()) | ||
.build(); | ||
|
||
@Test | ||
public void testSignalWithLocalActivityInTheLastWorkflowTask() { | ||
TestWorkflows.TestSignaledWorkflow client = | ||
testWorkflowRule.newWorkflowStub(TestWorkflows.TestSignaledWorkflow.class); | ||
WorkflowStub.fromTyped(client) | ||
.signalWithStart("testSignal", new String[] {"signalValue"}, new String[] {}); | ||
assertEquals("done", client.execute()); | ||
} | ||
|
||
public static class TestSignalWorkflowImpl implements TestWorkflows.TestSignaledWorkflow { | ||
|
||
private final TestActivities.VariousTestActivities activities = | ||
Workflow.newLocalActivityStub( | ||
TestActivities.VariousTestActivities.class, | ||
LocalActivityOptions.newBuilder() | ||
.setScheduleToCloseTimeout(Duration.ofSeconds(200)) | ||
.build()); | ||
|
||
@Override | ||
public String execute() { | ||
return "done"; | ||
} | ||
|
||
@Override | ||
public void signal(String arg) { | ||
activities.sleepActivity(1000, 0); | ||
} | ||
} | ||
} |
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.
Can you help me understand what is the exact behavior today? Do we start the LA but the server fails to accept the result marker command since workflows are done? Are there any concerns that people starting LAs at end of workflow but not waiting on them still expect that code to be reached and we are not calling it anymore?
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.
Correct
I don't have any concern here because if someone was starting LAs at end of workflow but not waiting on them their workflow could never complete