Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/worktrees/state-examples-docs
Submodule state-examples-docs added at 3ff4eb
34 changes: 19 additions & 15 deletions sdk-tests/src/test/java/io/dapr/it/DaprRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,13 @@ public void stop() throws InterruptedException, IOException {
System.out.println("Stopping dapr application ...");
try {
this.stopCommand.run();

System.out.println("Dapr application stopped.");
} catch (RuntimeException e) {
System.out.println("Could not stop app " + this.appName + ": " + e.getMessage());
if (e.getMessage() != null && e.getMessage().contains("Could not find success criteria")) {
System.out.println("App " + this.appName + " already stopped or not found (ignored).");
} else {
System.out.println("Could not stop app " + this.appName + ": " + e.getMessage());
}
}
}

Expand Down Expand Up @@ -219,8 +222,7 @@ public void waitForAppHealth(int maxWaitMilliseconds) throws InterruptedExceptio
while (System.currentTimeMillis() <= maxWait) {
try {
stub.healthCheck(Empty.getDefaultInstance());
// artursouza: workaround due to race condition with runtime's probe on app's health.
Thread.sleep(5000);
Thread.sleep(2000);
return;
} catch (Exception e) {
Thread.sleep(1000);
Expand All @@ -232,29 +234,31 @@ public void waitForAppHealth(int maxWaitMilliseconds) throws InterruptedExceptio
channel.shutdown();
}
} else {
Duration waitDuration = Duration.ofMillis(maxWaitMilliseconds);
long maxWait = System.currentTimeMillis() + maxWaitMilliseconds;
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.connectTimeout(waitDuration)
.connectTimeout(Duration.ofSeconds(5))
.build();
String url = "http://127.0.0.1:" + this.getAppPort() + "/health";
HttpRequest request = HttpRequest.newBuilder()
.GET()
.uri(URI.create(url))
.build();

try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());

if (response.statusCode() != 200) {
throw new RuntimeException("error: HTTP service is not healthy.");
while (System.currentTimeMillis() <= maxWait) {
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) {
Thread.sleep(2000);
return;
}
} catch (IOException e) {
// not ready yet
}
} catch (IOException e) {
throw new RuntimeException("exception: HTTP service is not healthy.");
Thread.sleep(1000);
}

// artursouza: workaround due to race condition with runtime's probe on app's health.
Thread.sleep(5000);
throw new RuntimeException("timeout: HTTP service is not healthy.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,24 +129,19 @@ public void reminderRecoveryTest(
) throws Exception {
setup(actorType);

logger.debug("Pausing 3 seconds to let gRPC connection get ready");
Thread.sleep(3000);

logger.debug("Invoking actor method 'startReminder' which will register a reminder");
proxy.invokeMethod("setReminderData", reminderDataParam).block();

proxy.invokeMethod("startReminder", reminderName).block();

logger.debug("Pausing 7 seconds to allow reminder to fire");
Thread.sleep(7000);

logger.debug("Waiting for reminder to fire at least 3 times");
final List<MethodEntryTracker> logs = new ArrayList<>();
callWithRetry(() -> {
logs.clear();
logs.addAll(fetchMethodCallLogs(proxy));
validateMethodCalls(logs, METHOD_NAME, 3);
validateMessageContent(logs, METHOD_NAME, expectedReminderStateText);
}, 5000);
}, 30000);

// Restarts runtime only.
logger.info("Stopping Dapr sidecar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public void timerRecoveryTest() throws Exception {
true,
60000);

Thread.sleep(3000);
String actorType="MyActorTest";
logger.debug("Creating proxy builder");

Expand All @@ -68,16 +67,14 @@ public void timerRecoveryTest() throws Exception {
logger.debug("Invoking actor method 'startTimer' which will register a timer");
proxy.invokeMethod("startTimer", "myTimer").block();

logger.debug("Pausing 7 seconds to allow timer to fire");
Thread.sleep(7000);

logger.debug("Waiting for timer to fire at least 3 times");
final List<MethodEntryTracker> logs = new ArrayList<>();
callWithRetry(() -> {
logs.clear();
logs.addAll(fetchMethodCallLogs(proxy));
validateMethodCalls(logs, METHOD_NAME, 3);
validateMessageContent(logs, METHOD_NAME, "ping!");
}, 5000);
}, 30000);

// Restarts app only.
runs.left.stop();
Expand All @@ -91,7 +88,7 @@ public void timerRecoveryTest() throws Exception {
newLogs.clear();
newLogs.addAll(fetchMethodCallLogs(proxy));
validateMethodCalls(newLogs, METHOD_NAME, 3);
}, 10000);
}, 30000);

// Check that the restart actually happened by confirming the old logs are not in the new logs.
for (MethodEntryTracker oldLog: logs) {
Expand Down
Loading
Loading