mirror of https://github.com/dapr/java-sdk.git
chore: Fix build ci
Signed-off-by: Javier Aliaga <javier@diagrid.io>
This commit is contained in:
parent
ddbecba409
commit
bd643b6d49
|
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
wait_for_dapr() {
|
|
||||||
local port="${1:-3500}"
|
|
||||||
local max_tries="${2:-60}"
|
|
||||||
local url="http://localhost:${port}/v1.0/healthz"
|
|
||||||
local code=""
|
|
||||||
|
|
||||||
for i in $(seq 1 "$max_tries"); do
|
|
||||||
code=$(curl -s -o /dev/null -w "%{http_code}" "$url" || true)
|
|
||||||
if [ "$code" = "204" ]; then
|
|
||||||
echo "Ready (204) on port ${port}"
|
|
||||||
return 0 # do not exit; just return
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "Timeout after ${max_tries}s waiting for 204 on port ${port} (last code: ${code})"
|
|
||||||
return 0 # keep returning success to avoid exiting callers using set -e
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example usage:
|
|
||||||
# wait_for_dapr # uses defaults: port 3500, tries 60
|
|
||||||
# wait_for_dapr 3501 # custom port, default tries
|
|
||||||
# wait_for_dapr 3501 30 # custom port and tries
|
|
||||||
|
|
@ -112,18 +112,14 @@ jobs:
|
||||||
wget -q ${{ env.TOXIPROXY_URL }} -O /home/runner/.local/bin/toxiproxy-server
|
wget -q ${{ env.TOXIPROXY_URL }} -O /home/runner/.local/bin/toxiproxy-server
|
||||||
chmod +x /home/runner/.local/bin/toxiproxy-server
|
chmod +x /home/runner/.local/bin/toxiproxy-server
|
||||||
/home/runner/.local/bin/toxiproxy-server --version
|
/home/runner/.local/bin/toxiproxy-server --version
|
||||||
- name: Clean up files
|
- name: Clean up and install sdk
|
||||||
run: ./mvnw clean -B
|
run: ./mvnw clean install -B -q -DskipTests
|
||||||
- name: Build sdk
|
|
||||||
run: ./mvnw compile -B -q
|
|
||||||
- name: Unit tests
|
- name: Unit tests
|
||||||
run: ./mvnw test # making it temporarily verbose.
|
run: ./mvnw test # making it temporarily verbose.
|
||||||
env:
|
env:
|
||||||
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
|
DOCKER_HOST: ${{steps.setup_docker.outputs.sock}}
|
||||||
- name: Codecov
|
- name: Codecov
|
||||||
uses: codecov/codecov-action@v5.5.0
|
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 }}
|
- name: Integration tests using spring boot version ${{ matrix.spring-boot-version }}
|
||||||
id: integration_tests
|
id: integration_tests
|
||||||
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -Pintegration-tests verify
|
run: PRODUCT_SPRING_BOOT_VERSION=${{ matrix.spring-boot-version }} ./mvnw -B -Pintegration-tests verify
|
||||||
|
|
|
||||||
|
|
@ -30,15 +30,15 @@ public class DemoChainClient {
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
||||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(DemoChainWorkflow.class),
|
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(DemoChainWorkflow.class),
|
||||||
Duration.ofSeconds(60));
|
Duration.ofSeconds(60));
|
||||||
|
|
||||||
System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId);
|
System.out.printf("Started a new chaining model workflow with instance ID: %s%n", instanceId);
|
||||||
WorkflowInstanceStatus workflowInstanceStatus =
|
WorkflowInstanceStatus workflowInstanceStatus =
|
||||||
client.waitForInstanceCompletion(instanceId, null, true);
|
client.waitForInstanceCompletion(instanceId, null, true);
|
||||||
|
|
||||||
String result = workflowInstanceStatus.readOutputAs(String.class);
|
String result = workflowInstanceStatus.readOutputAs(String.class);
|
||||||
System.out.printf("workflow instance with ID: %s completed with result: %s%n", instanceId, result);
|
System.out.printf("workflow instance with ID: %s completed with result: %s%n", instanceId, result);
|
||||||
} catch (TimeoutException | InterruptedException e) {
|
} catch (TimeoutException | InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,11 @@ public class DemoFanInOutClient {
|
||||||
"Always remember that you are absolutely unique. Just like everyone else.");
|
"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.
|
// Schedule an orchestration which will reliably count the number of words in all the given sentences.
|
||||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(
|
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(
|
||||||
DemoFanInOutWorkflow.class,
|
DemoFanInOutWorkflow.class,
|
||||||
listOfStrings), Duration.ofSeconds(60));
|
listOfStrings), Duration.ofSeconds(60));
|
||||||
|
|
||||||
|
System.out.printf("Started a new fan out/fan in model workflow with instance ID: %s%n", instanceId);
|
||||||
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.
|
// Block until the orchestration completes. Then print the final status, which includes the output.
|
||||||
WorkflowInstanceStatus workflowInstanceStatus = client.waitForInstanceCompletion(
|
WorkflowInstanceStatus workflowInstanceStatus = client.waitForInstanceCompletion(
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public class DemoSuspendResumeClient {
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
try (DaprWorkflowClient client = new DaprWorkflowClient(PropertyUtils.getProperties(args))) {
|
||||||
String instanceId = RetryUtils.callWithRetry(() -> client.scheduleNewWorkflow(DemoExternalEventWorkflow.class), Duration.ofSeconds(60));
|
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);
|
System.out.printf("Started a new external-event workflow with instance ID: %s%n", instanceId);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,31 +4,31 @@ import java.time.Duration;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class RetryUtils {
|
public class RetryUtils {
|
||||||
private static final long RETRY_WAIT_MILLISECONDS = 1000;
|
private static final long RETRY_WAIT_MILLISECONDS = 1000;
|
||||||
|
|
||||||
public static String callWithRetry(Callable<String> function, Duration retryTimeout) throws InterruptedException {
|
public static String callWithRetry(Callable<String> function, Duration retryTimeout) throws InterruptedException {
|
||||||
var retryTimeoutMilliseconds = retryTimeout.toMillis();
|
var retryTimeoutMilliseconds = retryTimeout.toMillis();
|
||||||
long started = System.currentTimeMillis();
|
long started = System.currentTimeMillis();
|
||||||
while (true) {
|
while (true) {
|
||||||
Throwable exception;
|
Throwable exception;
|
||||||
try {
|
try {
|
||||||
return function.call();
|
return function.call();
|
||||||
} catch (Exception | AssertionError e) {
|
} catch (Exception | AssertionError e) {
|
||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
long elapsed = System.currentTimeMillis() - started;
|
long elapsed = System.currentTimeMillis() - started;
|
||||||
if (elapsed >= retryTimeoutMilliseconds) {
|
if (elapsed >= retryTimeoutMilliseconds) {
|
||||||
if (exception instanceof RuntimeException) {
|
if (exception instanceof RuntimeException) {
|
||||||
throw (RuntimeException) exception;
|
throw (RuntimeException) exception;
|
||||||
}
|
|
||||||
|
|
||||||
throw new RuntimeException(exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
long remaining = retryTimeoutMilliseconds - elapsed;
|
|
||||||
Thread.sleep(Math.min(remaining, RETRY_WAIT_MILLISECONDS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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>
|
<modules>
|
||||||
<module>sdk-tests</module>
|
<module>sdk-tests</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -315,18 +315,6 @@
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>3.2.2</version>
|
<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>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue