mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-19 09:50:29 -05:00
chore(system): extract the scheduler to its own module
This commit is contained in:
@@ -2,7 +2,7 @@ package io.kestra.cli.commands.servers;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.kestra.core.models.ServerType;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.scheduler.AbstractScheduler;
|
||||
import io.kestra.core.utils.Await;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@@ -75,6 +75,7 @@ dependencies {
|
||||
testImplementation project(':runner-memory')
|
||||
testImplementation project(':storage-local')
|
||||
testImplementation project(':worker')
|
||||
testImplementation project(':scheduler')
|
||||
testImplementation project(':executor')
|
||||
|
||||
testImplementation "io.micronaut:micronaut-http-client"
|
||||
|
||||
@@ -6,7 +6,6 @@ import io.kestra.core.models.tasks.Task;
|
||||
import io.kestra.core.models.triggers.AbstractTrigger;
|
||||
import io.kestra.core.models.triggers.TriggerContext;
|
||||
import io.kestra.core.runners.*;
|
||||
import io.kestra.core.schedulers.SchedulerExecutionWithTrigger;
|
||||
import io.micrometer.core.instrument.*;
|
||||
import io.micrometer.core.instrument.binder.MeterBinder;
|
||||
import io.micrometer.core.instrument.search.Search;
|
||||
@@ -395,19 +394,6 @@ public class MetricRegistry {
|
||||
return triggerContext.getTenantId() == null ? baseTags : ArrayUtils.addAll(baseTags, TAG_TENANT_ID, triggerContext.getTenantId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return tags for current {@link SchedulerExecutionWithTrigger}.
|
||||
*
|
||||
* @param schedulerExecutionWithTrigger the current SchedulerExecutionWithTrigger
|
||||
* @return tags to apply to metrics
|
||||
*/
|
||||
public String[] tags(SchedulerExecutionWithTrigger schedulerExecutionWithTrigger, String... tags) {
|
||||
return ArrayUtils.addAll(
|
||||
this.tags(schedulerExecutionWithTrigger.getExecution()),
|
||||
tags
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return tags for current {@link ExecutionKilled}
|
||||
*
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.core.runners;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -2,6 +2,5 @@ package io.kestra.core.runners;
|
||||
|
||||
import io.kestra.core.server.Service;
|
||||
|
||||
public interface IndexerInterface extends Service, Runnable {
|
||||
|
||||
public interface Scheduler extends Service, Runnable {
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.core.runners;
|
||||
|
||||
import io.kestra.core.models.conditions.ConditionContext;
|
||||
import io.kestra.core.models.flows.Flow;
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.kestra.core.runners;
|
||||
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.server.Service;
|
||||
import io.kestra.core.utils.Await;
|
||||
import io.kestra.core.utils.ExecutorsUtils;
|
||||
@@ -64,7 +63,7 @@ public class StandAloneRunner implements RunnerInterface, AutoCloseable {
|
||||
}
|
||||
|
||||
if (schedulerEnabled) {
|
||||
AbstractScheduler scheduler = applicationContext.getBean(AbstractScheduler.class);
|
||||
Scheduler scheduler = applicationContext.getBean(Scheduler.class);
|
||||
poolExecutor.execute(scheduler);
|
||||
servers.add(scheduler);
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package io.kestra.core.schedulers;
|
||||
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Singleton
|
||||
public interface Scheduler extends Runnable, AutoCloseable {
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.kestra.core.repositories;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.kestra.core.Helpers;
|
||||
import io.kestra.core.events.CrudEvent;
|
||||
import io.kestra.core.events.CrudEventType;
|
||||
@@ -10,13 +11,17 @@ import io.kestra.core.models.QueryFilter;
|
||||
import io.kestra.core.models.QueryFilter.Field;
|
||||
import io.kestra.core.models.QueryFilter.Op;
|
||||
import io.kestra.core.models.SearchResult;
|
||||
import io.kestra.core.models.conditions.ConditionContext;
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
import io.kestra.core.models.executions.ExecutionTrigger;
|
||||
import io.kestra.core.models.flows.*;
|
||||
import io.kestra.core.models.flows.input.StringInput;
|
||||
import io.kestra.core.models.property.Property;
|
||||
import io.kestra.core.models.triggers.AbstractTrigger;
|
||||
import io.kestra.core.models.triggers.PollingTriggerInterface;
|
||||
import io.kestra.core.models.triggers.TriggerContext;
|
||||
import io.kestra.core.queues.QueueException;
|
||||
import io.kestra.core.repositories.ExecutionRepositoryInterface.ChildFilter;
|
||||
import io.kestra.core.schedulers.AbstractSchedulerTest;
|
||||
import io.kestra.core.services.FlowService;
|
||||
import io.kestra.core.utils.Await;
|
||||
import io.kestra.core.utils.IdUtils;
|
||||
@@ -28,7 +33,8 @@ import io.micronaut.data.model.Sort;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import lombok.Getter;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -552,9 +558,9 @@ public abstract class AbstractFlowRepositoryTest {
|
||||
.id(flowId)
|
||||
.namespace(TEST_NAMESPACE)
|
||||
.tenantId(MAIN_TENANT)
|
||||
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
||||
.triggers(Collections.singletonList(UnitTest.builder()
|
||||
.id("sleep")
|
||||
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
||||
.type(UnitTest.class.getName())
|
||||
.build()))
|
||||
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.ofValue(TEST_FLOW_ID)).build()))
|
||||
.build();
|
||||
@@ -592,9 +598,9 @@ public abstract class AbstractFlowRepositoryTest {
|
||||
.id(flowId)
|
||||
.namespace(TEST_NAMESPACE)
|
||||
.tenantId(MAIN_TENANT)
|
||||
.triggers(Collections.singletonList(AbstractSchedulerTest.UnitTest.builder()
|
||||
.triggers(Collections.singletonList(UnitTest.builder()
|
||||
.id("sleep")
|
||||
.type(AbstractSchedulerTest.UnitTest.class.getName())
|
||||
.type(UnitTest.class.getName())
|
||||
.build()))
|
||||
.tasks(Collections.singletonList(Return.builder().id(TEST_FLOW_ID).type(Return.class.getName()).format(Property.ofValue(TEST_FLOW_ID)).build()))
|
||||
.build();
|
||||
@@ -911,4 +917,47 @@ public abstract class AbstractFlowRepositoryTest {
|
||||
return GenericFlow.fromYaml(TEST_TENANT_ID, source);
|
||||
}
|
||||
|
||||
protected static int COUNTER = 0;
|
||||
|
||||
@SuperBuilder
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public static class UnitTest extends AbstractTrigger implements PollingTriggerInterface {
|
||||
@Builder.Default
|
||||
private final Duration interval = Duration.ofSeconds(2);
|
||||
|
||||
private String defaultInjected;
|
||||
|
||||
public Optional<Execution> evaluate(ConditionContext conditionContext, TriggerContext context) throws InterruptedException {
|
||||
COUNTER++;
|
||||
|
||||
if (COUNTER % 2 == 0) {
|
||||
Thread.sleep(4000);
|
||||
|
||||
return Optional.empty();
|
||||
} else {
|
||||
Execution execution = Execution.builder()
|
||||
.id(IdUtils.create())
|
||||
.tenantId(context.getTenantId())
|
||||
.namespace(context.getNamespace())
|
||||
.flowId(context.getFlowId())
|
||||
.flowRevision(conditionContext.getFlow().getRevision())
|
||||
.state(new State())
|
||||
.trigger(ExecutionTrigger.builder()
|
||||
.id(this.getId())
|
||||
.type(this.getType())
|
||||
.variables(ImmutableMap.of(
|
||||
"counter", COUNTER,
|
||||
"defaultInjected", defaultInjected == null ? "ko" : defaultInjected
|
||||
))
|
||||
.build()
|
||||
)
|
||||
.build();
|
||||
|
||||
return Optional.of(execution);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.kestra.core.queues.QueueFactoryInterface;
|
||||
import io.kestra.core.queues.QueueInterface;
|
||||
import io.kestra.core.repositories.TriggerRepositoryInterface;
|
||||
import io.kestra.core.runners.RunnerUtils;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.scheduler.AbstractScheduler;
|
||||
import io.kestra.core.utils.Await;
|
||||
import io.kestra.core.utils.TestsUtils;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@@ -6,6 +6,7 @@ dependencies {
|
||||
implementation project(":core")
|
||||
implementation project(":jdbc")
|
||||
implementation project(":executor")
|
||||
implementation project(":scheduler")
|
||||
|
||||
implementation("io.micronaut.sql:micronaut-jooq")
|
||||
runtimeOnly("com.h2database:h2")
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package io.kestra.schedulers.h2;
|
||||
|
||||
import io.kestra.core.runners.FlowListeners;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.schedulers.SchedulerExecutionStateInterface;
|
||||
import io.kestra.core.schedulers.SchedulerScheduleTest;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
|
||||
class H2SchedulerScheduleTest extends SchedulerScheduleTest {
|
||||
@Override
|
||||
protected AbstractScheduler scheduler(FlowListeners flowListenersServiceSpy, SchedulerExecutionStateInterface executionStateSpy) {
|
||||
return new JdbcScheduler(
|
||||
applicationContext,
|
||||
flowListenersServiceSpy
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ dependencies {
|
||||
implementation project(":core")
|
||||
implementation project(":jdbc")
|
||||
implementation project(":executor")
|
||||
implementation project(":scheduler")
|
||||
|
||||
implementation("io.micronaut.sql:micronaut-jooq")
|
||||
runtimeOnly("com.mysql:mysql-connector-j")
|
||||
@@ -13,6 +14,7 @@ dependencies {
|
||||
|
||||
testImplementation project(':core').sourceSets.test.output
|
||||
testImplementation project(':jdbc').sourceSets.test.output
|
||||
testImplementation project(':scheduler').sourceSets.test.output
|
||||
testImplementation project(':storage-local')
|
||||
testImplementation project(':tests')
|
||||
testImplementation("io.micronaut.validation:micronaut-validation") // MysqlServiceLivenessCoordinatorTest fail to init without that
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.kestra.schedulers.mysql;
|
||||
|
||||
import io.kestra.core.runners.FlowListeners;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.schedulers.SchedulerExecutionStateInterface;
|
||||
import io.kestra.core.schedulers.SchedulerScheduleTest;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
import io.kestra.scheduler.AbstractScheduler;
|
||||
import io.kestra.scheduler.SchedulerExecutionStateInterface;
|
||||
import io.kestra.scheduler.SchedulerScheduleTest;
|
||||
|
||||
class MysqlSchedulerScheduleTest extends SchedulerScheduleTest {
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,7 @@ dependencies {
|
||||
implementation project(":core")
|
||||
implementation project(":jdbc")
|
||||
implementation project(":executor")
|
||||
implementation project(":scheduler")
|
||||
|
||||
implementation("io.micronaut.sql:micronaut-jooq")
|
||||
runtimeOnly("org.postgresql:postgresql")
|
||||
@@ -13,6 +14,7 @@ dependencies {
|
||||
|
||||
testImplementation project(':core').sourceSets.test.output
|
||||
testImplementation project(':jdbc').sourceSets.test.output
|
||||
testImplementation project(':scheduler').sourceSets.test.output
|
||||
testImplementation project(':storage-local')
|
||||
testImplementation project(':tests')
|
||||
testImplementation("io.micronaut.validation:micronaut-validation") // PostgresServiceLivenessCoordinatorTest fail to init without that
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package io.kestra.schedulers.postgres;
|
||||
|
||||
import io.kestra.core.runners.FlowListeners;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.core.schedulers.SchedulerExecutionStateInterface;
|
||||
import io.kestra.core.schedulers.SchedulerScheduleTest;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
import io.kestra.scheduler.AbstractScheduler;
|
||||
import io.kestra.scheduler.SchedulerExecutionStateInterface;
|
||||
import io.kestra.scheduler.SchedulerScheduleTest;
|
||||
|
||||
class PostgresSchedulerScheduleTest extends SchedulerScheduleTest {
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.models.triggers.TriggerContext;
|
||||
import io.kestra.core.repositories.ArrayListTotal;
|
||||
import io.kestra.core.repositories.TriggerRepositoryInterface;
|
||||
import io.kestra.core.schedulers.ScheduleContextInterface;
|
||||
import io.kestra.core.runners.ScheduleContextInterface;
|
||||
import io.kestra.core.utils.DateUtils;
|
||||
import io.kestra.core.utils.ListUtils;
|
||||
import io.kestra.jdbc.runner.JdbcQueueIndexerInterface;
|
||||
|
||||
@@ -3,13 +3,15 @@ package io.kestra.jdbc.runner;
|
||||
import io.kestra.core.models.flows.FlowWithSource;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.repositories.TriggerRepositoryInterface;
|
||||
import io.kestra.core.schedulers.*;
|
||||
import io.kestra.core.runners.ScheduleContextInterface;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.services.FlowListenersInterface;
|
||||
import io.kestra.core.services.FlowService;
|
||||
import io.kestra.core.services.PluginDefaultService;
|
||||
import io.kestra.core.utils.ListUtils;
|
||||
import io.kestra.jdbc.JooqDSLContextWrapper;
|
||||
import io.kestra.jdbc.repository.AbstractJdbcTriggerRepository;
|
||||
import io.kestra.scheduler.AbstractScheduler;
|
||||
import io.kestra.scheduler.SchedulerExecutionState;
|
||||
import io.micronaut.context.ApplicationContext;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.kestra.jdbc.runner;
|
||||
|
||||
import io.kestra.core.schedulers.ScheduleContextInterface;
|
||||
import io.kestra.core.runners.ScheduleContextInterface;
|
||||
import io.kestra.jdbc.JooqDSLContextWrapper;
|
||||
import lombok.Getter;
|
||||
import org.jooq.DSLContext;
|
||||
|
||||
@@ -7,8 +7,8 @@ import io.kestra.core.models.triggers.AbstractTrigger;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.models.triggers.TriggerContext;
|
||||
import io.kestra.core.queues.QueueException;
|
||||
import io.kestra.core.schedulers.ScheduleContextInterface;
|
||||
import io.kestra.core.schedulers.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.runners.ScheduleContextInterface;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.jdbc.repository.AbstractJdbcTriggerRepository;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.inject.Singleton;
|
||||
|
||||
@@ -157,5 +157,6 @@ dependencies {
|
||||
api "io.kestra:repository-memory:$version"
|
||||
api "io.kestra:runner-memory:$version"
|
||||
api "io.kestra:storage-local:$version"
|
||||
api "io.kestra:scheduler:$version"
|
||||
}
|
||||
}
|
||||
|
||||
20
scheduler/build.gradle
Normal file
20
scheduler/build.gradle
Normal file
@@ -0,0 +1,20 @@
|
||||
configurations {
|
||||
implementation.extendsFrom(micronaut)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor project(':processor')
|
||||
implementation project(":core")
|
||||
|
||||
// test
|
||||
testAnnotationProcessor project(':processor')
|
||||
testImplementation project(':core').sourceSets.test.output
|
||||
testImplementation project(':storage-local')
|
||||
testImplementation project(':worker')
|
||||
|
||||
testImplementation project(':tests')
|
||||
testImplementation project(':jdbc')
|
||||
testImplementation project(':jdbc').sourceSets.test.output
|
||||
testImplementation project(':jdbc-h2')
|
||||
testImplementation("io.micronaut.sql:micronaut-jooq")
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
@@ -26,7 +26,6 @@ import io.kestra.core.queues.QueueFactoryInterface;
|
||||
import io.kestra.core.queues.QueueInterface;
|
||||
import io.kestra.core.runners.*;
|
||||
import io.kestra.core.server.ClusterEvent;
|
||||
import io.kestra.core.server.Service;
|
||||
import io.kestra.core.server.ServiceStateChangeEvent;
|
||||
import io.kestra.core.server.ServiceType;
|
||||
import io.kestra.core.services.*;
|
||||
@@ -64,7 +63,7 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Singleton
|
||||
@SuppressWarnings("this-escape")
|
||||
public abstract class AbstractScheduler implements Scheduler, Service {
|
||||
public abstract class AbstractScheduler implements Scheduler {
|
||||
protected final ApplicationContext applicationContext;
|
||||
protected final QueueInterface<Execution> executionQueue;
|
||||
protected final QueueInterface<Trigger> triggerQueue;
|
||||
@@ -824,7 +823,7 @@ public abstract class AbstractScheduler implements Scheduler, Service {
|
||||
|
||||
private void log(SchedulerExecutionWithTrigger executionWithTrigger) {
|
||||
metricRegistry
|
||||
.counter(MetricRegistry.METRIC_SCHEDULER_TRIGGER_COUNT, MetricRegistry.METRIC_SCHEDULER_TRIGGER_COUNT_DESCRIPTION, metricRegistry.tags(executionWithTrigger))
|
||||
.counter(MetricRegistry.METRIC_SCHEDULER_TRIGGER_COUNT, MetricRegistry.METRIC_SCHEDULER_TRIGGER_COUNT_DESCRIPTION, metricRegistry.tags(executionWithTrigger.getExecution()))
|
||||
.increment();
|
||||
|
||||
ZonedDateTime now = now();
|
||||
@@ -841,7 +840,7 @@ public abstract class AbstractScheduler implements Scheduler, Service {
|
||||
// FIXME : "late" are not excluded and can increase delay value (false positive)
|
||||
if (next != null && now.isBefore(next)) {
|
||||
metricRegistry
|
||||
.timer(MetricRegistry.METRIC_SCHEDULER_TRIGGER_DELAY_DURATION, MetricRegistry.METRIC_SCHEDULER_TRIGGER_DELAY_DURATION_DESCRIPTION, metricRegistry.tags(executionWithTrigger))
|
||||
.timer(MetricRegistry.METRIC_SCHEDULER_TRIGGER_DELAY_DURATION, MetricRegistry.METRIC_SCHEDULER_TRIGGER_DELAY_DURATION_DESCRIPTION, metricRegistry.tags(executionWithTrigger.getExecution()))
|
||||
.record(Duration.between(
|
||||
executionWithTrigger.getTriggerContext().getDate(), now
|
||||
));
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
import io.kestra.core.repositories.ExecutionRepositoryInterface;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -1,9 +1,9 @@
|
||||
package io.kestra.core.endpoints;
|
||||
package io.kestra.scheduler.endpoint;
|
||||
|
||||
import io.kestra.core.models.flows.FlowWithException;
|
||||
import io.kestra.core.models.triggers.AbstractTrigger;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.schedulers.AbstractScheduler;
|
||||
import io.kestra.scheduler.AbstractScheduler;
|
||||
import io.micronaut.context.annotation.Requires;
|
||||
import io.micronaut.management.endpoint.annotation.Endpoint;
|
||||
import io.micronaut.management.endpoint.annotation.Read;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.kestra.core.models.Label;
|
||||
@@ -16,6 +16,7 @@ import io.kestra.core.models.triggers.TriggerContext;
|
||||
import io.kestra.core.queues.QueueException;
|
||||
import io.kestra.core.queues.QueueFactoryInterface;
|
||||
import io.kestra.core.queues.QueueInterface;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.services.ExecutionService;
|
||||
import io.kestra.plugin.core.debug.Return;
|
||||
import io.kestra.core.utils.IdUtils;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
import io.kestra.core.models.flows.FlowWithSource;
|
||||
@@ -8,6 +8,7 @@ import io.kestra.core.models.flows.GenericFlow;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.repositories.FlowRepositoryInterface;
|
||||
import io.kestra.core.runners.FlowListeners;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.utils.TestsUtils;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
import io.kestra.plugin.core.condition.DayWeekInMonth;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.Label;
|
||||
import io.kestra.core.models.flows.FlowWithSource;
|
||||
@@ -6,6 +6,7 @@ import io.kestra.core.models.property.Property;
|
||||
import io.kestra.core.models.flows.GenericFlow;
|
||||
import io.kestra.core.models.triggers.AbstractTrigger;
|
||||
import io.kestra.core.repositories.FlowRepositoryInterface;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.tasks.test.FailingPollingTrigger;
|
||||
import io.kestra.core.utils.TestsUtils;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
import io.kestra.core.models.flows.Flow;
|
||||
@@ -10,6 +10,7 @@ import io.kestra.core.models.triggers.RecoverMissedSchedules;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.repositories.FlowRepositoryInterface;
|
||||
import io.kestra.core.runners.FlowListeners;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.utils.Await;
|
||||
import io.kestra.core.utils.TestsUtils;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import com.devskiller.friendly_id.FriendlyId;
|
||||
import io.kestra.core.models.executions.TaskRun;
|
||||
@@ -7,6 +7,7 @@ import io.kestra.core.models.flows.PluginDefault;
|
||||
import io.kestra.core.models.property.Property;
|
||||
import io.kestra.core.models.flows.GenericFlow;
|
||||
import io.kestra.core.repositories.FlowRepositoryInterface;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.utils.TestsUtils;
|
||||
import io.kestra.jdbc.runner.JdbcScheduler;
|
||||
import io.kestra.plugin.core.condition.Expression;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.kestra.core.models.Label;
|
||||
@@ -1,8 +1,7 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.Label;
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
import io.kestra.core.models.flows.Flow;
|
||||
import io.kestra.core.models.flows.FlowWithSource;
|
||||
import io.kestra.core.models.flows.State;
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
@@ -1,4 +1,4 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.conditions.ConditionContext;
|
||||
import io.kestra.core.models.executions.Execution;
|
||||
@@ -113,7 +113,7 @@ public class SchedulerTriggerChangeTest extends AbstractSchedulerTest {
|
||||
applicationContext,
|
||||
flowListenersService
|
||||
);
|
||||
Worker worker = applicationContext.createBean(TestMethodScopedWorker.class, IdUtils.create(), 8, null)
|
||||
DefaultWorker worker = applicationContext.createBean(TestMethodScopedWorker.class, IdUtils.create(), 8, null)
|
||||
) {
|
||||
// start the worker as it execute polling triggers
|
||||
worker.run();
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.kestra.core.schedulers;
|
||||
package io.kestra.scheduler;
|
||||
|
||||
import io.kestra.core.models.triggers.Trigger;
|
||||
import io.kestra.core.runners.SchedulerTriggerStateInterface;
|
||||
import io.kestra.core.utils.IdUtils;
|
||||
import io.kestra.core.junit.annotations.KestraTest;
|
||||
import jakarta.inject.Inject;
|
||||
1
scheduler/src/test/resources/allure.properties
Normal file
1
scheduler/src/test/resources/allure.properties
Normal file
@@ -0,0 +1 @@
|
||||
allure.results.directory=build/allure-results
|
||||
80
scheduler/src/test/resources/application-test.yml
Normal file
80
scheduler/src/test/resources/application-test.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
micronaut:
|
||||
router:
|
||||
static-resources:
|
||||
ui:
|
||||
paths: classpath:ui
|
||||
mapping: /ui/**
|
||||
|
||||
http:
|
||||
client:
|
||||
read-idle-timeout: 60s
|
||||
connect-timeout: 30s
|
||||
read-timeout: 60s
|
||||
http-version: HTTP_1_1
|
||||
services:
|
||||
api:
|
||||
url: http://localhost:28181
|
||||
server:
|
||||
cors:
|
||||
enabled: true
|
||||
configurations:
|
||||
all:
|
||||
allowedOrigins:
|
||||
- http://bad-origin
|
||||
jackson:
|
||||
serialization:
|
||||
writeDatesAsTimestamps: false
|
||||
writeDurationsAsTimestamps: false
|
||||
serialization-inclusion: non_null
|
||||
deserialization:
|
||||
FAIL_ON_UNKNOWN_PROPERTIES: false
|
||||
|
||||
kestra:
|
||||
url: http://localhost:8081
|
||||
encryption:
|
||||
secret-key: I6EGNzRESu3X3pKZidrqCGOHQFUFC0yK
|
||||
server-type: STANDALONE
|
||||
storage:
|
||||
type: local
|
||||
local:
|
||||
base-path: /tmp/unittest
|
||||
anonymous-usage-report:
|
||||
enabled: true
|
||||
uri: https://api.kestra.io/v1/reports/usages
|
||||
initial-delay: 5m
|
||||
fixed-delay: 1h
|
||||
server:
|
||||
access-log:
|
||||
enabled: false
|
||||
basic-auth:
|
||||
username: admin@kestra.io
|
||||
password: Kestra123
|
||||
open-urls:
|
||||
- "/ping"
|
||||
- "/api/v1/executions/webhook/"
|
||||
liveness:
|
||||
enabled: false
|
||||
service:
|
||||
purge:
|
||||
initial-delay: 1h
|
||||
fixed-delay: 1d
|
||||
retention: 30d
|
||||
queue:
|
||||
type: h2
|
||||
repository:
|
||||
type: h2
|
||||
|
||||
datasources:
|
||||
h2:
|
||||
url: jdbc:h2:mem:public;TIME ZONE=UTC;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||
username: sa
|
||||
password: ""
|
||||
driverClassName: org.h2.Driver
|
||||
flyway:
|
||||
datasources:
|
||||
h2:
|
||||
enabled: true
|
||||
locations:
|
||||
- classpath:migrations/h2
|
||||
ignore-migration-patterns: "*:missing,*:future"
|
||||
out-of-order: true
|
||||
11
scheduler/src/test/resources/logback.xml
Normal file
11
scheduler/src/test/resources/logback.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
<include resource="logback/base.xml" />
|
||||
<include resource="logback/text.xml" />
|
||||
<include resource="logback/test.xml" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="STDERR" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -18,6 +18,7 @@ include 'jdbc-postgres'
|
||||
|
||||
include 'webserver'
|
||||
include 'executor'
|
||||
include 'scheduler'
|
||||
include 'worker'
|
||||
|
||||
include 'ui'
|
||||
|
||||
Reference in New Issue
Block a user