Search in sources :

Example 1 with Execution

use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.

the class KafkaElasticIndexerTest method buildExecutionRecord.

private ConsumerRecord<String, String> buildExecutionRecord(String topic, int offset) throws JsonProcessingException {
    Flow flow = TestsUtils.mockFlow();
    Execution execution = TestsUtils.mockExecution(flow, ImmutableMap.of());
    return buildRecord(topic, execution.getId(), JacksonMapper.ofJson().writeValueAsString(execution), offset);
}
Also used : Execution(io.kestra.core.models.executions.Execution) Flow(io.kestra.core.models.flows.Flow)

Example 2 with Execution

use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.

the class ConditionServiceTest method valid.

@Test
void valid() {
    Flow flow = TestsUtils.mockFlow();
    Execution execution = TestsUtils.mockExecution(flow, ImmutableMap.of());
    RunContext runContext = runContextFactory.of(flow, execution);
    ConditionContext conditionContext = conditionService.conditionContext(runContext, flow, execution);
    List<Condition> conditions = Arrays.asList(ExecutionFlowCondition.builder().namespace(flow.getNamespace()).flowId(flow.getId()).build(), ExecutionNamespaceCondition.builder().namespace(flow.getNamespace()).build());
    boolean valid = conditionService.valid(flow, conditions, conditionContext);
    assertThat(valid, is(true));
}
Also used : ExecutionFlowCondition(io.kestra.core.models.conditions.types.ExecutionFlowCondition) ExecutionNamespaceCondition(io.kestra.core.models.conditions.types.ExecutionNamespaceCondition) Condition(io.kestra.core.models.conditions.Condition) ConditionContext(io.kestra.core.models.conditions.ConditionContext) Execution(io.kestra.core.models.executions.Execution) RunContext(io.kestra.core.runners.RunContext) Flow(io.kestra.core.models.flows.Flow) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Example 3 with Execution

use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.

the class BashTest method error.

@Test
void error() throws TimeoutException {
    Execution execution = runnerUtils.runOne("io.kestra.tests", "bash-warning");
    assertThat(execution.getState().getCurrent(), is(State.Type.WARNING));
    assertThat(execution.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.WARNING));
    assertThat(execution.getTaskRunList().get(0).getOutputs().get("stdErrLineCount"), is(1));
    assertThat(execution.getTaskRunList(), hasSize(1));
}
Also used : Execution(io.kestra.core.models.executions.Execution) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Example 4 with Execution

use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.

the class AllowFailureTest method success.

@Test
void success() throws TimeoutException {
    Execution execution = runnerUtils.runOne("io.kestra.tests", "allow-failure", Duration.ofSeconds(120));
    assertThat(execution.getTaskRunList(), hasSize(9));
    control(execution);
    assertThat(execution.findTaskRunsByTaskId("global-error").size(), is(0));
    assertThat(execution.findTaskRunsByTaskId("last").get(0).getState().getCurrent(), is(State.Type.SUCCESS));
    assertThat(execution.getState().getCurrent(), is(State.Type.WARNING));
}
Also used : Execution(io.kestra.core.models.executions.Execution) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Example 5 with Execution

use of io.kestra.core.models.executions.Execution in project kestra by kestra-io.

the class AllowFailureTest method failed.

@Test
void failed() throws TimeoutException {
    Execution execution = runnerUtils.runOne("io.kestra.tests", "allow-failure", null, (f, e) -> runnerUtils.typedInputs(f, e, ImmutableMap.of("crash", "1")));
    assertThat(execution.getTaskRunList(), hasSize(10));
    control(execution);
    assertThat(execution.findTaskRunsByTaskId("global-error").get(0).getState().getCurrent(), is(State.Type.SUCCESS));
    assertThat(execution.findTaskRunsByTaskId("switch").get(0).getState().getCurrent(), is(State.Type.FAILED));
    assertThat(execution.findTaskRunsByTaskId("crash").get(0).getState().getCurrent(), is(State.Type.FAILED));
    assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
}
Also used : Execution(io.kestra.core.models.executions.Execution) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Aggregations

Execution (io.kestra.core.models.executions.Execution)159 Test (org.junit.jupiter.api.Test)114 Flow (io.kestra.core.models.flows.Flow)59 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)39 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 State (io.kestra.core.models.flows.State)14 TaskRun (io.kestra.core.models.executions.TaskRun)13 EachSequentialTest (io.kestra.core.tasks.flows.EachSequentialTest)13 FlowCaseTest (io.kestra.core.tasks.flows.FlowCaseTest)13 TemplateTest (io.kestra.core.tasks.flows.TemplateTest)13 LogEntry (io.kestra.core.models.executions.LogEntry)11 Map (java.util.Map)11 InputsTest (io.kestra.core.runners.InputsTest)10 Inject (jakarta.inject.Inject)7 FlowRepositoryInterface (io.kestra.core.repositories.FlowRepositoryInterface)6 ZonedDateTime (java.time.ZonedDateTime)6 InternalException (io.kestra.core.exceptions.InternalException)5 QueueFactoryInterface (io.kestra.core.queues.QueueFactoryInterface)5 QueueInterface (io.kestra.core.queues.QueueInterface)5