use of org.guvnor.ala.services.api.RuntimeProvisioningService in project kie-wb-common by kiegroup.
the class RuntimeEndpointsTestIT method checkDockerService.
@Ignore
public void checkDockerService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
RuntimeProvisioningService proxy = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxy.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfigImpl();
proxy.registerProvider(dockerProviderConfig);
ProviderList allProviders = proxy.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof DockerProvider);
DockerProvider dockerProvider = (DockerProvider) allProviders.getItems().get(0);
DockerRuntimeConfig runtimeConfig = new DockerRuntimeConfigImpl(dockerProvider, "kitematic/hello-world-nginx", "8080", true);
RuntimeList allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
String newRuntime = proxy.newRuntime(runtimeConfig);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
Runtime runtime = allRuntimes.getItems().get(0);
assertTrue(runtime instanceof DockerRuntime);
DockerRuntime dockerRuntime = (DockerRuntime) runtime;
assertEquals("Running", dockerRuntime.getState().getState());
proxy.stopRuntime(newRuntime);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
runtime = allRuntimes.getItems().get(0);
assertTrue(runtime instanceof DockerRuntime);
dockerRuntime = (DockerRuntime) runtime;
assertEquals("Stopped", dockerRuntime.getState().getState());
proxy.destroyRuntime(newRuntime, true);
allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
use of org.guvnor.ala.services.api.RuntimeProvisioningService in project kie-wb-common by kiegroup.
the class PipelineEndpointsTestIT method checkService.
@Ignore
public void checkService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
PipelineService proxyPipeline = restEasyTarget.proxy(PipelineService.class);
RuntimeProvisioningService proxyRuntime = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxyRuntime.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfigImpl();
proxyRuntime.registerProvider(dockerProviderConfig);
ProviderList allProviders = proxyRuntime.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof DockerProvider);
PipelineConfigsList allPipelines = proxyPipeline.getPipelineConfigs(0, 10, "", true);
assertNotNull(allPipelines);
assertEquals(0, allPipelines.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("MavenBuildExecConfig", new MavenBuildExecConfigImpl()));
configs.add(new PipelineConfigStage("DockerProviderConfig", new DockerProviderConfigImpl()));
configs.add(new PipelineConfigStage("ContextAwareDockerProvisioning", new ContextAwareDockerProvisioningConfig()));
configs.add(new PipelineConfigStage("ContextAwareDockerRuntimeExec", new ContextAwareDockerRuntimeExecConfig()));
String newPipeline = proxyPipeline.newPipeline(new PipelineConfigImpl("mypipe", configs));
Input input = new Input();
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);
proxyPipeline.runPipeline("mypipe", input, false);
RuntimeList allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
proxyRuntime.destroyRuntime(allRuntimes.getItems().get(0).getId(), true);
allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
use of org.guvnor.ala.services.api.RuntimeProvisioningService in project kie-wb-common by kiegroup.
the class RuntimeEndpointsTestIT method checkOpenShiftService.
/**
* Can be used if internal to red hat.
* TODO: replace with more lightweight image and non-internal (minishift?) environment
* @throws Exception
*/
@Ignore
public void checkOpenShiftService() throws Exception {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
RuntimeProvisioningService proxy = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxy.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
OpenShiftProviderConfigImpl openshiftProviderConfig = createProviderConfig();
proxy.registerProvider(openshiftProviderConfig);
ProviderList allProviders = proxy.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof OpenShiftProvider);
OpenShiftProvider openshiftProvider = (OpenShiftProvider) allProviders.getItems().get(0);
OpenShiftRuntimeConfig runtimeConfig = createRuntimeConfig(openshiftProvider, "coss1");
@SuppressWarnings("unused") OpenShiftRuntime openshiftRuntime = getOpenShiftRuntime(proxy, 0, null);
String runtimeId = proxy.newRuntime(runtimeConfig);
openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.READY);
proxy.startRuntime(runtimeId);
openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.RUNNING);
proxy.stopRuntime(runtimeId);
openshiftRuntime = getOpenShiftRuntime(proxy, 1, OpenShiftRuntimeState.READY);
proxy.destroyRuntime(runtimeId, true);
openshiftRuntime = getOpenShiftRuntime(proxy, 0, null);
}
Aggregations