use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class FlowCaseTest method run.
@SuppressWarnings({ "ResultOfMethodCallIgnored", "unchecked" })
void run(String input, State.Type fromState, State.Type triggerState, int count, String outputs) throws Exception {
CountDownLatch countDownLatch = new CountDownLatch(1);
AtomicReference<Execution> triggered = new AtomicReference<>();
executionQueue.receive(execution -> {
if (execution.getFlowId().equals("switch") && execution.getState().getCurrent().isTerninated()) {
countDownLatch.countDown();
triggered.set(execution);
}
});
Execution execution = runnerUtils.runOne("io.kestra.tests", "task-flow", null, (f, e) -> ImmutableMap.of("string", input), Duration.ofMinutes(1));
countDownLatch.await(1, TimeUnit.MINUTES);
assertThat(execution.getTaskRunList(), hasSize(1));
assertThat(execution.getState().getCurrent(), is(fromState));
if (outputs != null) {
assertThat(((Map<String, String>) execution.getTaskRunList().get(0).getOutputs().get("outputs")).get("extracted"), containsString(outputs));
}
assertThat(execution.getTaskRunList().get(0).getOutputs().get("executionId"), is(triggered.get().getId()));
if (outputs != null) {
assertThat(execution.getTaskRunList().get(0).getOutputs().get("state"), is(triggered.get().getState().getCurrent().name()));
}
assertThat(triggered.get().getTrigger().getType(), is(Flow.class.getName()));
assertThat(triggered.get().getTrigger().getVariables().get("executionId"), is(execution.getId()));
assertThat(triggered.get().getTrigger().getVariables().get("flowId"), is(execution.getFlowId()));
assertThat(triggered.get().getTrigger().getVariables().get("namespace"), is(execution.getNamespace()));
assertThat(triggered.get().getTaskRunList(), hasSize(count));
assertThat(triggered.get().getState().getCurrent(), is(triggerState));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class ParallelTest method parallelNested.
@Test
void parallelNested() throws TimeoutException, QueueException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "parallel-nested");
assertThat(execution.getTaskRunList(), hasSize(11));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class PauseTest method run.
@Test
void run() throws Exception {
Flow flow = flowRepository.findById("io.kestra.tests", "pause").orElseThrow();
Execution execution = runnerUtils.runOne("io.kestra.tests", "pause", Duration.ofSeconds(120));
assertThat(execution.getState().getCurrent(), is(State.Type.PAUSED));
assertThat(execution.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.PAUSED));
assertThat(execution.getTaskRunList(), hasSize(1));
Execution restarted = executionService.markAs(execution, execution.findTaskRunByTaskIdAndValue("pause", List.of()).getId(), State.Type.RUNNING);
execution = runnerUtils.awaitExecution(e -> e.getState().getCurrent() == State.Type.SUCCESS, () -> executionQueue.emit(restarted), Duration.ofSeconds(120));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SequentialTest method sequentialWithLocalErrors.
@Test
void sequentialWithLocalErrors() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "sequential-with-local-errors");
assertThat(execution.getTaskRunList(), hasSize(6));
assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SequentialTest method sequential.
@Test
void sequential() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "sequential");
assertThat(execution.getTaskRunList(), hasSize(11));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
}
Aggregations