Search in sources :

Example 1 with DockerRuntimeManager

use of org.guvnor.ala.docker.service.DockerRuntimeManager 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 DockerRuntimeManager

use of org.guvnor.ala.docker.service.DockerRuntimeManager 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)

Aggregations

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 ContextAwareDockerRuntimeExecConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig)2 DockerRuntime (org.guvnor.ala.docker.model.DockerRuntime)2 DockerRuntimeManager (org.guvnor.ala.docker.service.DockerRuntimeManager)2 Input (org.guvnor.ala.pipeline.Input)2 Pipeline (org.guvnor.ala.pipeline.Pipeline)2 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)2 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)2 Runtime (org.guvnor.ala.runtime.Runtime)2 Test (org.junit.Test)2 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)1 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)1 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)1 MavenBuildConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor)1 MavenBuildExecConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor)1 MavenProjectConfigExecutor (org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor)1 DockerProviderConfig (org.guvnor.ala.docker.config.DockerProviderConfig)1 DockerBuildConfigImpl (org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl)1