Search in sources :

Example 1 with RuntimeList

use of org.guvnor.ala.services.api.itemlist.RuntimeList 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 RuntimeList

use of org.guvnor.ala.services.api.itemlist.RuntimeList 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());
}
Also used : RuntimeQueryResultItemList(org.guvnor.ala.services.api.itemlist.RuntimeQueryResultItemList) ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) ContextAwareDockerProvisioningConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig) DockerBuildConfigImpl(org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) ArrayList(java.util.ArrayList) DockerProviderConfigImpl(org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl) 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) Input(org.guvnor.ala.pipeline.Input) PipelineConfigStage(org.guvnor.ala.pipeline.PipelineConfigStage) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) PipelineConfigsList(org.guvnor.ala.services.api.itemlist.PipelineConfigsList) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) PipelineConfigImpl(org.guvnor.ala.pipeline.impl.PipelineConfigImpl) ContextAwareDockerRuntimeExecConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig) Test(org.junit.Test)

Example 3 with RuntimeList

use of org.guvnor.ala.services.api.itemlist.RuntimeList 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 4 with RuntimeList

use of org.guvnor.ala.services.api.itemlist.RuntimeList 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());
}
Also used : ProviderList(org.guvnor.ala.services.api.itemlist.ProviderList) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) ContextAwareDockerProvisioningConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig) DockerBuildConfigImpl(org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl) ArrayList(java.util.ArrayList) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) Input(org.guvnor.ala.pipeline.Input) PipelineConfigStage(org.guvnor.ala.pipeline.PipelineConfigStage) PipelineService(org.guvnor.ala.services.api.PipelineService) RuntimeList(org.guvnor.ala.services.api.itemlist.RuntimeList) PipelineConfigsList(org.guvnor.ala.services.api.itemlist.PipelineConfigsList) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Client(javax.ws.rs.client.Client) ContextAwareDockerRuntimeExecConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig) DockerProvider(org.guvnor.ala.docker.model.DockerProvider) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) DockerProviderConfigImpl(org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) RuntimeProvisioningService(org.guvnor.ala.services.api.RuntimeProvisioningService) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) ResteasyWebTarget(org.jboss.resteasy.client.jaxrs.ResteasyWebTarget) WebTarget(javax.ws.rs.client.WebTarget) PipelineConfigImpl(org.guvnor.ala.pipeline.impl.PipelineConfigImpl) Ignore(org.junit.Ignore)

Example 5 with RuntimeList

use of org.guvnor.ala.services.api.itemlist.RuntimeList 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;
}
Also used : 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) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime)

Aggregations

RuntimeList (org.guvnor.ala.services.api.itemlist.RuntimeList)6 DockerProviderConfig (org.guvnor.ala.docker.config.DockerProviderConfig)4 DockerProvider (org.guvnor.ala.docker.model.DockerProvider)4 ProviderList (org.guvnor.ala.services.api.itemlist.ProviderList)4 ProviderTypeList (org.guvnor.ala.services.api.itemlist.ProviderTypeList)4 DockerProviderConfigImpl (org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl)3 Runtime (org.guvnor.ala.runtime.Runtime)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Client (javax.ws.rs.client.Client)2 WebTarget (javax.ws.rs.client.WebTarget)2 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)2 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)2 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)2 DockerRuntimeConfig (org.guvnor.ala.docker.config.DockerRuntimeConfig)2 ContextAwareDockerProvisioningConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig)2 ContextAwareDockerRuntimeExecConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig)2 DockerBuildConfigImpl (org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl)2 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)2 OpenShiftRuntime (org.guvnor.ala.openshift.model.OpenShiftRuntime)2