use of pipelite.executor.SimpleLsfExecutor in project pipelite by enasequence.
the class StageExecutorSerializerTest method deserializeExecutionAsync.
@Test
public void deserializeExecutionAsync() {
SimpleLsfExecutor lsfExecutor = StageExecutor.createSimpleLsfExecutor("test");
lsfExecutor.setJobId("test");
SimpleLsfExecutorParameters params = new SimpleLsfExecutorParameters();
params.setHost("host");
params.setQueue("queue");
lsfExecutor.setExecutorParams(params);
StageEntity stageEntity = new StageEntity();
Stage stage = Stage.builder().stageName("STAGE1").executor(lsfExecutor).build();
stage.setStageEntity(stageEntity);
stageEntity.startExecution();
StageService.prepareSaveStage(stage);
assertThat(StageExecutorSerializer.deserializeExecution(stage, StageExecutorSerializer.Deserialize.ASYNC_EXECUTOR)).isTrue();
assertThat(stage.getExecutor()).isNotNull();
assertThat(stage.getExecutor()).isInstanceOf(SimpleLsfExecutor.class);
assertThat(stageEntity.getExecutorName()).isEqualTo("pipelite.executor.SimpleLsfExecutor");
assertThat(stageEntity.getExecutorData()).isEqualTo("{\n" + " \"jobId\" : \"test\",\n" + " \"cmd\" : \"test\"\n" + "}");
assertThat(stageEntity.getExecutorParams()).isEqualTo("{\n" + " \"timeout\" : 604800000,\n" + " \"maximumRetries\" : 3,\n" + " \"immediateRetries\" : 3,\n" + " \"logLines\" : 1000,\n" + " \"host\" : \"host\",\n" + " \"logTimeout\" : 10000,\n" + " \"queue\" : \"queue\"\n" + "}");
}
use of pipelite.executor.SimpleLsfExecutor in project pipelite by enasequence.
the class LsfDescribeJobsCacheTest method test.
@Test
public void test() {
LsfDescribeJobsCache cache = new LsfDescribeJobsCache(Mockito.mock(ServiceConfiguration.class), Mockito.mock(InternalErrorService.class));
SimpleLsfExecutorParameters host1 = SimpleLsfExecutorParameters.builder().host("1").build();
SimpleLsfExecutorParameters host2 = SimpleLsfExecutorParameters.builder().host("2").build();
AbstractLsfExecutor executor1Host1 = new SimpleLsfExecutor();
AbstractLsfExecutor executor2Host1 = new SimpleLsfExecutor();
AbstractLsfExecutor executor3Host2 = new SimpleLsfExecutor();
AbstractLsfExecutor executor4Host1 = new SimpleLsfExecutor();
executor1Host1.setExecutorParams(host1);
executor2Host1.setExecutorParams(host1);
executor3Host2.setExecutorParams(host2);
executor4Host1.setExecutorParams(host1);
assertThat(cache.getCacheContext(executor1Host1).getHost()).isEqualTo(host1.getHost());
assertThat(cache.getCacheContext(executor2Host1).getHost()).isEqualTo(host1.getHost());
assertThat(cache.getCacheContext(executor3Host2).getHost()).isEqualTo(host2.getHost());
assertThat(cache.getCacheContext(executor4Host1).getHost()).isEqualTo(host1.getHost());
DescribeJobs<LsfDescribeJobsCache.RequestContext, LsfDescribeJobsCache.ExecutorContext> describeJobs1 = cache.getDescribeJobs(executor1Host1);
DescribeJobs<LsfDescribeJobsCache.RequestContext, LsfDescribeJobsCache.ExecutorContext> describeJobs2 = cache.getDescribeJobs(executor2Host1);
DescribeJobs<LsfDescribeJobsCache.RequestContext, LsfDescribeJobsCache.ExecutorContext> describeJobs3 = cache.getDescribeJobs(executor3Host2);
DescribeJobs<LsfDescribeJobsCache.RequestContext, LsfDescribeJobsCache.ExecutorContext> describeJobs4 = cache.getDescribeJobs(executor4Host1);
assertThat(describeJobs1 == describeJobs2).isTrue();
assertThat(describeJobs1 != describeJobs3).isTrue();
assertThat(describeJobs1 == describeJobs4).isTrue();
}
use of pipelite.executor.SimpleLsfExecutor in project pipelite by enasequence.
the class TestTypeTest method next.
@Test
public void next() {
TestType testType = TestType.nonPermanentErrorAndThenSuccess;
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
String stageName = PipeliteIdCreator.stageName();
testType.register(pipelineName, processId, stageName);
assertThatThrownBy(() -> testType.lastExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
assertThatThrownBy(() -> testType.lastCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
assertThatThrownBy(() -> testType.lastImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no last exit code");
assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
assertThat(testType.permanentErrors()).containsExactly(EXIT_CODE_PERMANENT_ERROR);
SimpleLsfExecutor executor = new SimpleLsfExecutor();
Stage stage = new Stage(stageName, executor);
TestType.setLastExitCode(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR), pipelineName, processId, stageName);
TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_NON_PERMANENT_ERROR));
assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_NON_PERMANENT_ERROR + "'");
assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_NON_PERMANENT_ERROR);
assertThat(testType.nextExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
assertThat(testType.nextCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
assertThat(testType.nextImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
assertThat(executor.getCmd()).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
TestType.setLastExitCode(String.valueOf(EXIT_CODE_SUCCESS), pipelineName, processId, stageName);
TestType.setNextExitCode(testType, stage, pipelineName, processId, stageName);
assertThat(testType.lastExitCode(pipelineName, processId, stageName)).isEqualTo(String.valueOf(EXIT_CODE_SUCCESS));
assertThat(testType.lastCmd(pipelineName, processId, stageName)).isEqualTo("bash -c 'exit " + EXIT_CODE_SUCCESS + "'");
assertThat(testType.lastImageArgs(pipelineName, processId, stageName)).containsExactly("bash", "-c", "exit " + EXIT_CODE_SUCCESS);
assertThatThrownBy(() -> testType.nextExitCode(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
assertThatThrownBy(() -> testType.nextCmd(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
assertThatThrownBy(() -> testType.nextImageArgs(pipelineName, processId, stageName)).isInstanceOf(RuntimeException.class).hasMessageContaining("Stage has no next exit code");
}
Aggregations