Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ public <T, E extends Exception> T runStepInternal(
opts.name(),
opts.retriesAllowed(),
opts.maxAttempts(),
opts.backOffRate(),
opts.intervalSeconds(),
opts.backOffRate(),
childWfId,
() -> {
var res = stepfunc.execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ public interface ServiceWFAndStep {
String stepWithLongRetry(String input) throws Exception;

String stepRetryWorkflow(String input);

String inlineStepRetryWorkflow(String input);
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,38 @@ public String stepRetryWorkflow(String input) {

return result;
}

@Workflow(name = "inlineStepRetryTestWorkflow")
public String inlineStepRetryWorkflow(String input) {
long ctime = System.currentTimeMillis();
boolean caught = false;
String result = "2 Retries: ";
try {
result =
result
+ DBOS.runStep(
() -> {
++this.stepWithRetryRuns;
throw new Exception("Will not ever run");
},
new StepOptions("inlineStepWithRetries")
.withRetriesAllowed(true)
.withMaxAttempts(2)
.withIntervalSeconds(0.01)
.withBackoffRate(2.0));
;
} catch (Exception e) {
caught = true;
}
if (!caught) {
result += "<Step with retries should have thrown>";
}
if (System.currentTimeMillis() - ctime > 1000) {
result += "<Retry took too long>";
}
result += this.stepWithRetryRuns;
result += ".";

return result;
}
}
17 changes: 17 additions & 0 deletions transact/src/test/java/dev/dbos/transact/step/StepsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,21 @@ public void stepRetryLogic() throws Exception {
assertEquals(2, stepInfos.get(2).functionId());
assertNull(stepInfos.get(2).error());
}

@Test
public void inlineStepRetryLogic() throws Exception {
ServiceWFAndStep service =
DBOS.registerWorkflows(ServiceWFAndStep.class, new ServiceWFAndStepImpl());

DBOS.launch();

String workflowId = "wf-inlinestepretrytest-1234";
try (var id = new WorkflowOptions(workflowId).setContext()) {
service.inlineStepRetryWorkflow("input");
}

var handle = DBOS.retrieveWorkflow(workflowId);
String expectedRes = "2 Retries: 2.";
assertEquals(expectedRes, (String) handle.getResult());
}
}