Search in sources :

Example 1 with Schedule

use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.

the class YamlFlowParserTest method triggerEmpty.

@Test
void triggerEmpty() {
    Flow parse = this.parse("flows/tests/trigger-empty.yaml");
    assertThat(((Schedule) parse.getTriggers().get(0)).getBackfill().getStart(), nullValue());
}
Also used : Schedule(io.kestra.core.models.triggers.types.Schedule) Flow(io.kestra.core.models.flows.Flow) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 2 with Schedule

use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.

the class YamlFlowParserTest method trigger.

@Test
void trigger() {
    Flow parse = this.parse("flows/tests/trigger.yaml");
    assertThat(((Schedule) parse.getTriggers().get(0)).getBackfill().getStart(), is(ZonedDateTime.parse("2020-01-01T00:00:00+02:00")));
}
Also used : Schedule(io.kestra.core.models.triggers.types.Schedule) Flow(io.kestra.core.models.flows.Flow) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 3 with Schedule

use of io.kestra.core.models.triggers.types.Schedule 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 4 with Schedule

use of io.kestra.core.models.triggers.types.Schedule in project kestra by kestra-io.

the class CronExpressionTest method cronValidation.

@Test
void cronValidation() throws Exception {
    Schedule build = Schedule.builder().id(IdUtils.create()).type(Schedule.class.getName()).cron("* * * * *").build();
    assertThat(modelValidator.isValid(build).isEmpty(), is(true));
    build = Schedule.builder().type(Schedule.class.getName()).cron("$ome Inv@lid Cr0n").build();
    assertThat(modelValidator.isValid(build).isPresent(), is(true));
    assertThat(modelValidator.isValid(build).get().getMessage(), containsString("invalid cron expression"));
}
Also used : Schedule(io.kestra.core.models.triggers.types.Schedule) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Aggregations

Schedule (io.kestra.core.models.triggers.types.Schedule)4 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)4 Test (org.junit.jupiter.api.Test)4 Flow (io.kestra.core.models.flows.Flow)3 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 LogEntry (io.kestra.core.models.executions.LogEntry)1 RunContext (io.kestra.core.runners.RunContext)1 ArrayList (java.util.ArrayList)1