Search in sources :

Example 1 with Runtime

use of org.guvnor.ala.runtime.Runtime 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 Runtime

use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method destroyRuntime.

@Override
public void destroyRuntime(String runtimeId, boolean forced) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    final PipelineExecutorTrace pipelineTrace = pipelineExecutorRegistry.getExecutorTrace(runtimeById);
    try {
        runtimeFactory.destroyRuntime(runtimeById);
    } catch (Exception e) {
        if (forced) {
            LOG.warn("Runtime destroy raised the following error for runtime: " + runtimeId + " but forced destroy will still remove the runtime from registry.", e);
            runtimeRegistry.deregisterRuntime(runtimeById);
        } else {
            throw e;
        }
    }
    if (pipelineTrace != null) {
        pipelineExecutorRegistry.deregister(pipelineTrace.getTaskId());
    }
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException) PipelineExecutorTrace(org.guvnor.ala.pipeline.execution.PipelineExecutorTrace) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 3 with Runtime

use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method restartRuntime.

@Override
public void restartRuntime(String runtimeId) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    runtimeManagerFactory.restartRuntime(runtimeById);
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 4 with Runtime

use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method startRuntime.

@Override
public void startRuntime(String runtimeId) throws BusinessException {
    final Runtime runtimeById = runtimeRegistry.getRuntimeById(runtimeId);
    if (runtimeById == null) {
        throw new BusinessException("No runtime was found for runtimeId: " + runtimeId);
    }
    runtimeManagerFactory.startRuntime(runtimeById);
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime) BusinessException(org.guvnor.ala.services.exceptions.BusinessException)

Example 5 with Runtime

use of org.guvnor.ala.runtime.Runtime in project kie-wb-common by kiegroup.

the class InMemoryRuntimeRegistryTest method mockRuntime.

protected Runtime mockRuntime(ProviderId providerId, String suffix) {
    Runtime runtime = mock(Runtime.class);
    when(runtime.getId()).thenReturn("Runtime.id." + suffix);
    when(runtime.getName()).thenReturn("Runtime.name." + suffix);
    when(runtime.getProviderId()).thenReturn(providerId);
    return runtime;
}
Also used : Runtime(org.guvnor.ala.runtime.Runtime)

Aggregations

Runtime (org.guvnor.ala.runtime.Runtime)16 Test (org.junit.Test)8 Input (org.guvnor.ala.pipeline.Input)5 Pipeline (org.guvnor.ala.pipeline.Pipeline)5 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)5 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)5 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)4 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)4 MavenBuildConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor)3 MavenBuildExecConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor)3 MavenProjectConfigExecutor (org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor)3 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)3 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)3 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)3 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)3 RuntimeList (org.guvnor.ala.services.api.itemlist.RuntimeList)3 BusinessException (org.guvnor.ala.services.exceptions.BusinessException)3 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)3 MavenBuildConfig (org.guvnor.ala.build.maven.config.MavenBuildConfig)2 MavenBuildExecConfig (org.guvnor.ala.build.maven.config.MavenBuildExecConfig)2