use of io.kestra.core.tasks.flows.Parallel in project kestra by kestra-io.
the class KafkaExecutorTest method killedParallel.
@ParameterizedTest
@ValueSource(booleans = { true, false })
void killedParallel(boolean killed) {
startStream(this.executorStore);
Flow flow = flowRepository.findById("io.kestra.tests", "parallel").orElseThrow();
this.flowInput().pipeInput(flow.uid(), flow);
startStream(this.executorMain);
createExecution(flow);
Parallel parent = (Parallel) flow.getTasks().get(0);
Task firstChild = parent.getTasks().get(0);
Task secondChild = parent.getTasks().get(1);
// parent > worker > RUNNING
Execution executionRecord = executionOutput().readRecord().value();
assertThat(executionRecord.getTaskRunList(), hasSize(1));
this.changeStatus(parent, executionRecord.getTaskRunList().get(0), State.Type.RUNNING);
// parent > execution RUNNING
executionRecord = executionOutput().readRecord().value();
assertThat(executionRecord.getTaskRunList(), hasSize(7));
assertThat(executionRecord.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.RUNNING));
assertThat(executionRecord.getTaskRunList().get(1).getState().getCurrent(), is(State.Type.CREATED));
// first child > RUNNING
this.changeStatus(firstChild, executionRecord.getTaskRunList().get(1), State.Type.RUNNING);
executionRecord = executionOutput().readRecord().value();
assertThat(executionRecord.getTaskRunList().get(1).getState().getCurrent(), is(State.Type.RUNNING));
assertThat(executionRecord.getTaskRunList().get(2).getState().getCurrent(), is(State.Type.CREATED));
// killed execution
createKilled(executionRecord);
executionRecord = executionOutput().readRecord().value();
executionRecord = executionOutput().readRecord().value();
assertThat(executionRecord.getState().getCurrent(), is(State.Type.KILLING));
// killed all the creation and killing the parent
for (int i = 0; i < 5; i++) {
executionRecord = executionOutput().readRecord().value();
}
assertThat(executionRecord.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.KILLING));
for (int i = 2; i < 5; i++) {
assertThat(executionRecord.getTaskRunList().get(i).getState().getCurrent(), is(State.Type.KILLED));
}
// kill the first child
if (killed) {
this.changeStatus(firstChild, executionRecord.getTaskRunList().get(1), State.Type.KILLED);
} else {
this.changeStatus(firstChild, executionRecord.getTaskRunList().get(1), State.Type.SUCCESS);
}
// killing state
for (int i = 0; i < 2; i++) {
executionRecord = executionOutput().readRecord().value();
}
// control
assertThat(executionRecord.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.KILLED));
assertThat(executionRecord.getTaskRunList().get(1).getState().getCurrent(), is(killed ? State.Type.KILLED : State.Type.SUCCESS));
assertThat(executionRecord.getState().getCurrent(), is(State.Type.KILLED));
assertThat(executionOutput().isEmpty(), is(true));
}
use of io.kestra.core.tasks.flows.Parallel in project kestra by kestra-io.
the class KafkaExecutorTest method parallel.
@Test
void parallel() {
startStream(this.executorStore);
Flow flow = flowRepository.findById("io.kestra.tests", "parallel").orElseThrow();
this.flowInput().pipeInput(flow.uid(), flow);
startStream(this.executorMain);
createExecution(flow);
Parallel parent = (Parallel) flow.getTasks().get(0);
Task last = flow.getTasks().get(1);
// parent > worker > RUNNING
TestRecord<String, Execution> executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList(), hasSize(1));
this.changeStatus(parent, executionRecord.value().getTaskRunList().get(0), State.Type.RUNNING);
// parent > execution RUNNING and all created
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList(), hasSize(7));
assertThat(executionRecord.value().getTaskRunList().stream().filter(r -> r.getState().getCurrent() == State.Type.CREATED).count(), is(6L));
// Task > all RUNNING
for (ListIterator<Task> it = parent.getTasks().listIterator(); it.hasNext(); ) {
int index = it.nextIndex();
Task next = it.next();
// Task > CREATED
assertThat(executionRecord.value().getTaskRunList().get(index + 1).getState().getCurrent(), is(State.Type.CREATED));
// Task > RUNNING
this.changeStatus(next, executionRecord.value().getTaskRunList().get(index + 1), State.Type.RUNNING);
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList().get(index + 1).getState().getCurrent(), is(State.Type.RUNNING));
}
// Task > all SUCCESS
for (ListIterator<Task> it = parent.getTasks().listIterator(); it.hasNext(); ) {
int index = it.nextIndex();
Task next = it.next();
this.changeStatus(next, executionRecord.value().getTaskRunList().get(index + 1), State.Type.SUCCESS);
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList().get(index + 1).getState().getCurrent(), is(State.Type.SUCCESS));
}
// parent terminated
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList().get(0).getState().getCurrent(), is(State.Type.SUCCESS));
// last
this.changeStatus(last, executionRecord.value().getTaskRunList().get(7), State.Type.RUNNING);
this.changeStatus(last, executionRecord.value().getTaskRunList().get(7), State.Type.RUNNING);
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList().get(7).getState().getCurrent(), is(State.Type.RUNNING));
this.changeStatus(last, executionRecord.value().getTaskRunList().get(7), State.Type.SUCCESS);
executionRecord = executionOutput().readRecord();
assertThat(executionRecord.value().getTaskRunList().get(7).getState().getCurrent(), is(State.Type.SUCCESS));
// ok
assertThat(executionRecord.value().getState().getCurrent(), is(State.Type.SUCCESS));
}
Aggregations