use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessQueueTest method lifecycle.
@Test
public void lifecycle() {
final TestPipeline pipeline = new TestPipeline();
final int pipelineParallelism = pipeline.configurePipeline().pipelineParallelism();
final int processQueueMaxSize = pipelineParallelism * MAX_QUEUE_SIZE_PARALLELISM_MULTIPLIER;
List<ProcessEntity> activeEntities = Collections.nCopies(ACTIVE_PROCESS_CNT, mock(ProcessEntity.class));
List<ProcessEntity> pendingEntities = Collections.nCopies(PENDING_PROCESS_CNT, mock(ProcessEntity.class));
doReturn(activeEntities).when(processService).getUnlockedActiveProcesses(any(), eq(processQueueMaxSize));
doReturn(pendingEntities).when(processService).getPendingProcesses(any(), eq(processQueueMaxSize - ACTIVE_PROCESS_CNT));
ProcessQueue processQueue = spy(new ProcessQueue(pipeliteConfiguration, pipeliteServices, pipeline));
assertThat(processQueue.isRefreshQueue()).isTrue();
assertThat(processQueue.getProcessQueueSize()).isZero();
assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
assertThat(processQueue.getProcessQueueRefreshSize()).isZero();
// Queue processes.
processQueue.refreshQueue();
verify(processQueue, times(1)).refreshQueue();
assertThat(processQueue.isRefreshQueue()).isFalse();
assertThat(processQueue.getProcessQueueSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
assertThat(processQueue.getProcessQueueRefreshSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
for (int i = 0; i < ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT; ++i) {
assertThat(processQueue.nextProcess(0)).isNotNull();
}
assertThat(processQueue.isRefreshQueue()).isTrue();
assertThat(processQueue.getProcessQueueSize()).isZero();
assertThat(processQueue.getProcessQueueMaxSize()).isEqualTo(processQueueMaxSize);
assertThat(processQueue.getProcessQueueRefreshSize()).isEqualTo(ACTIVE_PROCESS_CNT + PENDING_PROCESS_CNT);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessEntityCreatorTest method processEntity.
private static ProcessEntity processEntity(String pipelineName, String processId) {
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
return processEntity;
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessFactoryTest method createSuccess.
@Test
public void createSuccess() {
ProcessEntity processEntity = new ProcessEntity();
processEntity.setProcessId(PROCESS_ID);
processEntity.setPipelineName(PIPELINE_NAME);
Pipeline pipeline = new Pipeline() {
@Override
public String pipelineName() {
return PIPELINE_NAME;
}
@Override
public Options configurePipeline() {
return new Options().pipelineParallelism(5);
}
@Override
public void configureProcess(ProcessBuilder builder) {
builder.execute("STAGE1").withSyncTestExecutor();
}
};
Process process = ProcessFactory.create(processEntity, pipeline);
assertThat(process).isNotNull();
assertThat(process.getProcessId()).isEqualTo(PROCESS_ID);
assertThat(process.getProcessEntity()).isNotNull();
assertThat(process.getProcessEntity()).isSameAs(processEntity);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessController method getProcesses.
private static List<ProcessInfo> getProcesses(ProcessRunnerPool processRunnerPool, String pipelineName) {
List<ProcessInfo> processes = new ArrayList<>();
for (ProcessRunner processRunner : processRunnerPool.getActiveProcessRunners()) {
Process process = processRunner.getProcess();
ProcessEntity processEntity = process.getProcessEntity();
if (pipelineName == null || pipelineName.equals(processRunner.getPipelineName())) {
ProcessInfo processInfo = getProcess(processEntity);
processes.add(processInfo);
}
}
return processes;
}
Aggregations