Search in sources :

Example 1 with DockerRuntimeConfig

use of org.guvnor.ala.docker.config.DockerRuntimeConfig 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());
}
Also used : ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) DockerProviderConfigImpl(org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl) DockerRuntimeConfigImpl(org.guvnor.ala.docker.config.impl.DockerRuntimeConfigImpl) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) Runtime(org.guvnor.ala.runtime.Runtime) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) RuntimeProvisioningService(org.guvnor.ala.services.api.RuntimeProvisioningService) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) DockerRuntimeConfig(org.guvnor.ala.docker.config.DockerRuntimeConfig) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) Client(javax.ws.rs.client.Client) Ignore(org.junit.Ignore)

Example 2 with DockerRuntimeConfig

use of org.guvnor.ala.docker.config.DockerRuntimeConfig 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());
}
Also used : RuntimeQueryResultItemList(org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList) ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) RuntimeQuery(org.guvnor.ala.services.api.RuntimeQuery) DockerRuntimeConfig(org.guvnor.ala.docker.config.DockerRuntimeConfig) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) Provider(org.guvnor.ala.runtime.providers.Provider) Test(org.junit.Test)

Example 3 with DockerRuntimeConfig

use of org.guvnor.ala.docker.config.DockerRuntimeConfig in project kie-wb-common by kiegroup.

the class ContextAwareDockerRuntimeExecConfig method setContext.

@Override
@JsonIgnore
public void setContext(final Map<String, ?> context) {
    this.context = context;
    final DockerRuntimeConfig dockerRuntimeConfiguration = (DockerRuntimeConfig) context.get("docker-runtime-config");
    this.providerId = dockerRuntimeConfiguration.getProviderId();
    this.image = dockerRuntimeConfiguration.getImage();
    this.port = dockerRuntimeConfiguration.getPort();
    this.pull = dockerRuntimeConfiguration.isPull();
}
Also used : DockerRuntimeConfig(org.guvnor.ala.docker.config.DockerRuntimeConfig) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore)

Aggregations

DockerRuntimeConfig (org.guvnor.ala.docker.config.DockerRuntimeConfig)3 DockerProviderConfig (org.guvnor.ala.docker.config.DockerProviderConfig)2 DockerProvider (org.guvnor.ala.docker.model.DockerProvider)2 ProviderList (org.guvnor.ala.services.api.itemlist.ProviderList)2 ProviderTypeList (org.guvnor.ala.services.api.itemlist.ProviderTypeList)2 RuntimeList (org.guvnor.ala.services.api.itemlist.RuntimeList)2 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 Client (javax.ws.rs.client.Client)1 WebTarget (javax.ws.rs.client.WebTarget)1 DockerProviderConfigImpl (org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl)1 DockerRuntimeConfigImpl (org.guvnor.ala.docker.config.impl.DockerRuntimeConfigImpl)1 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)1 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)1 Runtime (org.guvnor.ala.runtime.Runtime)1 Provider (org.guvnor.ala.runtime.providers.Provider)1 RuntimeProvisioningService (org.guvnor.ala.services.api.RuntimeProvisioningService)1 RuntimeQuery (org.guvnor.ala.services.api.RuntimeQuery)1 RuntimeQueryResultItemList (org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList)1 ResteasyWebTarget (org.jboss.resteasy.client.jaxrs.ResteasyWebTarget)1 Ignore (org.junit.Ignore)1