use of org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList in project kie-wb-common by kiegroup.
the class RestPipelineImplTest method testAPI.
@Test
public void testAPI() {
ProviderTypeList allProviderTypes = runtimeService.getProviderTypes(0, 10, "", true);
assertEquals(2, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfig() {
};
runtimeService.registerProvider(dockerProviderConfig);
ProviderList allProviders = runtimeService.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
Provider p = allProviders.getItems().get(0);
assertTrue(p instanceof DockerProvider);
// by construction.
int systemPipelines = 2;
PipelineConfigsList allPipelineConfigs = pipelineService.getPipelineConfigs(0, 10, "", true);
assertNotNull(allPipelineConfigs);
assertEquals(systemPipelines, allPipelineConfigs.getItems().size());
List<PipelineConfigStage> configs = new ArrayList<>();
configs.add(new PipelineConfigStage("GitConfig", new GitConfigImpl()));
configs.add(new PipelineConfigStage("MavenProjectConfig", new MavenProjectConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildConfig", new MavenBuildConfigImpl()));
configs.add(new PipelineConfigStage("DockerBuildConfig", new DockerBuildConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildExecConfigImpl", new MavenBuildExecConfigImpl()));
configs.add(new PipelineConfigStage("DockerProviderConfig", new DockerProviderConfigImpl()));
configs.add(new PipelineConfigStage("ContextAwareDockerProvisioningConfig", new ContextAwareDockerProvisioningConfig()));
configs.add(new PipelineConfigStage("ContextAwareDockerRuntimeExecConfig", new ContextAwareDockerRuntimeExecConfig()));
pipelineService.newPipeline(new PipelineConfigImpl("mypipe", configs));
pipelineService.newPipeline(new PipelineConfigImpl("wildlfyPipe", configs), WildflyProviderType.instance());
pipelineService.newPipeline(new PipelineConfigImpl("dockerPipe", configs), DockerProviderType.instance());
allPipelineConfigs = pipelineService.getPipelineConfigs(0, 10, "", true);
int createdPipelines = 3;
int totalPipelines = systemPipelines + createdPipelines;
assertEquals(totalPipelines, allPipelineConfigs.getItems().size());
PipelineConfigsList wildflyConfigs = pipelineService.getPipelineConfigs(WildflyProviderType.instance().getProviderTypeName(), WildflyProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(2, wildflyConfigs.getItems().size());
List<String> wildflyPipelineNames = pipelineService.getPipelineNames(WildflyProviderType.instance().getProviderTypeName(), WildflyProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(2, wildflyPipelineNames.size());
assertTrue(wildflyPipelineNames.contains("wildlfyPipe"));
assertTrue(wildflyPipelineNames.contains(SYSTEM_PIPELINE1));
PipelineConfigsList dockerConfigs = pipelineService.getPipelineConfigs(DockerProviderType.instance().getProviderTypeName(), DockerProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(1, dockerConfigs.getItems().size());
List<String> dockerPipelineNames = pipelineService.getPipelineNames(DockerProviderType.instance().getProviderTypeName(), DockerProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(1, dockerPipelineNames.size());
assertTrue(dockerPipelineNames.contains("dockerPipe"));
Input input = new Input();
input.put("provider-name", "local");
input.put("repo-name", "drools-workshop");
input.put("create-repo", "true");
input.put("branch", "master");
input.put("out-dir", tempPath.getAbsolutePath());
input.put("origin", gitUrl);
String pipelineExecutionId = pipelineService.runPipeline("mypipe", input, false);
RuntimeQueryResultItemList itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertEquals(pipelineExecutionId, itemList.getItems().get(0).getPipelineExecutionId());
pipelineService.deletePipelineExecution(pipelineExecutionId);
itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertNull(itemList.getItems().get(0).getPipelineExecutionId());
RuntimeList allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
runtimeService.destroyRuntime(allRuntimes.getItems().get(0).getId(), true);
allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
assertEquals(18, // 8 Stages x 2 + 2 pipeline events
listener.getEvents().size());
pipelineExecutionId = pipelineService.runPipeline("mypipe", input, true);
pipelineService.stopPipelineExecution(pipelineExecutionId);
itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertEquals(pipelineExecutionId, itemList.getItems().get(0).getPipelineExecutionId());
assertEquals(PipelineExecutorTask.Status.STOPPED.name(), itemList.getItems().get(0).getPipelineStatus());
}
use of org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList in project kie-wb-common by kiegroup.
the class RestRuntimeProvisioningImplTest method testAPI.
@Test
public void testAPI() {
ProviderTypeList allProviderTypes = runtimeService.getProviderTypes(0, 10, "", true);
assertEquals(2, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfig() {
};
runtimeService.registerProvider(dockerProviderConfig);
ProviderList allProviders = runtimeService.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
Provider p = allProviders.getItems().get(0);
assertTrue(p instanceof DockerProvider);
assertNotNull(p.getId());
assertNotNull(p.getProviderType());
assertNotNull(p.getConfig());
DockerRuntimeConfig dockerRuntimeConfiguration = new DockerRuntimeConfig() {
@Override
public String getImage() {
return "kitematic/hello-world-nginx";
}
@Override
public String getPort() {
return "8080";
}
@Override
public boolean isPull() {
return true;
}
@Override
public ProviderId getProviderId() {
return p;
}
};
String newRuntime = runtimeService.newRuntime(dockerRuntimeConfiguration);
assertNotNull(newRuntime);
RuntimeList allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
RuntimeQuery query = RuntimeQueryBuilder.newInstance().withProviderId(p.getId()).build();
RuntimeQueryResultItemList queryResult = runtimeService.executeQuery(query);
assertEquals(1, queryResult.getItems().size());
assertEquals(RuntimeState.RUNNING, queryResult.getItems().get(0).getRuntimeStatus());
runtimeService.destroyRuntime(newRuntime, true);
allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
use of org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList in project kie-wb-common by kiegroup.
the class RuntimeProvisioningServiceBackendImplTest method testExecuteQuery.
@Test
public void testExecuteQuery() {
RuntimeQuery query = mock(RuntimeQuery.class);
List<RuntimeQueryResultItem> values = mockList(RuntimeQueryResultItem.class, ELEMENTS_COUNT);
RuntimeQueryResultItemList list = new RuntimeQueryResultItemList(values);
when(runtimeProvisioningService.executeQuery(query)).thenReturn(list);
List<RuntimeQueryResultItem> result = runtimeProvisioningServiceBackend.executeQuery(query);
verify(runtimeProvisioningService, times(1)).executeQuery(query);
assertEquals(values, result);
}
Aggregations