Search in sources :

Example 1 with Flow

use of io.kestra.core.models.flows.Flow 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 Flow

use of io.kestra.core.models.flows.Flow in project kestra by kestra-io.

the class ElasticSearchFlowRepository method delete.

@Override
public Flow delete(Flow flow) {
    Flow deleted = flow.toDeleted();
    flowQueue.emit(deleted);
    this.deleteRequest(INDEX_NAME, flowId(deleted));
    this.putRequest(REVISIONS_NAME, deleted.uid(), deleted);
    ListUtils.emptyOnNull(flow.getTriggers()).forEach(abstractTrigger -> triggerQueue.delete(Trigger.of(flow, abstractTrigger)));
    eventPublisher.publishEvent(new CrudEvent<>(flow, CrudEventType.DELETE));
    return deleted;
}
Also used : Flow(io.kestra.core.models.flows.Flow)

Example 3 with Flow

use of io.kestra.core.models.flows.Flow in project kestra by kestra-io.

the class YamlFlowParserTest method serialization.

@Test
void serialization() throws IOException {
    Flow flow = this.parse("flows/valids/minimal.yaml");
    String s = mapper.writeValueAsString(flow);
    assertThat(s, is("{\"id\":\"minimal\",\"namespace\":\"io.kestra.tests\",\"revision\":2,\"tasks\":[{\"id\":\"date\",\"type\":\"io.kestra.core.tasks.debugs.Return\",\"format\":\"{{taskrun.startDate}}\"}],\"deleted\":false}"));
}
Also used : Flow(io.kestra.core.models.flows.Flow) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 4 with Flow

use of io.kestra.core.models.flows.Flow in project kestra by kestra-io.

the class YamlFlowParserTest method inputs.

@Test
void inputs() {
    Flow flow = this.parse("flows/valids/inputs.yaml");
    assertThat(flow.getInputs().size(), is(8));
    assertThat(flow.getInputs().stream().filter(Input::getRequired).count(), is(6L));
    assertThat(flow.getInputs().stream().filter(r -> !r.getRequired()).count(), is(2L));
    assertThat(flow.getInputs().stream().filter(r -> r.getDefaults() != null).count(), is(1L));
}
Also used : Input(io.kestra.core.models.flows.Input) Flow(io.kestra.core.models.flows.Flow) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 5 with Flow

use of io.kestra.core.models.flows.Flow 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)

Aggregations

Flow (io.kestra.core.models.flows.Flow)127 Test (org.junit.jupiter.api.Test)82 Execution (io.kestra.core.models.executions.Execution)60 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)51 AbstractMemoryRunnerTest (io.kestra.core.runners.AbstractMemoryRunnerTest)24 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)18 Inject (jakarta.inject.Inject)15 Collectors (java.util.stream.Collectors)12 State (io.kestra.core.models.flows.State)11 FlowRepositoryInterface (io.kestra.core.repositories.FlowRepositoryInterface)11 QueueFactoryInterface (io.kestra.core.queues.QueueFactoryInterface)10 QueueInterface (io.kestra.core.queues.QueueInterface)10 AbstractSchedulerTest (io.kestra.core.schedulers.AbstractSchedulerTest)10 HttpClientResponseException (io.micronaut.http.client.exceptions.HttpClientResponseException)10 Singleton (jakarta.inject.Singleton)10 InternalException (io.kestra.core.exceptions.InternalException)9 TaskRun (io.kestra.core.models.executions.TaskRun)9 Duration (java.time.Duration)9 ApplicationContext (io.micronaut.context.ApplicationContext)7 Named (jakarta.inject.Named)7