private void prepareExecution() { //mock the execution inputs pipeline = mock(Pipeline.class); stages = mockStages(PIPELINE_STAGES_SIZE); when(pipeline.getStages()).thenReturn(stages); when(pipeline.getName()).thenReturn(PIPELINE_ID); when(pipelineRegistry.getPipelineByName(PIPELINE_ID)).thenReturn(pipeline); taskDef = mock(PipelineExecutorTaskDef.class); input = mock(Input.class); when(taskDef.getInput()).thenReturn(input); when(taskDef.getPipeline()).thenReturn(PIPELINE_ID); }
private void registerPipelines(Iterator<SystemPipelineDescriptor> iterator) { iterator.forEachRemaining(pipelineDescriptor -> { if (pipelineDescriptor.getProviderType().isPresent()) { pipelineRegistry.registerPipeline(pipelineDescriptor.getPipeline(), pipelineDescriptor.getProviderType().get()); } else { pipelineRegistry.registerPipeline(pipelineDescriptor.getPipeline()); } }); }
@Override public List<String> getPipelineNames(String providerTypeName, String providerTypeVersion, Integer page, Integer pageSize, String sort, boolean sortOrder) throws BusinessException { return pipelineRegistry.getPipelines(providerTypeName, providerTypeVersion, page, pageSize, sort, sortOrder) .stream() .map(Pipeline::getName) .collect(Collectors.toList()); }
final Input input, final boolean async) throws BusinessException { final Pipeline pipeline = pipelineRegistry.getPipelineByName(pipelineId); if (pipeline == null) { throw new BusinessException("Pipeline: " + pipelineId + " was not found."); providerType = pipelineRegistry.getProviderType(pipelineId);
private void prepareExecution() { //mock the execution inputs pipeline = mock(Pipeline.class); stages = mockStages(PIPELINE_STAGES_SIZE); when(pipeline.getStages()).thenReturn(stages); when(pipeline.getName()).thenReturn(PIPELINE_ID); when(pipelineRegistry.getPipelineByName(PIPELINE_ID)).thenReturn(pipeline); taskDef = mock(PipelineExecutorTaskDef.class); input = mock(Input.class); when(taskDef.getInput()).thenReturn(input); when(taskDef.getPipeline()).thenReturn(PIPELINE_ID); }
@Override public String newPipeline(PipelineConfig config, ProviderType providerType) throws BusinessException { final Pipeline pipeline = PipelineFactory.startFrom(null).build(config); pipelineRegistry.registerPipeline(pipeline, providerType); return config.getName(); }
@Override public PipelineConfigsList getPipelineConfigs(Integer page, Integer pageSize, String sort, boolean sortOrder) throws BusinessException { final List<PipelineConfig> configs = pipelineRegistry.getPipelines(page, pageSize, sort, sortOrder).stream() .filter(p -> p.getConfig() != null) .map(Pipeline::getConfig) .collect(Collectors.toList()); return new PipelineConfigsList(configs); }
@Before public void setUp() { pipelineInvoker = new BuildPipelineInvoker(pipelineExecutor, pipelineRegistry); when(pipelineRegistry.getPipelineByName(BuildPipelineInitializer.LOCAL_BUILD_PIPELINE)).thenReturn(pipeline); when(buildRequest.getModule()).thenReturn(module); when(module.getRootPath()).thenReturn(rootPath); when(rootPath.toURI()).thenReturn(ROOT_PATH_URI); when(resource.toURI()).thenReturn(RESOURCE_URI_1); }
@Override public String newPipeline(PipelineConfig config) throws BusinessException { final Pipeline pipeline = PipelineFactory.startFrom(null).build(config); pipelineRegistry.registerPipeline(pipeline); return config.getName(); }
@Override public PipelineConfigsList getPipelineConfigs(String providerTypeName, String providerTypeVersion, Integer page, Integer pageSize, String sort, boolean sortOrder) throws BusinessException { final List<PipelineConfig> configs = pipelineRegistry.getPipelines(providerTypeName, providerTypeVersion, page, pageSize, sort, sortOrder) .stream() .filter(p -> p.getConfig() != null) .map(Pipeline::getConfig) .collect(Collectors.toList()); return new PipelineConfigsList(configs); }
@Before public void setUp() { super.setUp(); error = mock(Throwable.class); when(error.getMessage()).thenReturn(ERROR_MESSAGE); pipelineExecutorExceptionCaptor = ArgumentCaptor.forClass(PipelineExecutorException.class); pipeline = mock(Pipeline.class); stages = mockStages(PIPELINE_STAGES_SIZE); when(pipeline.getStages()).thenReturn(stages); when(pipeline.getName()).thenReturn(PIPELINE_ID); when(pipelineRegistry.getPipelineByName(PIPELINE_ID)).thenReturn(pipeline); //pick an arbitrary stage for events testing. stage = stages.get(0); taskDef = mock(PipelineExecutorTaskDef.class); input = mock(Input.class); when(taskDef.getInput()).thenReturn(input); when(taskDef.getPipeline()).thenReturn(PIPELINE_ID); task = spy(taskManagerHelper.createTask(taskDef, TASK_ID)); taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.getTask()).thenReturn(task); //emulate there's a running task. taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); }
/** * Initializes a build pipeline based on local structures and optimizations required by the workbench. */ private void initLocalBuildPipeline() { final Pipeline localBuildPipeline = PipelineFactory .newBuilder() .addConfigStage("Local Source Config", new LocalSourceConfig() { }) .addConfigStage("Local Project Config", new LocalProjectConfig() { }) .addConfigStage("Local Build Config", new LocalBuildConfigImpl()) .addConfigStage("Local Build Exec", new LocalBuildExecConfig() { }) .buildAs(LOCAL_BUILD_PIPELINE); pipelineRegistry.registerPipeline(localBuildPipeline); }
@Before public void setUp() { super.setUp(); error = mock(Throwable.class); when(error.getMessage()).thenReturn(ERROR_MESSAGE); pipelineExecutorErrorCaptor = ArgumentCaptor.forClass(PipelineExecutorError.class); pipeline = mock(Pipeline.class); stages = mockStages(PIPELINE_STAGES_SIZE); when(pipeline.getStages()).thenReturn(stages); when(pipeline.getName()).thenReturn(PIPELINE_ID); when(pipelineRegistry.getPipelineByName(PIPELINE_ID)).thenReturn(pipeline); //pick an arbitrary stage for events testing. stage = stages.get(0); taskDef = mock(PipelineExecutorTaskDef.class); input = mock(Input.class); when(taskDef.getInput()).thenReturn(input); when(taskDef.getPipeline()).thenReturn(PIPELINE_ID); task = spy(taskManagerHelper.createTask(taskDef, TASK_ID)); taskEntry = mock(PipelineExecutorTaskManagerImpl.TaskEntry.class); when(taskEntry.getTask()).thenReturn(task); //emulate there's a running task. taskManager.currentTasks.put(TASK_ID, taskEntry); taskManager.init(); }
/** * Executes a task in asynchronous mode. * @param task the task for execute. * @return the taskId of the task. */ private synchronized void startAsyncTask(final PipelineExecutorTask task) { final Future<?> future = executor.submit(() -> { final Pipeline pipeline = pipelineRegistry.getPipelineByName(task.getTaskDef().getPipeline()); try { pipelineExecutor.execute(task.getTaskDef().getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); } catch (Exception e) { logger.error("An error was produced during pipeline execution for PipelineExecutorTask: " + task.getId(), e); } finally { removeTaskEntry(task.getId()); removeFutureTask(task.getId()); } }); storeFutureTask(task.getId(), future); }
pipe = pipelineRegistry.getPipelineByName(BuildPipelineInitializer.LOCAL_BUILD_PIPELINE);
/** * Executes a task in asynchronous mode. * @param task the task for execute. * @return the taskId of the task. */ private synchronized void startAsyncTask(final PipelineExecutorTask task) { final Future<?> future = executor.submit(() -> { final Pipeline pipeline = pipelineRegistry.getPipelineByName(task.getTaskDef().getPipeline()); try { pipelineExecutor.execute(task.getTaskDef().getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); } catch (Exception e) { logger.error("An error was produced during pipeline execution for PipelineExecutorTask: " + task.getId(), e); } finally { removeTaskEntry(task.getId()); removeFutureTask(task.getId()); } }); storeFutureTask(task.getId(), future); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
/** * Executes a task definition in synchronous mode. * @param taskDef task definition for executing. * @return the taskId assigned to the executed task. */ private String executeSync(final PipelineExecutorTaskDef taskDef) { final PipelineExecutorTaskImpl task = taskManagerHelper.createTask(taskDef); storeTaskEntry(TaskEntry.newSyncEntry(task)); final Pipeline pipeline = pipelineRegistry.getPipelineByName(taskDef.getPipeline()); pipelineExecutor.execute(taskDef.getInput(), pipeline, output -> processPipelineOutput(task, output), localListener); removeTaskEntry(task.getId()); updateExecutorRegistry(task); return task.getId(); }
Consumer<LocalBinaryConfig> consumer) { Pipeline pipe = pipelineRegistry.getPipelineByName(BuildPipelineInitializer.LOCAL_BUILD_PIPELINE);