Search in sources :

Example 1 with CmdExecutorParameters

use of pipelite.stage.parameters.CmdExecutorParameters in project pipelite by enasequence.

the class SingleStageCmdTestProcessConfiguration method configure.

@Override
protected void configure(ProcessBuilder builder) {
    CmdExecutorParameters.CmdExecutorParametersBuilder<?, ?> executorParamsBuilder = CmdExecutorParameters.builder();
    executorParamsBuilder.maximumRetries(maximumRetries()).immediateRetries(immediateRetries());
    CmdExecutorParameters executorParams = executorParamsBuilder.build();
    executorParams.setPermanentErrors(testType().permanentErrors());
    builder.execute(stageName()).withCmdExecutor(testType().nextCmd(pipelineName(), builder.getProcessId(), stageName()), executorParams);
}
Also used : CmdExecutorParameters(pipelite.stage.parameters.CmdExecutorParameters)

Example 2 with CmdExecutorParameters

use of pipelite.stage.parameters.CmdExecutorParameters in project pipelite by enasequence.

the class LocalCmdExecutorTest method test.

@Test
public void test() {
    String stageName = PipeliteIdCreator.stageName();
    CmdExecutor<CmdExecutorParameters> executor = StageExecutor.createCmdExecutor("echo test");
    executor.setExecutorParams(CmdExecutorParameters.builder().build());
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    stage.execute(PIPELINE_NAME, PROCESS_ID, (result) -> {
        assertThat(result.isSuccess()).isTrue();
        assertThat(result.getAttribute(StageExecutorResultAttribute.COMMAND)).isEqualTo("echo test");
        assertThat(result.getAttribute(StageExecutorResultAttribute.EXIT_CODE)).isEqualTo("0");
        assertThat(result.getStageLog()).contains("test\n");
    });
}
Also used : Stage(pipelite.stage.Stage) CmdExecutorParameters(pipelite.stage.parameters.CmdExecutorParameters) Test(org.junit.jupiter.api.Test)

Example 3 with CmdExecutorParameters

use of pipelite.stage.parameters.CmdExecutorParameters in project pipelite by enasequence.

the class SshCmdExecutorTest method test.

@Test
@EnabledIfEnvironmentVariable(named = "PIPELITE_TEST_SSH_HOST", matches = ".+")
public void test() {
    String stageName = PipeliteIdCreator.stageName();
    CmdExecutor<CmdExecutorParameters> executor = StageExecutor.createCmdExecutor("echo test");
    executor.setExecutorParams(CmdExecutorParameters.builder().host(sshTestConfiguration.getHost()).user(sshTestConfiguration.getUser()).timeout(Duration.ofSeconds(30)).build());
    Stage stage = Stage.builder().stageName(stageName).executor(executor).build();
    stage.execute(PIPELINE_NAME, PROCESS_ID, (result) -> {
        // Ignore timeout errors.
        if (result.isErrorType(ErrorType.TIMEOUT_ERROR)) {
            return;
        }
        assertThat(result.isSuccess()).isTrue();
        assertThat(result.getAttribute(StageExecutorResultAttribute.COMMAND)).isEqualTo("echo test");
        assertThat(result.getAttribute(StageExecutorResultAttribute.EXIT_CODE)).isEqualTo("0");
        assertThat(result.getStageLog()).contains("test\n");
    });
}
Also used : Stage(pipelite.stage.Stage) CmdExecutorParameters(pipelite.stage.parameters.CmdExecutorParameters) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) EnabledIfEnvironmentVariable(org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable)

Aggregations

CmdExecutorParameters (pipelite.stage.parameters.CmdExecutorParameters)3 Test (org.junit.jupiter.api.Test)2 Stage (pipelite.stage.Stage)2 EnabledIfEnvironmentVariable (org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1