use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SwitchTest method switchThird.
@Test
void switchThird() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "switch", null, (f, e) -> ImmutableMap.of("string", "THIRD"));
assertThat(execution.getTaskRunList().get(1).getTaskId(), is("t3"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("value"), is("THIRD"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("defaults"), is(false));
assertThat(execution.getTaskRunList().get(2).getTaskId(), is("failed"));
assertThat(execution.getTaskRunList().get(3).getTaskId(), is("error-t1"));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SwitchTest method switchSecond.
@Test
void switchSecond() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "switch", null, (f, e) -> ImmutableMap.of("string", "SECOND"));
assertThat(execution.getTaskRunList().get(1).getTaskId(), is("t2"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("value"), is("SECOND"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("defaults"), is(false));
assertThat(execution.getTaskRunList().get(2).getTaskId(), is("t2_sub"));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SwitchTest method switchDefault.
@Test
void switchDefault() throws TimeoutException {
Execution execution = runnerUtils.runOne("io.kestra.tests", "switch", null, (f, e) -> ImmutableMap.of("string", "DEFAULT"));
assertThat(execution.getTaskRunList().get(1).getTaskId(), is("default"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("value"), is("DEFAULT"));
assertThat(execution.findTaskRunsByTaskId("parent-seq").get(0).getOutputs().get("defaults"), is(true));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class VariablesTest method invalidVars.
@Test
void invalidVars() throws TimeoutException {
List<LogEntry> logs = new ArrayList<>();
workerTaskLogQueue.receive(logs::add);
Execution execution = runnerUtils.runOne("io.kestra.tests", "variables-invalid");
List<LogEntry> filters = TestsUtils.filterLogs(logs, execution.getTaskRunList().get(1));
assertThat(execution.getTaskRunList(), hasSize(2));
assertThat(execution.getTaskRunList().get(1).getState().getCurrent(), is(State.Type.FAILED));
assertThat(filters.stream().filter(logEntry -> logEntry.getMessage().contains("Missing variable: 'inputs' on '{{inputs.invalid}}'")).count(), greaterThan(0L));
assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
}
use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.
the class SchedulerThreadTest method thread.
@Test
void thread() throws Exception {
// mock flow listeners
MemoryFlowListeners flowListenersServiceSpy = spy(this.flowListenersService);
SchedulerExecutionStateInterface schedulerExecutionStateSpy = spy(this.executionState);
CountDownLatch queueCount = new CountDownLatch(2);
Flow flow = createThreadFlow();
doReturn(Collections.singletonList(flow)).when(flowListenersServiceSpy).flows();
// mock the backfill execution is ended
doAnswer(invocation -> Optional.of(Execution.builder().state(new State().withState(State.Type.SUCCESS)).build())).when(schedulerExecutionStateSpy).findById(any());
// scheduler
try (AbstractScheduler scheduler = new DefaultScheduler(applicationContext, flowListenersServiceSpy, schedulerExecutionStateSpy, triggerState)) {
AtomicReference<Execution> last = new AtomicReference<>();
// wait for execution
executionQueue.receive(SchedulerThreadTest.class, execution -> {
last.set(execution);
assertThat(execution.getFlowId(), is(flow.getId()));
if (execution.getState().getCurrent() != State.Type.SUCCESS) {
executionQueue.emit(execution.withState(State.Type.SUCCESS));
queueCount.countDown();
}
});
scheduler.run();
queueCount.await(1, TimeUnit.MINUTES);
assertThat(last.get().getVariables().get("defaultInjected"), is("done"));
assertThat(last.get().getVariables().get("counter"), is(3));
AbstractSchedulerTest.COUNTER = 0;
}
}
Aggregations