use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class InMemoryRuntimeRegistryTest method testGetRuntimes.
@Test
public void testGetRuntimes() {
List<Runtime> result = runtimeRegistry.getRuntimes(0, 1000, RuntimeRegistry.RUNTIME_ID_SORT, true);
assertTrue(result.isEmpty());
List<Runtime> runtimes = mockRuntimeList(providerId, "", ELEMENTS_COUNT);
runtimes.forEach(runtime -> runtimeRegistry.registerRuntime(runtime));
result = runtimeRegistry.getRuntimes(0, 1000, RuntimeRegistry.RUNTIME_ID_SORT, true);
for (Runtime runtime : runtimes) {
assertTrue(result.contains(runtime));
}
}
use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class RuntimeEndpointsTestIT method getOpenShiftRuntime.
private OpenShiftRuntime getOpenShiftRuntime(RuntimeProvisioningService proxy, int expectedCount, String expectedState) {
RuntimeList allRuntimes = proxy.getRuntimes(0, 10, "", true);
assertEquals(expectedCount, allRuntimes.getItems().size());
if (expectedCount == 0) {
return null;
}
Runtime runtime = allRuntimes.getItems().get(0);
assertTrue(runtime instanceof OpenShiftRuntime);
OpenShiftRuntime openshiftRuntime = (OpenShiftRuntime) runtime;
assertEquals(expectedState, openshiftRuntime.getState().getState());
return openshiftRuntime;
}
use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class DockerExecutorTest method testFlexAPI.
@Test
public void testFlexAPI() throws InterruptedException {
final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
final DockerAccessInterface dockerAccessInterface = new DockerAccessInterfaceImpl();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Docker Provider Config", new DockerProviderConfig() {
}).addConfigStage("Docker Runtime Config", new ContextAwareDockerProvisioningConfig() {
}).addConfigStage("Docker Runtime Exec", new ContextAwareDockerRuntimeExecConfig()).buildAs("my pipe");
DockerRuntimeExecExecutor dockerRuntimeExecExecutor = new DockerRuntimeExecExecutor(runtimeRegistry, dockerAccessInterface);
final PipelineExecutor executor = new PipelineExecutor(asList(new DockerProviderConfigExecutor(runtimeRegistry), new DockerProvisioningConfigExecutor(), dockerRuntimeExecExecutor));
executor.execute(new Input() {
{
put("image-name", "kitematic/hello-world-nginx");
put("port-number", "8080");
put("docker-pull", "true");
}
}, pipe, (Runtime b) -> System.out.println(b));
List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
Runtime runtime = allRuntimes.get(0);
assertTrue(runtime instanceof DockerRuntime);
DockerRuntime dockerRuntime = (DockerRuntime) runtime;
DockerRuntimeManager runtimeManager = new DockerRuntimeManager(runtimeRegistry, dockerAccessInterface);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
dockerRuntime = (DockerRuntime) runtime;
assertEquals(RUNNING, dockerRuntime.getState().getState());
runtimeManager.stop(dockerRuntime);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
dockerRuntime = (DockerRuntime) runtime;
assertEquals(STOPPED, dockerRuntime.getState().getState());
dockerRuntimeExecExecutor.destroy(runtime);
dockerAccessInterface.dispose();
}
use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class DockerExecutorTest method testAPI.
@Test
public void testAPI() throws InterruptedException {
final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
final DockerAccessInterface dockerAccessInterface = new DockerAccessInterfaceImpl();
final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new GitConfigImpl()).addConfigStage("Maven Project", new MavenProjectConfigImpl()).addConfigStage("Maven Build Config", new MavenBuildConfigImpl()).addConfigStage("Docker Build Config", new DockerBuildConfigImpl()).addConfigStage("Maven Build", new MavenBuildExecConfigImpl()).addConfigStage("Docker Provider Config", new DockerProviderConfigImpl()).addConfigStage("Docker Runtime Config", new ContextAwareDockerProvisioningConfig()).addConfigStage("Docker Runtime Exec", new ContextAwareDockerRuntimeExecConfig()).buildAs("my pipe");
DockerRuntimeExecExecutor dockerRuntimeExecExecutor = new DockerRuntimeExecExecutor(runtimeRegistry, dockerAccessInterface);
final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry), new DockerBuildConfigExecutor(), new DockerProviderConfigExecutor(runtimeRegistry), new DockerProvisioningConfigExecutor(), dockerRuntimeExecExecutor));
executor.execute(new Input() {
{
put("repo-name", "drools-workshop");
put("create-repo", "true");
put("branch", "master");
put("out-dir", tempPath.getAbsolutePath());
put("origin", gitUrl);
}
}, pipe, (Runtime b) -> System.out.println(b));
List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
Runtime runtime = allRuntimes.get(0);
assertTrue(runtime instanceof DockerRuntime);
DockerRuntime dockerRuntime = (DockerRuntime) runtime;
DockerRuntimeManager runtimeManager = new DockerRuntimeManager(runtimeRegistry, dockerAccessInterface);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
dockerRuntime = (DockerRuntime) runtime;
assertEquals(RUNNING, dockerRuntime.getState().getState());
runtimeManager.stop(dockerRuntime);
allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
runtime = allRuntimes.get(0);
dockerRuntime = (DockerRuntime) runtime;
assertEquals(STOPPED, dockerRuntime.getState().getState());
dockerRuntimeExecExecutor.destroy(runtime);
dockerAccessInterface.dispose();
}
use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.
the class OpenShiftExecutorTest method getRuntime.
private OpenShiftRuntime getRuntime(RuntimeRegistry runtimeRegistry, OpenShiftRuntimeManager runtimeManager, OpenShiftRuntime openshiftRuntime, boolean expected) {
if (openshiftRuntime != null) {
runtimeManager.refresh(openshiftRuntime);
}
if (expected) {
List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.size());
Runtime runtime = allRuntimes.get(0);
assertTrue(runtime instanceof OpenShiftRuntime);
return (OpenShiftRuntime) runtime;
} else {
return null;
}
}
Aggregations