mirror of https://github.com/dapr/java-sdk.git
Improve CI runs (#1527)
* chore: Wait for dapr script When running mechanical markdown examples wait for dapr to be running Signed-off-by: Javier Aliaga <javier@diagrid.io> * chore: Fix build ci Signed-off-by: Javier Aliaga <javier@diagrid.io> * chore: Fix build ci Signed-off-by: Javier Aliaga <javier@diagrid.io> --------- Signed-off-by: Javier Aliaga <javier@diagrid.io> Co-authored-by: salaboy <Salaboy@gmail.com>
This commit is contained in:
parent
0edc30a096
commit
6b0b79d04c
|
|
@ -112,18 +112,14 @@ jobs:
|
|||
wget -q ${{ env.TOXIPROXY_URL }} -O /home/runner/.local/bin/toxiproxy-server
|
||||
chmod +x /home/runner/.local/bin/toxiproxy-server
|
||||
/home/runner/.local/bin/toxiproxy-server --version
|
||||
- name: Clean up files
|
||||
run: ./mvnw clean -B
|
||||
- name: Build sdk
|
||||
run: ./mvnw compile -B -q
|
||||
- name: Clean up and install sdk
|
||||
run: ./mvnw clean install -B -q -DskipTests
|
||||
- name: Unit tests
|
||||
run: ./mvnw test # making it temporarily verbose.
|
||||
env:
|
||||
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v5.5.0
|
||||
- name: Install jars
|
||||
run: ./mvnw install -q -B -DskipTests
|
||||
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}
|
||||
id: integration_tests
|
||||
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -Pintegration-tests verify
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ background: true
|
|||
-->
|
||||
Execute the following script in order to run DemoChainWorker:
|
||||
```sh
|
||||
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
|
||||
dapr run --app-id chainingworker --resources-path ./components/workflows --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainWorker 50001
|
||||
```
|
||||
|
||||
Once running, the logs will start displaying the different steps: First, you can see workflow is starting:
|
||||
|
|
@ -169,7 +169,8 @@ timeout_seconds: 20
|
|||
-->
|
||||
Then, execute the following script in order to run DemoChainClient:
|
||||
```sh
|
||||
sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient 50001
|
||||
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.chain.DemoChainClient 50001
|
||||
dapr stop --app-id chainingworker
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
|
|
@ -266,7 +267,7 @@ background: true
|
|||
|
||||
Execute the following script in order to run DemoFanInOutWorker:
|
||||
```sh
|
||||
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
|
||||
dapr run --app-id faninoutworker --resources-path ./components/workflows --dapr-grpc-port 50002 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutWorker 50002
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -282,7 +283,8 @@ timeout_seconds: 20
|
|||
Execute the following script in order to run DemoFanInOutClient:
|
||||
|
||||
```sh
|
||||
sleep 10 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient 50002
|
||||
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.faninout.DemoFanInOutClient 50002
|
||||
dapr stop --app-id faninoutworker
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
|
|
@ -660,7 +662,8 @@ timeout_seconds: 30
|
|||
-->
|
||||
Once running, execute the following script to run the BookTripClient:
|
||||
```sh
|
||||
sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient 50003
|
||||
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.compensation.BookTripClient 50003
|
||||
dapr stop --app-id book-trip-worker
|
||||
```
|
||||
<!-- END_STEP -->
|
||||
|
||||
|
|
@ -702,7 +705,7 @@ timeout_seconds: 30
|
|||
-->
|
||||
|
||||
```sh
|
||||
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
|
||||
dapr run --app-id suspendresumeworker --resources-path ./components/workflows --dapr-grpc-port 50004 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeWorker 50004
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -720,7 +723,8 @@ expected_stdout_lines:
|
|||
timeout_seconds: 30
|
||||
-->
|
||||
```sh
|
||||
sleep 15 && java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient 50004
|
||||
java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.workflows.suspendresume.DemoSuspendResumeClient 50004
|
||||
dapr stop --app-id suspendresumeworker
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@ limitations under the License.
|
|||
package io.dapr.examples.workflows.chain;
|
||||
|
||||
import io.dapr.examples.workflows.utils.PropertyUtils;
|
||||
import io.dapr.examples.workflows.utils.RetryUtils;
|
||||
import io.dapr.workflows.client.DaprWorkflowClient;
|
||||
import io.dapr.workflows.client.WorkflowInstanceStatus;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class DemoChainClient {
|
||||
|
|
@ -28,15 +30,15 @@ public class DemoChainClient {
|
|||
*/
|
||||
public static void main(String[] args) {
|
||||
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
||||
String instanceId = client.scheduleNewWorkflow(DemoChainWorkflow.class);
|
||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(DemoChainWorkflow.class),
|
||||
Duration.ofSeconds(60));
|
||||
|
||||
System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId);
|
||||
WorkflowInstanceStatus workflowInstanceStatus =
|
||||
client.waitForInstanceCompletion(instanceId, null, true);
|
||||
|
||||
String result = workflowInstanceStatus.readOutputAs(String.class);
|
||||
System.out.printf("workflow instance with ID: %s completed with result: %s%n", instanceId, result);
|
||||
|
||||
|
||||
} catch (TimeoutException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ limitations under the License.
|
|||
package io.dapr.examples.workflows.compensation;
|
||||
|
||||
import io.dapr.examples.workflows.utils.PropertyUtils;
|
||||
import io.dapr.examples.workflows.utils.RetryUtils;
|
||||
import io.dapr.workflows.client.DaprWorkflowClient;
|
||||
import io.dapr.workflows.client.WorkflowInstanceStatus;
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ import java.util.concurrent.TimeoutException;
|
|||
public class BookTripClient {
|
||||
public static void main(String[] args) {
|
||||
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
||||
String instanceId = client.scheduleNewWorkflow(BookTripWorkflow.class);
|
||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(BookTripWorkflow.class), Duration.ofSeconds(60));
|
||||
System.out.printf("Started a new trip booking workflow with instance ID: %s%n", instanceId);
|
||||
|
||||
WorkflowInstanceStatus status = client.waitForInstanceCompletion(instanceId, Duration.ofMinutes(30), true);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ limitations under the License.
|
|||
package io.dapr.examples.workflows.faninout;
|
||||
|
||||
import io.dapr.examples.workflows.utils.PropertyUtils;
|
||||
import io.dapr.examples.workflows.utils.RetryUtils;
|
||||
import io.dapr.workflows.client.DaprWorkflowClient;
|
||||
import io.dapr.workflows.client.WorkflowInstanceStatus;
|
||||
|
||||
|
|
@ -40,9 +41,10 @@ public class DemoFanInOutClient {
|
|||
"Always remember that you are absolutely unique. Just like everyone else.");
|
||||
|
||||
// Schedule an orchestration which will reliably count the number of words in all the given sentences.
|
||||
String instanceId = client.scheduleNewWorkflow(
|
||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(
|
||||
DemoFanInOutWorkflow.class,
|
||||
listOfStrings);
|
||||
listOfStrings), Duration.ofSeconds(60));
|
||||
|
||||
System.out.printf("Started a new fan out/fan in model workflow with instance ID: %s%n", instanceId);
|
||||
|
||||
// Block until the orchestration completes. Then print the final status, which includes the output.
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@ package io.dapr.examples.workflows.suspendresume;
|
|||
|
||||
import io.dapr.examples.workflows.externalevent.DemoExternalEventWorkflow;
|
||||
import io.dapr.examples.workflows.utils.PropertyUtils;
|
||||
import io.dapr.examples.workflows.utils.RetryUtils;
|
||||
import io.dapr.workflows.client.DaprWorkflowClient;
|
||||
import io.dapr.workflows.client.WorkflowInstanceStatus;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
public class DemoSuspendResumeClient {
|
||||
|
|
@ -29,7 +31,7 @@ public class DemoSuspendResumeClient {
|
|||
*/
|
||||
public static void main(String[] args) {
|
||||
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
||||
String instanceId = client.scheduleNewWorkflow(DemoExternalEventWorkflow.class);
|
||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(DemoExternalEventWorkflow.class), Duration.ofSeconds(60));
|
||||
System.out.printf("Started a new external-event workflow with instance ID: %s%n", instanceId);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* 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.examples.workflows.utils;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class RetryUtils {
|
||||
private static final long RETRY_WAIT_MILLISECONDS = 1000;
|
||||
|
||||
public static String callWithRetry(Callable<String> function, Duration retryTimeout) throws InterruptedException {
|
||||
var retryTimeoutMilliseconds = retryTimeout.toMillis();
|
||||
long started = System.currentTimeMillis();
|
||||
while (true) {
|
||||
Throwable exception;
|
||||
try {
|
||||
return function.call();
|
||||
} catch (Exception | AssertionError e) {
|
||||
exception = e;
|
||||
}
|
||||
|
||||
long elapsed = System.currentTimeMillis() - started;
|
||||
if (elapsed >= retryTimeoutMilliseconds) {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
|
||||
long remaining = retryTimeoutMilliseconds - elapsed;
|
||||
Thread.sleep(Math.min(remaining, RETRY_WAIT_MILLISECONDS));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
12
pom.xml
12
pom.xml
|
|
@ -658,6 +658,18 @@
|
|||
<modules>
|
||||
<module>sdk-tests</module>
|
||||
</modules>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
|
|
|||
|
|
@ -315,18 +315,6 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!--suppress UnresolvedMavenProperty -->
|
||||
<skip>${skipITs}</skip>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- 'TOKYO, LONDON, SEATTLE'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
|
@ -73,7 +72,7 @@ timeout_seconds: 90
|
|||
To start the workflow with the three chained activities you can run:
|
||||
|
||||
```sh
|
||||
sleep 35 && curl -X POST localhost:8080/wfp/chain -H 'Content-Type: application/json'
|
||||
curl -X POST localhost:8080/wfp/chain -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -142,7 +141,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- '!wolfkroW rpaD olleH'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
|
@ -150,7 +148,7 @@ timeout_seconds: 90
|
|||
To start the workflow with the three chained activities you can run:
|
||||
|
||||
```sh
|
||||
sleep 35 && curl -X POST localhost:8080/wfp/child -H 'Content-Type: application/json'
|
||||
curl -X POST localhost:8080/wfp/child -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -191,13 +189,12 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- '{"cleanUpTimes":5}'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
||||
```sh
|
||||
sleep 30 && curl -X POST localhost:8080/wfp/continueasnew -H 'Content-Type: application/json'
|
||||
curl -X POST localhost:8080/wfp/continueasnew -H 'Content-Type: application/json' --retry 10 --max-time 60 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -260,13 +257,12 @@ To start the workflow you can run:
|
|||
name: Start External Event Workflow
|
||||
match_order: none
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
||||
```sh
|
||||
sleep 30 && curl -X POST "localhost:8080/wfp/externalevent?orderId=123" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/externalevent?orderId=123" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -290,7 +286,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- '{"approved":true}'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
|
@ -298,7 +293,7 @@ timeout_seconds: 90
|
|||
To send the event you can run:
|
||||
|
||||
```sh
|
||||
sleep 42 && curl -X POST "localhost:8080/wfp/externalevent-continue?orderId=123&decision=true" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/externalevent-continue?orderId=123&decision=true" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -346,13 +341,12 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- '{"wordCount":60}'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
||||
```sh
|
||||
sleep 45 && curl -X POST localhost:8080/wfp/fanoutin -H 'Content-Type: application/json' -d @body.json
|
||||
curl -X POST localhost:8080/wfp/fanoutin -H 'Content-Type: application/json' -d @body.json --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -398,13 +392,12 @@ To start the workflow, you can run:
|
|||
name: Start Suspend/Resume Workflow
|
||||
match_order: none
|
||||
output_match_mode: substring
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
||||
```sh
|
||||
sleep 50 && curl -X POST "localhost:8080/wfp/suspendresume?orderId=456" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/suspendresume?orderId=456" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -431,7 +424,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- 'SUSPENDED'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
|
||||
|
|
@ -439,7 +431,7 @@ timeout_seconds: 90
|
|||
Let's suspend the workflow instance by sending the following request:
|
||||
|
||||
```sh
|
||||
sleep 55 && curl -X POST "localhost:8080/wfp/suspendresume/suspend?orderId=456" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/suspendresume/suspend?orderId=456" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -459,7 +451,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- 'RUNNING'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
|
||||
|
|
@ -467,7 +458,7 @@ timeout_seconds: 90
|
|||
To send the event you can run:
|
||||
|
||||
```sh
|
||||
sleep 60 && curl -X POST "localhost:8080/wfp/suspendresume/resume?orderId=456" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/suspendresume/resume?orderId=456" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
@ -487,7 +478,6 @@ match_order: none
|
|||
output_match_mode: substring
|
||||
expected_stdout_lines:
|
||||
- '{"approved":true}'
|
||||
background: true
|
||||
timeout_seconds: 90
|
||||
-->
|
||||
<!-- Timeout for above service must be more than sleep + timeout for the client-->
|
||||
|
|
@ -495,7 +485,7 @@ timeout_seconds: 90
|
|||
To send the event you can run:
|
||||
|
||||
```sh
|
||||
sleep 65 && curl -X POST "localhost:8080/wfp/suspendresume/continue?orderId=456&decision=true" -H 'Content-Type: application/json'
|
||||
curl -X POST "localhost:8080/wfp/suspendresume/continue?orderId=456&decision=true" -H 'Content-Type: application/json' --retry 10 --max-time 20 --retry-all-errors --retry-max-time 90
|
||||
```
|
||||
|
||||
<!-- END_STEP -->
|
||||
|
|
|
|||
Loading…
Reference in New Issue