Search in sources :

Example 36 with RunContext

use of io.kestra.core.runners.RunContext in project kestra by kestra-io.

the class AbstractBashTest method longBashCreateTempFiles.

@Test
void longBashCreateTempFiles() throws Exception {
    List<String> commands = new ArrayList<>();
    for (int i = 0; i < 15000; i++) {
        commands.add("if [ \"" + i + "\" -eq 0 ] || [ \"" + i + "\" -eq 14999  ]; then echo " + i + ";fi;");
    }
    Bash bash = configure(Bash.builder().commands(commands.toArray(String[]::new))).build();
    RunContext runContext = TestsUtils.mockRunContext(runContextFactory, bash, ImmutableMap.of());
    ScriptOutput run = bash.run(runContext);
    assertThat(run.getExitCode(), is(0));
    assertThat(run.getStdOutLineCount(), is(2));
    assertThat(run.getStdErrLineCount() > 0, is(false));
}
Also used : ScriptOutput(io.kestra.core.tasks.scripts.ScriptOutput) RunContext(io.kestra.core.runners.RunContext) Bash(io.kestra.core.tasks.scripts.Bash) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Example 37 with RunContext

use of io.kestra.core.runners.RunContext in project kestra by kestra-io.

the class DeleteTest method run.

@Test
void run() throws Exception {
    RunContext runContext = runContextFactory.of();
    URL resource = DeleteTest.class.getClassLoader().getResource("application.yml");
    URI put = storageInterface.put(new URI("/file/storage/get.yml"), new FileInputStream(Objects.requireNonNull(resource).getFile()));
    Delete bash = Delete.builder().uri(put.toString()).build();
    Delete.Output run = bash.run(runContext);
    assertThat(run.getDeleted(), is(true));
    run = bash.run(runContext);
    assertThat(run.getDeleted(), is(false));
    assertThrows(NoSuchElementException.class, () -> {
        Delete error = Delete.builder().uri(put.toString()).errorOnMissing(true).build();
        error.run(runContext);
    });
}
Also used : RunContext(io.kestra.core.runners.RunContext) URI(java.net.URI) URL(java.net.URL) FileInputStream(java.io.FileInputStream) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Aggregations

RunContext (io.kestra.core.runners.RunContext)37 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)31 Test (org.junit.jupiter.api.Test)31 ScriptOutput (io.kestra.core.tasks.scripts.ScriptOutput)21 HashMap (java.util.HashMap)18 Bash (io.kestra.core.tasks.scripts.Bash)11 Python (io.kestra.core.tasks.scripts.Python)9 Node (io.kestra.core.tasks.scripts.Node)7 FileInputStream (java.io.FileInputStream)6 URI (java.net.URI)6 URL (java.net.URL)5 Logger (org.slf4j.Logger)5 Collectors (java.util.stream.Collectors)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 ConditionContext (io.kestra.core.models.conditions.ConditionContext)3 Execution (io.kestra.core.models.executions.Execution)3 Flow (io.kestra.core.models.flows.Flow)3 List (java.util.List)3 Map (java.util.Map)3 PluginProperty (io.kestra.core.models.annotations.PluginProperty)2