Skip to content

Commit

Permalink
fix(core): ResumeTest didn't pass anymore
Browse files Browse the repository at this point in the history
As we cannot anymore pause in one branch and continue in the other
  • Loading branch information
loicmathieu committed Oct 18, 2024
1 parent 416e2a1 commit 48da2a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 16 deletions.
24 changes: 21 additions & 3 deletions core/src/test/java/io/kestra/plugin/core/execution/ResumeTest.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
package io.kestra.plugin.core.execution;

import io.kestra.core.models.executions.Execution;
import io.kestra.core.models.flows.Flow;
import io.kestra.core.models.flows.State;
import io.kestra.core.repositories.ExecutionRepositoryInterface;
import io.kestra.core.runners.AbstractMemoryRunnerTest;
import io.kestra.core.utils.Await;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import java.time.Duration;
import java.util.Map;

import static io.kestra.core.utils.Rethrow.throwRunnable;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

class ResumeTest extends AbstractMemoryRunnerTest {
@Inject
private ExecutionRepositoryInterface executionRepository;

@Test
void resume() throws Exception {
Execution execution = runnerUtils.runOne(null, "io.kestra.tests", "resume-execution");
Execution pause = runnerUtils.runOneUntilPaused(null, "io.kestra.tests", "pause");
String pauseId = pause.getId();

Execution resume = runnerUtils.runOne(null, "io.kestra.tests", "resume-execution", null, (flow, execution) -> Map.of("executionId", pauseId));
assertThat(resume.getState().getCurrent(), is(State.Type.SUCCESS));

assertThat(execution.getTaskRunList(), hasSize(5));
assertThat(execution.getState().getCurrent(), is(State.Type.SUCCESS));
Await.until(
() -> executionRepository.findById(null, pauseId).orElseThrow().getState().getCurrent().isTerminated(),
Duration.ofMillis(100),
Duration.ofSeconds(5)
);
}
}
20 changes: 7 additions & 13 deletions core/src/test/resources/flows/valids/resume-execution.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
id: resume-execution
namespace: io.kestra.tests

inputs:
- id: executionId
type: STRING

tasks:
- id: parallel
type: io.kestra.plugin.core.flow.Parallel
tasks:
- id: pause
type: io.kestra.plugin.core.flow.Pause
- id: sequential
type: io.kestra.plugin.core.flow.Sequential
tasks:
- id: log
type: io.kestra.core.tasks.test.Sleep
duration: 100
- id: resume
type: io.kestra.plugin.core.execution.Resume
- id: resume
type: io.kestra.plugin.core.execution.Resume
executionId: "{{inputs.executionId}}"

0 comments on commit 48da2a7

Please sign in to comment.