Search in sources :

Example 1 with LogEntry

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

the class ConditionServiceTest method exception.

@Test
void exception() throws InterruptedException {
    List<LogEntry> logs = new ArrayList<>();
    logQueue.receive(logs::add);
    Flow flow = TestsUtils.mockFlow();
    Schedule schedule = Schedule.builder().id("unit").type(Schedule.class.getName()).cron("0 0 1 * *").build();
    RunContext runContext = runContextFactory.of(flow, schedule);
    ConditionContext conditionContext = conditionService.conditionContext(runContext, flow, null);
    List<Condition> conditions = Collections.singletonList(ExecutionFlowCondition.builder().namespace(flow.getNamespace()).flowId(flow.getId()).build());
    conditionService.valid(flow, conditions, conditionContext);
    Thread.sleep(250);
    assertThat(logs.stream().filter(logEntry -> logEntry.getNamespace().equals("io.kestra.core.services.ConditionServiceTest")).count(), greaterThan(0L));
    assertThat(logs.stream().filter(logEntry -> logEntry.getFlowId().equals("exception")).count(), greaterThan(0L));
}
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) Schedule(io.kestra.core.models.triggers.types.Schedule) ArrayList(java.util.ArrayList) RunContext(io.kestra.core.runners.RunContext) LogEntry(io.kestra.core.models.executions.LogEntry) Flow(io.kestra.core.models.flows.Flow) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Example 2 with LogEntry

use of io.kestra.core.models.executions.LogEntry 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));
}
Also used : Execution(io.kestra.core.models.executions.Execution) ArrayList(java.util.ArrayList) LogEntry(io.kestra.core.models.executions.LogEntry) Test(org.junit.jupiter.api.Test) AbstractMemoryRunnerTest(io.kestra.core.runners.AbstractMemoryRunnerTest)

Example 3 with LogEntry

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

the class RunContextTest method inputsLarge.

@Test
void inputsLarge() throws TimeoutException, InterruptedException {
    List<LogEntry> logs = new ArrayList<>();
    workerTaskLogQueue.receive(logs::add);
    char[] chars = new char[1024 * 11];
    Arrays.fill(chars, 'a');
    Map<String, String> inputs = new HashMap<>(InputsTest.inputs);
    inputs.put("string", new String(chars));
    Execution execution = runnerUtils.runOne("io.kestra.tests", "inputs-large", null, (flow, execution1) -> runnerUtils.typedInputs(flow, execution1, inputs));
    assertThat(execution.getTaskRunList(), hasSize(10));
    assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
    assertThat(execution.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.SUCCESS));
    List<LogEntry> logEntries = logs.stream().filter(logEntry -> logEntry.getTaskRunId() != null && logEntry.getTaskRunId().equals(execution.getTaskRunList().get(1).getId())).sorted(Comparator.comparingLong(value -> value.getTimestamp().toEpochMilli())).collect(Collectors.toList());
    Thread.sleep(100);
    assertThat(logEntries.get(0).getTimestamp().toEpochMilli() + 1, is(logEntries.get(1).getTimestamp().toEpochMilli()));
}
Also used : Execution(io.kestra.core.models.executions.Execution) LogEntry(io.kestra.core.models.executions.LogEntry) Test(org.junit.jupiter.api.Test)

Example 4 with LogEntry

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

the class KafkaRunnerTest method invalidVars.

@Test
void invalidVars() throws TimeoutException {
    List<LogEntry> logs = new ArrayList<>();
    logsQueue.receive(logs::add);
    Execution execution = runnerUtils.runOne("io.kestra.tests", "variables-invalid", null, null, Duration.ofSeconds(60));
    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));
}
Also used : Execution(io.kestra.core.models.executions.Execution) LogEntry(io.kestra.core.models.executions.LogEntry) TemplateTest(io.kestra.core.tasks.flows.TemplateTest) FlowCaseTest(io.kestra.core.tasks.flows.FlowCaseTest) EachSequentialTest(io.kestra.core.tasks.flows.EachSequentialTest) Test(org.junit.jupiter.api.Test)

Example 5 with LogEntry

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

the class KafkaRunnerTest method streamTooLarge.

@Test
void streamTooLarge() throws TimeoutException {
    List<LogEntry> logs = new ArrayList<>();
    logsQueue.receive(logs::add);
    char[] chars = new char[1100000];
    Arrays.fill(chars, 'a');
    Map<String, String> inputs = new HashMap<>(InputsTest.inputs);
    inputs.put("string", new String(chars));
    Execution execution = runnerUtils.runOne("io.kestra.tests", "inputs-large", null, (flow, execution1) -> runnerUtils.typedInputs(flow, execution1, inputs), Duration.ofSeconds(120));
    assertThat(execution.getTaskRunList(), hasSize(10));
    assertThat(execution.getState().getCurrent(), is(State.Type.FAILED));
    assertThat(execution.getTaskRunList().get(0).getState().getCurrent(), is(State.Type.FAILED));
    assertThat(logs.stream().filter(logEntry -> logEntry.getMessage().contains("max.request.size")).count(), greaterThan(0L));
}
Also used : Execution(io.kestra.core.models.executions.Execution) LogEntry(io.kestra.core.models.executions.LogEntry) TemplateTest(io.kestra.core.tasks.flows.TemplateTest) FlowCaseTest(io.kestra.core.tasks.flows.FlowCaseTest) EachSequentialTest(io.kestra.core.tasks.flows.EachSequentialTest) Test(org.junit.jupiter.api.Test)

Aggregations

LogEntry (io.kestra.core.models.executions.LogEntry)11 Execution (io.kestra.core.models.executions.Execution)10 Test (org.junit.jupiter.api.Test)8 ArrayList (java.util.ArrayList)5 EachSequentialTest (io.kestra.core.tasks.flows.EachSequentialTest)3 FlowCaseTest (io.kestra.core.tasks.flows.FlowCaseTest)3 TemplateTest (io.kestra.core.tasks.flows.TemplateTest)3 Flow (io.kestra.core.models.flows.Flow)2 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)2 Condition (io.kestra.core.models.conditions.Condition)1 ConditionContext (io.kestra.core.models.conditions.ConditionContext)1 ExecutionFlowCondition (io.kestra.core.models.conditions.types.ExecutionFlowCondition)1 ExecutionNamespaceCondition (io.kestra.core.models.conditions.types.ExecutionNamespaceCondition)1 Schedule (io.kestra.core.models.triggers.types.Schedule)1 ListenersTest (io.kestra.core.runners.ListenersTest)1 RunContext (io.kestra.core.runners.RunContext)1 Bash (io.kestra.core.tasks.scripts.Bash)1 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)1