use of org.guvnor.ala.pipeline.Input in project kie-wb-common by kiegroup.
the class WildflyExecutorTest method testAPI.
@Test
@InSequence(1)
public void testAPI() {
final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
final WildflyAccessInterface wildflyAccessInterface = new WildflyAccessInterfaceImpl();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new GitConfig() {
}).addConfigStage("Maven Project", new MavenProjectConfig() {
}).addConfigStage("Maven Build Config", new MavenBuildConfig() {
}).addConfigStage("Maven Build", new MavenBuildExecConfig() {
}).addConfigStage("Wildfly Provider Config", new WildflyProviderConfig() {
}).addConfigStage("Wildfly Runtime Exec", new ContextAwareWildflyRuntimeExecConfig()).buildAs("my pipe");
WildflyRuntimeExecExecutor wildflyRuntimeExecExecutor = new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface);
final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry), new WildflyProviderConfigExecutor(runtimeRegistry), wildflyRuntimeExecExecutor));
executor.execute(new Input() {
{
put("repo-name", "drools-workshop");
put("create-repo", "true");
put("branch", "master");
put("out-dir", tempPath.getAbsolutePath());
put("origin", gitUrl);
put("provider-name", "wildlfy-test");
put("wildfly-user", "admin");
put("wildfly-password", "Admin#70365");
put("host", ip);
put("port", "8080");
put("management-port", "9990");
}
}, pipe, System.out::println);
List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
Runtime runtime = allRuntimes.get(0);
assertTrue(runtime instanceof WildflyRuntime);
WildflyRuntime wildflyRuntime = (WildflyRuntime) runtime;
WildflyRuntimeManager runtimeManager = new WildflyRuntimeManager(runtimeRegistry, wildflyAccessInterface);
runtimeManager.start(wildflyRuntime);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
assertTrue(runtime instanceof WildflyRuntime);
wildflyRuntime = (WildflyRuntime) runtime;
assertEquals(RUNNING, wildflyRuntime.getState().getState());
runtimeManager.stop(wildflyRuntime);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
assertTrue(runtime instanceof WildflyRuntime);
wildflyRuntime = (WildflyRuntime) runtime;
assertEquals(STOPPED, wildflyRuntime.getState().getState());
wildflyRuntimeExecExecutor.destroy(wildflyRuntime);
wildflyAccessInterface.dispose();
}
use of org.guvnor.ala.pipeline.Input in project kie-wb-common by kiegroup.
the class PipelineExecutorTaskManagerImplHelperTest method testSetTaskInStoppedStatus.
@Test
public void testSetTaskInStoppedStatus() {
List<String> scheduledStages = mockStages(STAGES_COUNT, "scheduled");
List<String> runningStages = mockStages(STAGES_COUNT, "running");
List<String> finishedStages = mockStages(STAGES_COUNT, "finished");
List<String> errorStages = mockStages(STAGES_COUNT, "error");
List<String> stoppedStages = mockStages(STAGES_COUNT, "stopped");
List<String> stages = new ArrayList<>();
stages.addAll(scheduledStages);
stages.addAll(runningStages);
stages.addAll(finishedStages);
stages.addAll(errorStages);
stages.addAll(stoppedStages);
PipelineExecutorTaskDef taskDef = mock(PipelineExecutorTaskDef.class);
Input input = mock(Input.class);
when(taskDef.getInput()).thenReturn(input);
when(taskDef.getStages()).thenReturn(stages);
PipelineExecutorTaskImpl task = new PipelineExecutorTaskImpl(taskDef, "executionId");
// set the pipeline e.g. in running status
task.setPipelineStatus(PipelineExecutorTask.Status.RUNNING);
// set the stages in the corresponding status
setStagesInStatus(task, scheduledStages, PipelineExecutorTask.Status.SCHEDULED);
setStagesInStatus(task, runningStages, PipelineExecutorTask.Status.RUNNING);
setStagesInStatus(task, finishedStages, PipelineExecutorTask.Status.FINISHED);
setStagesInStatus(task, errorStages, PipelineExecutorTask.Status.ERROR);
setStagesInStatus(task, stoppedStages, PipelineExecutorTask.Status.STOPPED);
taskManagerHelper.setTaskInStoppedStatus(task);
// verify all stages were set in the expected status.
// the scheduled stages must have been set to STOPPED
assertStagesInStatus(task, scheduledStages, PipelineExecutorTask.Status.STOPPED);
// the running stages must have been set to STOPPED
assertStagesInStatus(task, runningStages, PipelineExecutorTask.Status.STOPPED);
// the finished stages must remain in FINISHED status
assertStagesInStatus(task, finishedStages, PipelineExecutorTask.Status.FINISHED);
// the error stages must remain in ERROR status
assertStagesInStatus(task, errorStages, PipelineExecutorTask.Status.ERROR);
// the stopped stages must remain in STOPPED status
assertStagesInStatus(task, stoppedStages, PipelineExecutorTask.Status.STOPPED);
// the pipeline must have been stopped
assertEquals(PipelineExecutorTask.Status.STOPPED, task.getPipelineStatus());
}
use of org.guvnor.ala.pipeline.Input in project kie-wb-common by kiegroup.
the class PipelineExecutorTraceImplMarshallerTest method getValue.
@Override
public PipelineExecutorTraceImpl getValue() {
// only the stage names are used by the taskDef, so the pipeline can be mocked.
List<Stage> stages = mockStages(STAGE_COUNT);
Pipeline pipeline = new BasePipeline(PIPELINE_NAME, stages) {
};
Input input = mockInput(PIPELINE_INPUT_SIZE);
PipelineExecutorTaskDefImpl taskDef = new PipelineExecutorTaskDefImpl(pipeline, input);
PipelineExecutorTaskImpl taskImpl = new PipelineExecutorTaskImpl(taskDef, PIPELINE_EXECUTION_ID);
taskImpl.setPipelineStatus(PipelineExecutorTask.Status.SCHEDULED);
taskImpl.setPipelineError(mockError(PIPELINE_ERROR, PIPELINE_ERROR_DETAIL));
taskImpl.getTaskDef().getStages().forEach(stage -> taskImpl.setStageError(stage, mockStageError(stage)));
taskImpl.setOutput(new MockPipelineOutput(PIPELINE_OUTPUT));
return new PipelineExecutorTraceImpl(taskImpl);
}
use of org.guvnor.ala.pipeline.Input in project kie-wb-common by kiegroup.
the class RuntimeServiceImpl method createRuntime.
@Override
public PipelineExecutionTraceKey createRuntime(final ProviderKey providerKey, final String runtimeName, final PipelineKey pipelineKey, final Map<String, String> params) {
checkNotNull("providerKey", providerKey);
checkNotNull("runtimeName", runtimeName);
checkNotNull("pipelineKey", pipelineKey);
validateForCreateRuntime(providerKey, runtimeName);
try {
final Input input = PipelineInputBuilder.newInstance().withRuntimeName(runtimeName).withProvider(providerKey).withParams(params).build();
return new PipelineExecutionTraceKey(pipelineService.runPipeline(pipelineKey.getId(), input, true));
} catch (Exception e) {
logger.error("Runtime creation failed.", e);
throw ExceptionUtilities.handleException(e);
}
}
Aggregations