Skip to content

Commit

Permalink
fix(jdbc): purge executor state at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Mar 7, 2023
1 parent 6e6c333 commit a9dc5b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
27 changes: 27 additions & 0 deletions core/src/test/java/io/kestra/core/runners/RestartCaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,31 @@ public void replay() throws Exception {
assertThat(finishedRestartedExecution.getParentId(), is(firstExecution.getId()));
assertThat(finishedRestartedExecution.getState().getCurrent(), is(State.Type.SUCCESS));
}

public void restartMultiple() throws Exception {
Execution execution = runnerUtils.runOne("io.kestra.tests", "failed-first");
assertThat(execution.getTaskRunList(), hasSize(1));
assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));

Execution restart = executionService.restart(execution, null);
assertThat(restart.getState().getCurrent(), is(State.Type.RESTARTED));

Execution restartEnded = runnerUtils.awaitExecution(
e -> e.getState().getCurrent() == State.Type.FAILED,
() -> executionQueue.emit(restart),
Duration.ofSeconds(120)
);

assertThat(restartEnded.getState().getCurrent(), is(State.Type.FAILED));

Execution newRestart = executionService.restart(restartEnded, null);

restartEnded = runnerUtils.awaitExecution(
e -> e.getState().getCurrent() == State.Type.FAILED,
() -> executionQueue.emit(newRestart),
Duration.ofSeconds(120)
);

assertThat(restartEnded.getState().getCurrent(), is(State.Type.FAILED));
}
}
3 changes: 1 addition & 2 deletions jdbc/src/main/java/io/kestra/jdbc/runner/JdbcExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,7 @@ private void toExecution(Executor executor) {

// delete if ended
if (executorService.canBePurged(executor)) {
// TODO
// executorStateStorage.delete(executor.getExecution());
executorStateStorage.delete(executor.getExecution());
}
}

Expand Down
5 changes: 5 additions & 0 deletions jdbc/src/test/java/io/kestra/jdbc/runner/JdbcRunnerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ void replay() throws Exception {
restartCaseTest.replay();
}

@Test
void restartMultiple() throws Exception {
restartCaseTest.restartMultiple();
}

@Test
void flowTrigger() throws Exception {
flowTriggerCaseTest.trigger();
Expand Down

0 comments on commit a9dc5b6

Please sign in to comment.