-
Notifications
You must be signed in to change notification settings - Fork 224
chore: New task execution task id test #1352
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3c7e413
chore: New task execution task id test
javier-aliaga 3434802
chore: Clean up not used files
javier-aliaga 90b11d6
docs: Task execution keys
javier-aliaga 5557439
test: Modify unit tests
javier-aliaga da29688
Merge branch 'master' into ja-task-idempotency-keys
cicoyle 8869369
Merge branch 'master' into ja-task-idempotency-keys
cicoyle 2eb20e6
Remove new lines
artur-ciocanu 34715a9
Merge branch 'master' into ja-task-idempotency-keys
artur-ciocanu 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
51 changes: 51 additions & 0 deletions
51
sdk-tests/src/test/java/io/dapr/it/testcontainers/KeyStore.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,51 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file 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.dapr.it.testcontainers; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class KeyStore { | ||
|
|
||
| private final Map<String, Boolean> keyStore = new HashMap<>(); | ||
|
|
||
| private static KeyStore instance; | ||
|
|
||
| private KeyStore() { | ||
| } | ||
|
|
||
| public static KeyStore getInstance() { | ||
| if (instance == null) { | ||
| synchronized (KeyStore.class) { | ||
| if (instance == null) { | ||
| instance = new KeyStore(); | ||
| } | ||
| } | ||
| } | ||
| return instance; | ||
| } | ||
|
|
||
|
|
||
| public void addKey(String key, Boolean value) { | ||
| keyStore.put(key, value); | ||
| } | ||
|
|
||
| public Boolean getKey(String key) { | ||
| return keyStore.get(key); | ||
| } | ||
|
|
||
| public void removeKey(String key) { | ||
| keyStore.remove(key); | ||
| } | ||
|
|
||
| } |
35 changes: 35 additions & 0 deletions
35
sdk-tests/src/test/java/io/dapr/it/testcontainers/TaskExecutionKeyActivity.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,35 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file 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.dapr.it.testcontainers; | ||
|
|
||
| import io.dapr.workflows.WorkflowActivity; | ||
| import io.dapr.workflows.WorkflowActivityContext; | ||
|
|
||
| public class TaskExecutionKeyActivity implements WorkflowActivity { | ||
|
|
||
| @Override | ||
| public Object run(WorkflowActivityContext ctx) { | ||
| TestWorkflowPayload workflowPayload = ctx.getInput(TestWorkflowPayload.class); | ||
| KeyStore keyStore = KeyStore.getInstance(); | ||
| Boolean exists = keyStore.getKey(ctx.getTaskExecutionKey()); | ||
| if (!Boolean.TRUE.equals(exists)) { | ||
| keyStore.addKey(ctx.getTaskExecutionKey(), true); | ||
| workflowPayload.getPayloads().add("Execution key not found"); | ||
| throw new IllegalStateException("Task execution key not found"); | ||
| } | ||
| workflowPayload.getPayloads().add("Execution key found"); | ||
| return workflowPayload; | ||
| } | ||
|
|
||
| } |
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
58 changes: 58 additions & 0 deletions
58
sdk-tests/src/test/java/io/dapr/it/testcontainers/TestExecutionKeysWorkflow.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,58 @@ | ||
| /* | ||
| * Copyright 2025 The Dapr Authors | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file 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.dapr.it.testcontainers; | ||
|
|
||
| import io.dapr.durabletask.Task; | ||
| import io.dapr.workflows.Workflow; | ||
| import io.dapr.workflows.WorkflowStub; | ||
| import io.dapr.workflows.WorkflowTaskOptions; | ||
| import io.dapr.workflows.WorkflowTaskRetryPolicy; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| import org.slf4j.Logger; | ||
|
|
||
| public class TestExecutionKeysWorkflow implements Workflow { | ||
|
|
||
| @Override | ||
| public WorkflowStub create() { | ||
| return ctx -> { | ||
|
|
||
| Logger logger = ctx.getLogger(); | ||
| String instanceId = ctx.getInstanceId(); | ||
| logger.info("Starting Workflow: " + ctx.getName()); | ||
| logger.info("Instance ID: " + instanceId); | ||
| logger.info("Current Orchestration Time: " + ctx.getCurrentInstant()); | ||
|
|
||
| TestWorkflowPayload workflowPayload = ctx.getInput(TestWorkflowPayload.class); | ||
| workflowPayload.setWorkflowId(instanceId); | ||
|
|
||
| WorkflowTaskOptions options = new WorkflowTaskOptions(WorkflowTaskRetryPolicy.newBuilder() | ||
| .setMaxNumberOfAttempts(3) | ||
| .setFirstRetryInterval(Duration.ofSeconds(1)) | ||
| .setMaxRetryInterval(Duration.ofSeconds(10)) | ||
| .setBackoffCoefficient(2.0) | ||
| .setRetryTimeout(Duration.ofSeconds(50)) | ||
| .build()); | ||
|
|
||
|
|
||
| Task<TestWorkflowPayload> t = ctx.callActivity(TaskExecutionKeyActivity.class.getName(), workflowPayload, options,TestWorkflowPayload.class); | ||
|
|
||
| TestWorkflowPayload payloadAfterExecution = t.await(); | ||
|
|
||
| ctx.complete(payloadAfterExecution); | ||
| }; | ||
| } | ||
|
|
||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.