Skip to content

Commit

Permalink
fix(core): loading template to early can lead to infinite wait startu…
Browse files Browse the repository at this point in the history
…p on standalone

since the FlowRepository need KafkaTemplateExecutor and it's not started when injecting flow
  • Loading branch information
tchiotludo committed Feb 10, 2022
1 parent adca9c7 commit 4fb6507
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/test/java/io/kestra/core/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.function.Consumer;

public class Helpers {
public static long FLOWS_COUNT = 48;
public static long FLOWS_COUNT = 47;

public static ApplicationContext applicationContext() throws URISyntaxException {
return applicationContext(
Expand Down
13 changes: 10 additions & 3 deletions core/src/test/java/io/kestra/core/tasks/flows/TemplateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.kestra.core.models.executions.LogEntry;
import io.kestra.core.queues.QueueFactoryInterface;
import io.kestra.core.queues.QueueInterface;
import io.kestra.core.runners.ListenersTest;
import io.kestra.core.tasks.debugs.Echo;
import org.junit.jupiter.api.Test;
import io.kestra.core.models.executions.Execution;
Expand All @@ -13,10 +14,13 @@
import io.kestra.core.runners.RunnerUtils;
import org.slf4j.event.Level;

import java.io.IOException;
import java.net.URISyntaxException;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeoutException;
import jakarta.inject.Inject;
import jakarta.inject.Named;
Expand All @@ -29,6 +33,7 @@ public class TemplateTest extends AbstractMemoryRunnerTest {
@Inject
protected TemplateRepositoryInterface templateRepository;


@Inject
@Named(QueueFactoryInterface.WORKERTASKLOG_NAMED)
protected QueueInterface<LogEntry> logQueue;
Expand All @@ -39,11 +44,10 @@ public class TemplateTest extends AbstractMemoryRunnerTest {
.tasks(Collections.singletonList(Echo.builder().id("test").type(Echo.class.getName()).format("{{ parent.outputs.args['my-forward'] }}").build())).build();

public static void withTemplate(RunnerUtils runnerUtils, TemplateRepositoryInterface templateRepository, QueueInterface<LogEntry> logQueue) throws TimeoutException {
templateRepository.create(TEMPLATE_1);

List<LogEntry> logs = new ArrayList<>();
logQueue.receive(logs::add);


Execution execution = runnerUtils.runOne(
"io.kestra.tests",
"with-template",
Expand All @@ -61,7 +65,10 @@ public static void withTemplate(RunnerUtils runnerUtils, TemplateRepositoryInter
}

@Test
void withTemplate() throws TimeoutException {
void withTemplate() throws TimeoutException, IOException, URISyntaxException {
templateRepository.create(TEMPLATE_1);
repositoryLoader.load(Objects.requireNonNull(ListenersTest.class.getClassLoader().getResource("flows/tests/with-template.yaml")));

TemplateTest.withTemplate(runnerUtils, templateRepository, logQueue);
}
}

0 comments on commit 4fb6507

Please sign in to comment.