Search in sources :

Example 1 with PipelineExecutor

use of org.guvnor.ala.pipeline.execution.PipelineExecutor in project kie-wb-common by kiegroup.

the class MavenDependencyConfigExecutorTest method testMavenDependencyAPI.

@Test
public void testMavenDependencyAPI() throws Exception {
    final String groupId = "org.guvnor.ala";
    final String artifactId = "maven-ala-artifact-test";
    final String version = "1";
    final String artifactPath = "/org/guvnor/ala/maven-ala-artifact-test/1/maven-ala-artifact-test-1.pom";
    final String oldSettingsXmlPath = System.getProperty(CUSTOM_SETTINGS_PROPERTY);
    try {
        final Path settingsXmlPath = generateSettingsXml();
        System.setProperty(CUSTOM_SETTINGS_PROPERTY, settingsXmlPath.toString());
        MavenSettings.reinitSettings();
        installArtifactLocally(groupId, artifactId, version);
        final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
        final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Maven Artifact", new MavenDependencyConfigImpl()).buildAs("my pipe");
        final PipelineExecutor executor = new PipelineExecutor(singletonList(new MavenDependencyConfigExecutor(buildRegistry)));
        executor.execute(new Input() {

            {
                put("artifact", groupId + ":" + artifactId + ":pom:" + version);
            }
        }, pipe, System.out::println);
        final List<Binary> allBinaries = buildRegistry.getAllBinaries();
        assertNotNull(allBinaries);
        assertEquals(1, allBinaries.size());
        assertTrue(allBinaries.get(0) instanceof MavenBinary);
        final MavenBinary binary = (MavenBinary) allBinaries.get(0);
        assertEquals("Maven", binary.getType());
        assertEquals(artifactId, binary.getName());
        assertEquals(groupId, binary.getGroupId());
        assertEquals(artifactId, binary.getArtifactId());
        assertEquals(version, binary.getVersion());
        assertEquals(Paths.get(m2Folder.getPath(), artifactPath).toString(), binary.getPath().toString());
    } finally {
        if (oldSettingsXmlPath == null) {
            System.clearProperty(CUSTOM_SETTINGS_PROPERTY);
        } else {
            System.setProperty(CUSTOM_SETTINGS_PROPERTY, oldSettingsXmlPath);
        }
        MavenSettings.reinitSettings();
    }
}
Also used : Path(java.nio.file.Path) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenDependencyConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenDependencyConfigImpl) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Input(org.guvnor.ala.pipeline.Input) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Example 2 with PipelineExecutor

use of org.guvnor.ala.pipeline.execution.PipelineExecutor in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutorTest method testAPI.

@Test
public void testAPI() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new MyGitConfig()).addConfigStage("Maven Project", new MavenProjectConfigImpl()).addConfigStage("Maven Build Config", new MavenBuildConfigImpl()).addConfigStage("Maven Build", new MavenBuildExecConfigImpl()).buildAs("my pipe");
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry)));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop-pipe");
            put("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            put("origin", gitUrl);
        }
    }, pipe, System.out::println);
    List<Repository> allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    Repository repo = allRepositories.get(0);
    List<Project> allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(1, allProjects.size());
    List<Binary> allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(0));
    final String tempDir = sourceRegistry.getAllProjects(repo).get(0).getTempDir();
    executor.execute(new Input() {

        {
            put("project-temp-dir", tempDir);
            put("repo-name", "drools-workshop-pipe");
            put("branch", "master");
        }
    }, pipe, System.out::println);
    allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    repo = allRepositories.get(0);
    allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(2, allProjects.size());
    allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(1));
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Project(org.guvnor.ala.build.Project) MavenProject(org.apache.maven.project.MavenProject) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) Input(org.guvnor.ala.pipeline.Input) Repository(org.guvnor.ala.source.Repository) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Example 3 with PipelineExecutor

use of org.guvnor.ala.pipeline.execution.PipelineExecutor in project kie-wb-common by kiegroup.

the class MavenProjectConfigExecutorTest method testReuseTmpDirectoryAPI.

@Test
public void testReuseTmpDirectoryAPI() {
    final SourceRegistry sourceRegistry = new InMemorySourceRegistry();
    final BuildRegistry buildRegistry = new InMemoryBuildRegistry();
    final Pipeline pipe = PipelineFactory.newBuilder().addConfigStage("Git Source", new MyGitConfig()).addConfigStage("Maven Project", new MavenProjectConfigImpl()).addConfigStage("Maven Build Config", new MavenBuildConfigImpl()).addConfigStage("Maven Build", new MavenBuildExecConfigImpl()).buildAs("my pipe");
    final PipelineExecutor executor = new PipelineExecutor(asList(new GitConfigExecutor(sourceRegistry), new MavenProjectConfigExecutor(sourceRegistry), new MavenBuildConfigExecutor(), new MavenBuildExecConfigExecutor(buildRegistry)));
    executor.execute(new Input() {

        {
            put("repo-name", "drools-workshop-pipe2");
            put("create-repo", "true");
            put("branch", "master");
            put("out-dir", tempPath.getAbsolutePath());
            put("origin", gitUrl);
        }
    }, pipe, System.out::println);
    List<Repository> allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    Repository repo = allRepositories.get(0);
    List<Project> allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(1, allProjects.size());
    List<Binary> allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(0));
    final String tempDir = sourceRegistry.getAllProjects(repo).get(0).getTempDir();
    executor.execute(new Input() {

        {
            put("project-temp-dir", tempDir);
            put("repo-name", "drools-workshop-pipe2");
            put("branch", "master");
        }
    }, pipe, System.out::println);
    allRepositories = sourceRegistry.getAllRepositories();
    assertEquals(1, allRepositories.size());
    repo = allRepositories.get(0);
    allProjects = sourceRegistry.getAllProjects(repo);
    assertEquals(2, allProjects.size());
    allBinaries = buildRegistry.getAllBinaries();
    assertEquals(1, allBinaries.size());
    assertMavenBinary(allBinaries.get(0), allProjects.get(1));
}
Also used : InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) SourceRegistry(org.guvnor.ala.registry.SourceRegistry) PipelineExecutor(org.guvnor.ala.pipeline.execution.PipelineExecutor) Pipeline(org.guvnor.ala.pipeline.Pipeline) Project(org.guvnor.ala.build.Project) MavenProject(org.apache.maven.project.MavenProject) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) Input(org.guvnor.ala.pipeline.Input) Repository(org.guvnor.ala.source.Repository) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenBuildExecConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl) BuildRegistry(org.guvnor.ala.registry.BuildRegistry) InMemoryBuildRegistry(org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry) MavenBuildConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl) Binary(org.guvnor.ala.build.Binary) MavenBinary(org.guvnor.ala.build.maven.model.MavenBinary) Test(org.junit.Test)

Example 4 with PipelineExecutor

use of org.guvnor.ala.pipeline.execution.PipelineExecutor 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 5 with PipelineExecutor

use of org.guvnor.ala.pipeline.execution.PipelineExecutor 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

Input (org.guvnor.ala.pipeline.Input)8 Pipeline (org.guvnor.ala.pipeline.Pipeline)8 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)8 Test (org.junit.Test)8 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)6 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)6 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)5 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)5 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)5 Runtime (org.guvnor.ala.runtime.Runtime)5 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)5 Binary (org.guvnor.ala.build.Binary)3 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)3 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)3 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)3 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 MavenBinary (org.guvnor.ala.build.maven.model.MavenBinary)3 MavenProject (org.apache.maven.project.MavenProject)2