Skip to content

Commit

Permalink
fix(core): Schedule trigger cannot have an interval (#2008)
Browse files Browse the repository at this point in the history
close #2005
  • Loading branch information
loicmathieu authored Sep 1, 2023
1 parent c0b6132 commit 102e84c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.kestra.core.runners.RunnerUtils;
import io.kestra.core.services.ConditionService;
import io.kestra.core.validations.CronExpression;
import io.swagger.v3.oas.annotations.Hidden;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
Expand All @@ -35,6 +36,7 @@
import java.util.Optional;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

@SuperBuilder
@ToString
Expand Down Expand Up @@ -143,7 +145,9 @@ public class Schedule extends AbstractTrigger implements PollingTriggerInterface
@PluginProperty
private ScheduleBackfill backfill;

@Schema(hidden = true)
@Builder.Default
@Null
private final Duration interval = null;

@Valid
Expand Down
15 changes: 15 additions & 0 deletions core/src/test/java/io/kestra/core/validations/ScheduleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,19 @@ void cronValidation() {
assertThat(modelValidator.isValid(build).isPresent(), is(true));
assertThat(modelValidator.isValid(build).get().getMessage(), containsString("backfill and lateMaximumDelay are incompatible options"));
}

@Test
void intervalValidation() {
Schedule build = Schedule.builder()
.id(IdUtils.create())
.type(Schedule.class.getName())
.cron("* * * * *")
.interval(Duration.ofSeconds(5))
.build();


assertThat(modelValidator.isValid(build).isPresent(), is(true));
assertThat(modelValidator.isValid(build).get().getMessage(), containsString("interval: must be null"));

}
}

0 comments on commit 102e84c

Please sign in to comment.