Skip to content

Commit 6526468

Browse files
committed
chore: Run MM workflows tests in parallel
Signed-off-by: Javier Aliaga <[email protected]>
1 parent 33d91b2 commit 6526468

16 files changed

+109
-41
lines changed

examples/src/main/java/io/dapr/examples/workflows/README.md

Lines changed: 62 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,12 @@ expected_stdout_lines:
142142
- 'Message Received from input: Seattle'
143143
- 'Sending message to output: SEATTLE'
144144
- 'Workflow finished with result: TOKYO, LONDON, SEATTLE'
145+
timeout_seconds: 20
145146
background: true
146-
sleep: 60
147-
timeout_seconds: 60
148147
-->
149148
Execute the following script in order to run DemoChainWorker:
150149
```sh
151-
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainWorker
150+
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainWorker 50001
152151
```
153152

154153
Once running, the logs will start displaying the different steps: First, you can see workflow is starting:
@@ -158,9 +157,20 @@ Once running, the logs will start displaying the different steps: First, you can
158157
== APP == INFO: Durable Task worker is connecting to sidecar at 127.0.0.1:50001.
159158
```
160159

160+
<!-- END_STEP -->
161+
162+
<!-- STEP
163+
name: Execute Chaining Pattern workflow
164+
match_order: none
165+
output_match_mode: substring
166+
expected_stdout_lines:
167+
- 'completed with result: TOKYO, LONDON, SEATTLE'
168+
timeout_seconds: 20
169+
background: true
170+
-->
161171
Then, execute the following script in order to run DemoChainClient:
162172
```sh
163-
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient
173+
sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient 50001
164174
```
165175
<!-- END_STEP -->
166176

@@ -241,7 +251,7 @@ public class CountWordsActivity implements WorkflowActivity {
241251
}
242252
```
243253
<!-- STEP
244-
name: Run Chaining Pattern workflow
254+
name: Run FanInOut Pattern workflow
245255
match_order: none
246256
output_match_mode: substring
247257
expected_stdout_lines:
@@ -251,20 +261,30 @@ expected_stdout_lines:
251261
- 'Activity returned: 17.'
252262
- 'Activity returned: 11.'
253263
- 'Workflow finished with result: 60'
264+
timeout_seconds: 20
254265
background: true
255-
sleep: 60
256-
timeout_seconds: 60
257266
-->
258267

259268
Execute the following script in order to run DemoFanInOutWorker:
260269
```sh
261-
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutWorker
270+
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50002 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutWorker 50002
262271
```
263272

273+
<!-- END_STEP -->
274+
275+
<!-- STEP
276+
name: Execute FanInOut Pattern workflow
277+
match_order: none
278+
output_match_mode: substring
279+
expected_stdout_lines:
280+
- 'completed with result: 60'
281+
timeout_seconds: 20
282+
background: true
283+
-->
264284
Execute the following script in order to run DemoFanInOutClient:
265285

266286
```sh
267-
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient
287+
sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient 50002
268288
```
269289
<!-- END_STEP -->
270290

@@ -294,7 +314,6 @@ and the client:
294314
Started a new fan out/fan in model model workflow with instance ID: 092c1928-b5dd-4576-9468-300bf6aed986
295315
workflow instance with ID: 092c1928-b5dd-4576-9468-300bf6aed986 completed with result: 60
296316
```
297-
298317
### Continue As New Pattern
299318
`ContinueAsNew` API allows you to restart the workflow with a new input.
300319

@@ -606,8 +625,6 @@ expected_stdout_lines:
606625
- "Registered Activity: CancelCarActivity"
607626
- "Successfully built dapr workflow runtime"
608627
- "Start workflow runtime"
609-
- "Durable Task worker is connecting to sidecar at 127.0.0.1:50001."
610-
611628
- "Starting Workflow: io.dapr.examples.workflows.compensation.BookTripWorkflow"
612629
- "Starting Activity: io.dapr.examples.workflows.compensation.BookFlightActivity"
613630
- "Activity completed with result: Flight booked successfully"
@@ -625,18 +642,28 @@ expected_stdout_lines:
625642
- "Starting Activity: io.dapr.examples.workflows.compensation.CancelFlightActivity"
626643
- "Activity completed with result: Flight canceled successfully"
627644
background: true
628-
sleep: 60
629-
timeout_seconds: 60
645+
timeout_seconds: 30
630646
-->
631647

632648
Execute the following script in order to run the BookTripWorker:
633649
```sh
634-
dapr run --app-id book-trip-worker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripWorker
650+
dapr run --app-id book-trip-worker --resources-path ./components/workflows --dapr-grpc-port 50003 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripWorker 50003
635651
```
636652

653+
<!-- END_STEP -->
654+
655+
<!-- STEP
656+
name: Execute Compensation Pattern workflow
657+
match_order: none
658+
output_match_mode: substring
659+
expected_stdout_lines:
660+
- 'Workflow failed, compensation applied'
661+
timeout_seconds: 30
662+
background: true
663+
-->
637664
Once running, execute the following script to run the BookTripClient:
638665
```sh
639-
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient
666+
sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient 50003
640667
```
641668
<!-- END_STEP -->
642669

@@ -656,7 +683,7 @@ Key Points:
656683

657684
### Suspend/Resume Pattern
658685

659-
Workflow instances can be suspended and resumed. This example shows how to use the suspend and resume commands.
686+
Workflow instances can be suspended and resumed. This example shows how to use the suspend and resume commands.
660687

661688
For testing the suspend and resume operations we will use the same workflow definition used by the DemoExternalEventWorkflow.
662689

@@ -669,26 +696,35 @@ match_order: none
669696
output_match_mode: substring
670697
expected_stdout_lines:
671698
- "Waiting for approval..."
672-
- "Suspending Workflow Instance"
673-
- "Workflow Instance Status: SUSPENDED"
674-
- "Let's resume the Workflow Instance before sending the external event"
675-
- "Workflow Instance Status: RUNNING"
676-
- "Now that the instance is RUNNING again, lets send the external event."
677699
- "approval granted - do the approved action"
678700
- "Starting Activity: io.dapr.examples.workflows.externalevent.ApproveActivity"
679701
- "Running approval activity..."
680702
- "approval-activity finished"
681703
background: true
682-
sleep: 60
683-
timeout_seconds: 60
704+
timeout_seconds: 30
684705
-->
685706

686707
```sh
687-
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeWorker
708+
dapr run --app-id demoworkflowworker --resources-path ./components/workflows --dapr-grpc-port 50004 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeWorker 50004
688709
```
689710

711+
<!-- END_STEP -->
712+
713+
<!-- STEP
714+
name: Execute Suspend/Resume workflow
715+
match_order: none
716+
output_match_mode: substring
717+
expected_stdout_lines:
718+
- "Suspending Workflow Instance"
719+
- "Workflow Instance Status: SUSPENDED"
720+
- "Let's resume the Workflow Instance before sending the external event"
721+
- "Workflow Instance Status: RUNNING"
722+
- "Now that the instance is RUNNING again, lets send the external event."
723+
timeout_seconds: 30
724+
background: true
725+
-->
690726
```sh
691-
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient
727+
sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient 50004
692728
```
693729

694730
<!-- END_STEP -->

examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.chain;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.client.DaprWorkflowClient;
1718
import io.dapr.workflows.client.WorkflowInstanceStatus;
1819

@@ -26,7 +27,7 @@ public class DemoChainClient {
2627
* @throws InterruptedException If program has been interrupted.
2728
*/
2829
public static void main(String[] args) {
29-
try (DaprWorkflowClient client = new DaprWorkflowClient()) {
30+
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
3031
String instanceId = client.scheduleNewWorkflow(DemoChainWorkflow.class);
3132
System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId);
3233
WorkflowInstanceStatus workflowInstanceStatus =

examples/src/main/java/io/dapr/examples/workflows/chain/DemoChainWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.chain;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.runtime.WorkflowRuntime;
1718
import io.dapr.workflows.runtime.WorkflowRuntimeBuilder;
1819

@@ -25,7 +26,7 @@ public class DemoChainWorker {
2526
*/
2627
public static void main(String[] args) throws Exception {
2728
// Register the Workflow with the builder.
28-
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().registerWorkflow(DemoChainWorkflow.class);
29+
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).registerWorkflow(DemoChainWorkflow.class);
2930
builder.registerActivity(ToUpperCaseActivity.class);
3031

3132
// Build and then start the workflow runtime pulling and executing tasks

examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkerflowClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.childworkflow;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.client.DaprWorkflowClient;
1718
import io.dapr.workflows.client.WorkflowInstanceStatus;
1819

@@ -26,7 +27,7 @@ public class DemoChildWorkerflowClient {
2627
* @throws InterruptedException If program has been interrupted.
2728
*/
2829
public static void main(String[] args) {
29-
try (DaprWorkflowClient client = new DaprWorkflowClient()) {
30+
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
3031
String instanceId = client.scheduleNewWorkflow(DemoWorkflow.class);
3132
System.out.printf("Started a new child-workflow model workflow with instance ID: %s%n", instanceId);
3233
WorkflowInstanceStatus workflowInstanceStatus =

examples/src/main/java/io/dapr/examples/workflows/childworkflow/DemoChildWorkflowWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.childworkflow;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.runtime.WorkflowRuntime;
1718
import io.dapr.workflows.runtime.WorkflowRuntimeBuilder;
1819

@@ -25,7 +26,7 @@ public class DemoChildWorkflowWorker {
2526
*/
2627
public static void main(String[] args) throws Exception {
2728
// Register the Workflow with the builder.
28-
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder()
29+
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args))
2930
.registerWorkflow(DemoWorkflow.class)
3031
.registerWorkflow(DemoChildWorkflow.class);
3132
builder.registerActivity(ReverseActivity.class);

examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.compensation;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.client.DaprWorkflowClient;
1718
import io.dapr.workflows.client.WorkflowInstanceStatus;
1819

@@ -21,7 +22,7 @@
2122

2223
public class BookTripClient {
2324
public static void main(String[] args) {
24-
try (DaprWorkflowClient client = new DaprWorkflowClient()) {
25+
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
2526
String instanceId = client.scheduleNewWorkflow(BookTripWorkflow.class);
2627
System.out.printf("Started a new trip booking workflow with instance ID: %s%n", instanceId);
2728

examples/src/main/java/io/dapr/examples/workflows/compensation/BookTripWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313

1414
package io.dapr.examples.workflows.compensation;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.runtime.WorkflowRuntime;
1718
import io.dapr.workflows.runtime.WorkflowRuntimeBuilder;
1819

1920
public class BookTripWorker {
2021

2122
public static void main(String[] args) throws Exception {
2223
// Register the Workflow with the builder
23-
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder()
24+
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args))
2425
.registerWorkflow(BookTripWorkflow.class)
2526
.registerActivity(BookFlightActivity.class)
2627
.registerActivity(CancelFlightActivity.class)

examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.continueasnew;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.client.DaprWorkflowClient;
1718

1819
import java.util.concurrent.TimeoutException;
@@ -25,7 +26,7 @@ public class DemoContinueAsNewClient {
2526
* @throws InterruptedException If program has been interrupted.
2627
*/
2728
public static void main(String[] args) {
28-
try (DaprWorkflowClient client = new DaprWorkflowClient()) {
29+
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
2930
String instanceId = client.scheduleNewWorkflow(DemoContinueAsNewWorkflow.class);
3031
System.out.printf("Started a new continue-as-new model workflow with instance ID: %s%n", instanceId);
3132

examples/src/main/java/io/dapr/examples/workflows/continueasnew/DemoContinueAsNewWorker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
package io.dapr.examples.workflows.continueasnew;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.runtime.WorkflowRuntime;
1718
import io.dapr.workflows.runtime.WorkflowRuntimeBuilder;
1819

19-
import java.util.concurrent.ExecutorService;
2020
import java.util.concurrent.Executors;
2121

2222
public class DemoContinueAsNewWorker {
@@ -28,7 +28,7 @@ public class DemoContinueAsNewWorker {
2828
*/
2929
public static void main(String[] args) throws Exception {
3030
// Register the Workflow with the builder.
31-
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder().
31+
WorkflowRuntimeBuilder builder = new WorkflowRuntimeBuilder(PropertyUtils.getProperties(args)).
3232
registerWorkflow(DemoContinueAsNewWorkflow.class)
3333
.withExecutorService(Executors.newFixedThreadPool(3));
3434
builder.registerActivity(CleanUpActivity.class);

examples/src/main/java/io/dapr/examples/workflows/externalevent/DemoExternalEventClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
package io.dapr.examples.workflows.externalevent;
1515

16+
import io.dapr.examples.workflows.utils.PropertyUtils;
1617
import io.dapr.workflows.client.DaprWorkflowClient;
1718

1819
import java.util.concurrent.TimeoutException;
@@ -25,7 +26,7 @@ public class DemoExternalEventClient {
2526
* @throws InterruptedException If program has been interrupted.
2627
*/
2728
public static void main(String[] args) {
28-
try (DaprWorkflowClient client = new DaprWorkflowClient()) {
29+
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
2930
String instanceId = client.scheduleNewWorkflow(DemoExternalEventWorkflow.class);
3031
System.out.printf("Started a new external-event workflow with instance ID: %s%n", instanceId);
3132

0 commit comments

Comments
 (0)