Skip to content

Commit

Permalink
fix(core): graph on dag are not attaching finally at the end of the d…
Browse files Browse the repository at this point in the history
…ag task
  • Loading branch information
tchiotludo committed Jan 14, 2025
1 parent daddcd4 commit e985438
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/io/kestra/core/utils/GraphUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,13 +483,13 @@ private static void fillGraphDag(
if (currentTask.getTask() instanceof FlowableTask<?>) {
graph.addEdge(
((GraphCluster) currentGraph).getEnd(),
graph.getEnd(),
graph.getFinally(),
new Relation()
);
} else {
graph.addEdge(
currentGraph,
graph.getEnd(),
graph.getFinally(),
new Relation()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import io.kestra.core.models.flows.FlowWithSource;
import io.kestra.core.models.triggers.Trigger;
import io.kestra.core.queues.QueueException;
import io.kestra.core.runners.RunnerUtils;
import io.kestra.plugin.core.trigger.Schedule;
import io.kestra.core.repositories.TriggerRepositoryInterface;
import io.kestra.core.runners.RunnerUtils;
import io.kestra.core.serializers.YamlParser;
import io.kestra.core.services.GraphService;
import io.kestra.plugin.core.flow.Switch;
import io.kestra.core.utils.GraphUtils;
import io.kestra.core.utils.TestsUtils;
import io.kestra.plugin.core.flow.Switch;
import io.kestra.plugin.core.trigger.Schedule;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -243,6 +243,24 @@ void multipleTriggers() throws IllegalVariableEvaluationException, IOException {
assertThat(flowGraph.getClusters().size(), is(1));
}


@Test
void dag() throws IllegalVariableEvaluationException, IOException {
FlowWithSource flow = this.parse("flows/valids/dag.yaml");
FlowGraph flowGraph = GraphUtils.flowGraph(flow, null);

assertThat(flowGraph.getNodes().size(), is(11));
assertThat(flowGraph.getEdges().size(), is(13));
assertThat(flowGraph.getClusters().size(), is(1));

assertThat(edge(flowGraph, ".*root..*", ".*dag.root..*").getRelation().getRelationType(), is(nullValue()));
assertThat(edge(flowGraph, ".*root.dag.*", ".*dag.task1.*").getRelation().getRelationType(), is(RelationType.PARALLEL));
assertThat(edge(flowGraph, ".*dag.task2.*", ".*dag.task4.*").getRelation().getRelationType(), is(RelationType.PARALLEL));
assertThat(edge(flowGraph, ".*dag.task2.*", ".*dag.task6.*").getRelation().getRelationType(), is(RelationType.PARALLEL));
assertThat(edge(flowGraph, ".*dag.task6", ".*dag.end.*").getRelation().getRelationType(), is(nullValue()));
assertThat(edge(flowGraph, ".*dag.task5", ".*dag.end.*").getRelation().getRelationType(), is(nullValue()));
}

@Test
@LoadFlows({"flows/valids/task-flow.yaml",
"flows/valids/switch.yaml"})
Expand Down Expand Up @@ -336,6 +354,7 @@ void finallyDag() throws IllegalVariableEvaluationException, IOException {

assertThat(edge(flowGraph, ".*dag.e1", ".*dag.e2").getRelation().getRelationType(), is(RelationType.ERROR));
assertThat(edge(flowGraph, ".*dag.e2", ".*dag.finally.*").getRelation().getRelationType(), is(nullValue()));
assertThat(edge(flowGraph, ".*dag.t3.end..*", ".*dag.finally.*").getRelation().getRelationType(), is(nullValue()));
assertThat(edge(flowGraph, ".*dag.finally.*", ".*dag.a1").getRelation().getRelationType(), is(RelationType.DYNAMIC));
assertThat(edge(flowGraph, ".*dag.a1", ".*dag.a2").getRelation().getRelationType(), is(RelationType.DYNAMIC));
assertThat(edge(flowGraph, ".*dag.a2", ".*dag.end.*").getRelation().getRelationType(), is(nullValue()));
Expand Down

0 comments on commit e985438

Please sign in to comment.