Search in sources :

Example 1 with InMemoryRuntimeRegistry

use of org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry 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();
}
Also used : ContextAwareDockerProvisioningConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig) DockerAccessInterfaceImpl(org.guvnor.ala.docker.access.impl.DockerAccessInterfaceImpl) DockerProviderConfig(org.guvnor.ala.docker.config.DockerProviderConfig) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) Input(org.guvnor.ala.pipeline.Input) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) Runtime(org.guvnor.ala.runtime.Runtime) DockerRuntimeManager(org.guvnor.ala.docker.service.DockerRuntimeManager) DockerAccessInterface(org.guvnor.ala.docker.access.DockerAccessInterface) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) ContextAwareDockerRuntimeExecConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig) Test(org.junit.Test)

Example 2 with InMemoryRuntimeRegistry

use of org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry 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();
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigExecutor(org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor) 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) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) Input(org.guvnor.ala.pipeline.Input) DockerRuntime(org.guvnor.ala.docker.model.DockerRuntime) Runtime(org.guvnor.ala.runtime.Runtime) DockerRuntimeManager(org.guvnor.ala.docker.service.DockerRuntimeManager) DockerAccessInterface(org.guvnor.ala.docker.access.DockerAccessInterface) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) ContextAwareDockerRuntimeExecConfig(org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) DockerProviderConfigImpl(org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl) DockerAccessInterfaceImpl(org.guvnor.ala.docker.access.impl.DockerAccessInterfaceImpl) Pipeline(org.guvnor.ala.pipeline.Pipeline) MavenBuildExecConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) MavenBuildConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor) Test(org.junit.Test)

Example 3 with InMemoryRuntimeRegistry

use of org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry in project kie-wb-common by kiegroup.

the class OpenShiftExecutorTest method testPipelineAndLifecycle.

/**
 * Tests the ALA pipeline and runtime lifecycle.
 *
 * If running via command line, the properties are already set in the pom.xml file.
 * If running in an IDE, set these properties in your debug configuration VM arguments.
 * On Eclipse, Run / Debug Configurations... / Arguments / VM arguments:
 * -Dsun.net.spi.nameservice.provider.1=dns,OpenShiftNameService
 * -Dsun.net.spi.nameservice.provider.2=default
 * -Dorg.guvnor.ala.openshift.access.OpenShiftClientListener.postCreate=org.guvnor.ala.openshift.dns.OpenShiftNameServiceClientListener
 * -Dorg.guvnor.ala.openshift.dns.OpenShiftNameServiceClientListener.routerHost=10.34.75.115
 *
 * @throws Exception
 */
@Test
public void testPipelineAndLifecycle() throws Exception {
    final RuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
    final OpenShiftAccessInterface openshiftAccessInterface = new OpenShiftAccessInterfaceImpl();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("OpenShift Provider Config", new OpenShiftProviderConfig() {
    }).addConfigStage("OpenShift Runtime Config", new ContextAwareOpenShiftRuntimeExecConfig()).buildAs("my pipe");
    final OpenShiftRuntimeExecExecutor<OpenShiftRuntimeExecConfig> openshiftRuntimeExecExecutor = new OpenShiftRuntimeExecExecutor<>(runtimeRegistry, openshiftAccessInterface);
    final PipelineExecutor executor = new PipelineExecutor(asList(new OpenShiftProviderConfigExecutor(runtimeRegistry), openshiftRuntimeExecExecutor));
    final String pvrName = getClass().getSimpleName();
    final String prjName = createProjectName("tpal1");
    final String appName = "myapp";
    final String svcName = appName + "-execserv";
    final String kieServerUser = "executionUser";
    final String kieServerPwd = "execution1!";
    String templateParams = new OpenShiftParameters().param("APPLICATION_NAME", appName).param("IMAGE_STREAM_NAMESPACE", prjName).param("KIE_ADMIN_PWD", "admin1!").param("KIE_SERVER_USER", kieServerUser).param("KIE_SERVER_PWD", kieServerPwd).param("MAVEN_REPO_URL", "http://repository.jboss.org/nexus/content/groups/public/").toString();
    Input input = new Input() {

        {
            /*
            // build properties
            put(GitConfig.ORIGIN, "https://github.com/jboss-openshift/openshift-quickstarts");
            put(GitConfig.REPO_NAME, "openshift-quickstarts");
            put(GitConfig.BRANCH,  "master");
            put(GitConfig.CREATE_REPO,  "true");
            put(GitConfig.OUT_DIR,  workDir.getAbsolutePath());
            put(MavenProjectConfig.PROJECT_DIR, "decisionserver/hellorules");
            */
            // provider properties
            put(KUBERNETES_MASTER.inputKey(), "https://ce-os-rhel-master.usersys.redhat.com:8443");
            put(KUBERNETES_AUTH_BASIC_USERNAME.inputKey(), "admin");
            put(KUBERNETES_AUTH_BASIC_PASSWORD.inputKey(), "admin");
            put(PROVIDER_NAME.inputKey(), pvrName);
            // runtime properties
            put(APPLICATION_NAME.inputKey(), appName);
            // put(KIE_SERVER_CONTAINER_DEPLOYMENT.inputKey(), "decisionserver-hellorules=org.openshift.quickstarts:decisionserver-hellorules:1.4.0.Final");
            put(PROJECT_NAME.inputKey(), prjName);
            put(RESOURCE_SECRETS_URI.inputKey(), getUri("bpmsuite-app-secret.json"));
            put(RESOURCE_STREAMS_URI.inputKey(), getUri("bpmsuite-image-streams.json"));
            put(RESOURCE_TEMPLATE_PARAM_VALUES.inputKey(), templateParams);
            put(RESOURCE_TEMPLATE_URI.inputKey(), getUri("bpmsuite70-execserv.json"));
            put(SERVICE_NAME.inputKey(), svcName);
        }
    };
    executor.execute(input, pipe, (Runtime b) -> System.out.println(b));
    OpenShiftRuntimeManager runtimeManager = new OpenShiftRuntimeManager(runtimeRegistry, openshiftAccessInterface);
    OpenShiftRuntime openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, null, true);
    assertEquals(OpenShiftRuntimeState.READY, openshiftRuntime.getState().getState());
    // This step would normally be done by guvnor, but since we don't have guvnor in this test, we
    // include a standalone Nexus repo in the json configuration and deploy the binary to it here.
    // new OpenShiftMavenDeployer(workDir, appName, prjName).deploy(buildRegistry);
    runtimeManager.start(openshiftRuntime);
    openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, true);
    assertEquals(OpenShiftRuntimeState.RUNNING, openshiftRuntime.getState().getState());
    RuntimeEndpoint runtimeEndpoint = openshiftRuntime.getEndpoint();
    assertTrue(runtimeEndpoint instanceof OpenShiftRuntimeEndpoint);
    OpenShiftRuntimeEndpoint openshiftRuntimeEndpoint = (OpenShiftRuntimeEndpoint) runtimeEndpoint;
    String kieServerHost = openshiftRuntimeEndpoint.getHost();
    if (OpenShiftNameService.isHostRegistered(kieServerHost)) {
        String kieServerUrl = new StringBuilder().append(openshiftRuntimeEndpoint.getProtocol()).append("://").append(kieServerHost).append("/services/rest/server").toString();
        if (checkConnection(kieServerUrl)) {
            KieServicesConfiguration kieServicesConfig = KieServicesFactory.newRestConfiguration(kieServerUrl, kieServerUser, kieServerPwd);
            KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kieServicesConfig);
            ServiceResponse<KieServerInfo> serverInfoResponse = kieServicesClient.getServerInfo();
            assertEquals(ServiceResponse.ResponseType.SUCCESS, serverInfoResponse.getType());
        }
    }
    runtimeManager.stop(openshiftRuntime);
    openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, true);
    assertEquals(OpenShiftRuntimeState.READY, openshiftRuntime.getState().getState());
    openshiftRuntimeExecExecutor.destroy(openshiftRuntime);
    openshiftRuntime = getRuntime(runtimeRegistry, runtimeManager, openshiftRuntime, false);
    assertNull(openshiftRuntime);
    openshiftAccessInterface.dispose();
}
Also used : OpenShiftRuntimeExecConfig(org.guvnor.ala.openshift.config.OpenShiftRuntimeExecConfig) ContextAwareOpenShiftRuntimeExecConfig(org.guvnor.ala.openshift.config.impl.ContextAwareOpenShiftRuntimeExecConfig) OpenShiftAccessInterface(org.guvnor.ala.openshift.access.OpenShiftAccessInterface) RuntimeEndpoint(org.guvnor.ala.runtime.RuntimeEndpoint) OpenShiftRuntimeEndpoint(org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint) KieServicesClient(org.kie.server.client.KieServicesClient) OpenShiftProviderConfig(org.guvnor.ala.openshift.config.OpenShiftProviderConfig) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Input(org.guvnor.ala.pipeline.Input) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) Runtime(org.guvnor.ala.runtime.Runtime) OpenShiftParameters(org.guvnor.ala.openshift.config.OpenShiftParameters) OpenShiftAccessInterfaceImpl(org.guvnor.ala.openshift.access.impl.OpenShiftAccessInterfaceImpl) OpenShiftRuntimeManager(org.guvnor.ala.openshift.service.OpenShiftRuntimeManager) OpenShiftRuntime(org.guvnor.ala.openshift.model.OpenShiftRuntime) KieServicesConfiguration(org.kie.server.client.KieServicesConfiguration) KieServerInfo(org.kie.server.api.model.KieServerInfo) RuntimeRegistry(org.guvnor.ala.registry.RuntimeRegistry) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) OpenShiftRuntimeEndpoint(org.guvnor.ala.openshift.model.OpenShiftRuntimeEndpoint) Pipeline(org.guvnor.ala.pipeline.Pipeline) ContextAwareOpenShiftRuntimeExecConfig(org.guvnor.ala.openshift.config.impl.ContextAwareOpenShiftRuntimeExecConfig) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) Test(org.junit.Test)

Example 4 with InMemoryRuntimeRegistry

use of org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry in project kie-wb-common by kiegroup.

the class WildflyExecutorTest method testRedeploy.

@Test
@InSequence(2)
public void testRedeploy() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
    final WildflyAccessInterface wildflyAccessInterface = new WildflyAccessInterfaceImpl();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new GitConfig() {
    }).addConfigStage("Maven Project", new MavenProjectConfig() {
    }).addConfigStage("Maven Build Config", new MavenBuildConfig() {
    }).addConfigStage("Maven Build", new MavenBuildExecConfig() {
    }).addConfigStage("Wildfly Provider Config", new WildflyProviderConfig() {
    }).addConfigStage("Wildfly Runtime Exec", new ContextAwareWildflyRuntimeExecConfig()).buildAs("my pipe");
    WildflyRuntimeExecExecutor wildflyRuntimeExecExecutor = new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface);
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry), new WildflyProviderConfigExecutor(runtimeRegistry), wildflyRuntimeExecExecutor));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop");
            put("branch", "master");
            put("origin", gitUrl);
            put("provider-name", "wildlfy-test");
            put("wildfly-user", "admin");
            put("wildfly-password", "Admin#70365");
            put("host", ip);
            put("port", "8080");
            put("management-port", "9990");
        }
    }, pipe, System.out::println);
    List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    Runtime runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    WildflyRuntime wildflyRuntime = (WildflyRuntime) runtime;
    WildflyRuntimeManager runtimeManager = new WildflyRuntimeManager(runtimeRegistry, wildflyAccessInterface);
    runtimeManager.start(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(RUNNING, wildflyRuntime.getState().getState());
    runtimeManager.stop(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(STOPPED, wildflyRuntime.getState().getState());
    wildflyRuntimeExecExecutor.destroy(wildflyRuntime);
    wildflyAccessInterface.dispose();
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigExecutor(org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) MavenBuildConfig(org.guvnor.ala.build.maven.config.MavenBuildConfig) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) MavenBuildExecConfig(org.guvnor.ala.build.maven.config.MavenBuildExecConfig) Input(org.guvnor.ala.pipeline.Input) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) Runtime(org.guvnor.ala.runtime.Runtime) MavenProjectConfig(org.guvnor.ala.build.maven.config.MavenProjectConfig) WildflyAccessInterfaceImpl(org.guvnor.ala.wildfly.access.impl.WildflyAccessInterfaceImpl) WildflyProviderConfigExecutor(org.guvnor.ala.wildfly.executor.WildflyProviderConfigExecutor) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) GitConfig(org.guvnor.ala.source.git.config.GitConfig) WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) Pipeline(org.guvnor.ala.pipeline.Pipeline) WildflyRuntimeExecExecutor(org.guvnor.ala.wildfly.executor.WildflyRuntimeExecExecutor) MavenBuildExecConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor) WildflyAccessInterface(org.guvnor.ala.wildfly.access.WildflyAccessInterface) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyRuntimeManager(org.guvnor.ala.wildfly.service.WildflyRuntimeManager) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) MavenBuildConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with InMemoryRuntimeRegistry

use of org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry in project kie-wb-common by kiegroup.

the class WildflyExecutorTest method testAPI.

@Test
@InSequence(1)
public void testAPI() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry();
    final WildflyAccessInterface wildflyAccessInterface = new WildflyAccessInterfaceImpl();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new GitConfig() {
    }).addConfigStage("Maven Project", new MavenProjectConfig() {
    }).addConfigStage("Maven Build Config", new MavenBuildConfig() {
    }).addConfigStage("Maven Build", new MavenBuildExecConfig() {
    }).addConfigStage("Wildfly Provider Config", new WildflyProviderConfig() {
    }).addConfigStage("Wildfly Runtime Exec", new ContextAwareWildflyRuntimeExecConfig()).buildAs("my pipe");
    WildflyRuntimeExecExecutor wildflyRuntimeExecExecutor = new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface);
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry), new WildflyProviderConfigExecutor(runtimeRegistry), wildflyRuntimeExecExecutor));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop");
            put("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            put("origin", gitUrl);
            put("provider-name", "wildlfy-test");
            put("wildfly-user", "admin");
            put("wildfly-password", "Admin#70365");
            put("host", ip);
            put("port", "8080");
            put("management-port", "9990");
        }
    }, pipe, System.out::println);
    List<Runtime> allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    Runtime runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    WildflyRuntime wildflyRuntime = (WildflyRuntime) runtime;
    WildflyRuntimeManager runtimeManager = new WildflyRuntimeManager(runtimeRegistry, wildflyAccessInterface);
    runtimeManager.start(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(RUNNING, wildflyRuntime.getState().getState());
    runtimeManager.stop(wildflyRuntime);
    allRuntimes = runtimeRegistry.getRuntimes(0, 10, "", true);
    assertEquals(1, allRuntimes.size());
    runtime = allRuntimes.get(0);
    assertTrue(runtime instanceof WildflyRuntime);
    wildflyRuntime = (WildflyRuntime) runtime;
    assertEquals(STOPPED, wildflyRuntime.getState().getState());
    wildflyRuntimeExecExecutor.destroy(wildflyRuntime);
    wildflyAccessInterface.dispose();
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigExecutor(org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) MavenBuildConfig(org.guvnor.ala.build.maven.config.MavenBuildConfig) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) MavenBuildExecConfig(org.guvnor.ala.build.maven.config.MavenBuildExecConfig) Input(org.guvnor.ala.pipeline.Input) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) Runtime(org.guvnor.ala.runtime.Runtime) MavenProjectConfig(org.guvnor.ala.build.maven.config.MavenProjectConfig) WildflyAccessInterfaceImpl(org.guvnor.ala.wildfly.access.impl.WildflyAccessInterfaceImpl) WildflyProviderConfigExecutor(org.guvnor.ala.wildfly.executor.WildflyProviderConfigExecutor) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) GitConfig(org.guvnor.ala.source.git.config.GitConfig) WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) Pipeline(org.guvnor.ala.pipeline.Pipeline) WildflyRuntimeExecExecutor(org.guvnor.ala.wildfly.executor.WildflyRuntimeExecExecutor) MavenBuildExecConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor) WildflyAccessInterface(org.guvnor.ala.wildfly.access.WildflyAccessInterface) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) WildflyRuntimeManager(org.guvnor.ala.wildfly.service.WildflyRuntimeManager) InMemoryRuntimeRegistry(org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry) MavenBuildConfigExecutor(org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

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 Runtime (org.guvnor.ala.runtime.Runtime)5 Test (org.junit.Test)5 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 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 MavenProjectConfig (org.guvnor.ala.build.maven.config.MavenProjectConfig)2 DockerAccessInterface (org.guvnor.ala.docker.access.DockerAccessInterface)2 DockerAccessInterfaceImpl (org.guvnor.ala.docker.access.impl.DockerAccessInterfaceImpl)2 ContextAwareDockerProvisioningConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig)2