Search in sources :

Example 6 with GitConfigImpl

use of org.guvnor.ala.source.git.config.impl.GitConfigImpl 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 7 with GitConfigImpl

use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.

the class RepositoryVisitorTest method repositoryVisitorDiffDeletedTest.

@Test
public void repositoryVisitorDiffDeletedTest() throws IOException {
    final IOServiceNio2WrapperImpl ioService = new IOServiceNio2WrapperImpl();
    final Optional<Source> sourceOptional = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "master", gitUrl, "users-new", "true"));
    assertTrue(sourceOptional.isPresent());
    final Source source = sourceOptional.get();
    final InputStream pomStream = org.uberfire.java.nio.file.Files.newInputStream(source.getPath().resolve("pom.xml"));
    final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
    RepositoryVisitor repositoryVisitor = new RepositoryVisitor(source.getPath(), project.getName());
    System.out.println("Root: " + repositoryVisitor.getRoot().getAbsolutePath());
    Map<String, String> identityHash = repositoryVisitor.getIdentityHash();
    final URI originRepo = URI.create("git://users-new");
    final FileSystem fs = FileSystems.getFileSystem(originRepo);
    ioService.startBatch(fs);
    ioService.write(fs.getPath("/file.txt"), "temp");
    ioService.write(fs.getPath("/pom.xml"), "hi there" + UUID.randomUUID().toString());
    ioService.endBatch();
    ioService.delete(source.getPath().resolve("demo.iml"));
    RepositoryVisitor newRepositoryVisitor = new RepositoryVisitor(source.getPath(), repositoryVisitor.getRoot().getAbsolutePath().trim(), false);
    System.out.println("Root: " + newRepositoryVisitor.getRoot().getAbsolutePath());
    Map<String, String> newIdentityHash = newRepositoryVisitor.getIdentityHash();
    MapDifference<String, String> difference = Maps.difference(identityHash, newIdentityHash);
    Map<String, MapDifference.ValueDifference<String>> entriesDiffering = difference.entriesDiffering();
    System.out.println(" Size of Differences: " + entriesDiffering.size());
    for (String key : entriesDiffering.keySet()) {
        System.out.println("Different Value: " + key);
    }
    assertEquals(1, entriesDiffering.size());
    assertNotNull(entriesDiffering.get("/pom.xml"));
    Map<String, String> deletedFiles = difference.entriesOnlyOnLeft();
    System.out.println(" Size of Deleted Files: " + deletedFiles.size());
    for (String key : deletedFiles.keySet()) {
        System.out.println("Deleted File: " + key);
    }
    assertEquals(1, deletedFiles.size());
    assertNotNull(deletedFiles.get("/demo.iml"));
    Map<String, String> addedFiles = difference.entriesOnlyOnRight();
    System.out.println(" Size of added Files: " + addedFiles.size());
    for (String key : addedFiles.keySet()) {
        System.out.println("Added File: " + key);
    }
    assertEquals(1, addedFiles.size());
    assertNotNull(addedFiles.get("/file.txt"));
}
Also used : GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) InputStream(java.io.InputStream) RepositoryVisitor(org.guvnor.ala.build.maven.util.RepositoryVisitor) URI(java.net.URI) Source(org.guvnor.ala.source.Source) GitConfigExecutor(org.guvnor.ala.source.git.executor.GitConfigExecutor) InMemorySourceRegistry(org.guvnor.ala.registry.inmemory.InMemorySourceRegistry) MavenProject(org.apache.maven.project.MavenProject) IOServiceNio2WrapperImpl(org.uberfire.io.impl.IOServiceNio2WrapperImpl) FileSystem(org.uberfire.java.nio.file.FileSystem) Test(org.junit.Test)

Example 8 with GitConfigImpl

use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.

the class MockSystemPipelines method createDummyPipeline.

private Pipeline createDummyPipeline(String pipelineName) {
    final GitConfig gitConfig = new GitConfigImpl();
    final Pipeline pipeline = PipelineFactory.newBuilder().addConfigStage("GigConfig", gitConfig).buildAs(pipelineName);
    return pipeline;
}
Also used : GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) GitConfig(org.guvnor.ala.source.git.config.GitConfig) Pipeline(org.guvnor.ala.pipeline.Pipeline)

Example 9 with GitConfigImpl

use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.

the class RestPipelineEventsTest method testEventsPropagation.

@Test
public void testEventsPropagation() {
    List<PipelineConfigStage> configs = new ArrayList<>();
    configs.add(new PipelineConfigStage("GitConfig", new GitConfigImpl()));
    configs.add(new PipelineConfigStage("MavenProjectConfig", new MavenProjectConfigImpl()));
    pipelineService.newPipeline(new PipelineConfigImpl("mypipe", configs));
    Input input = new Input();
    input.put("repo-name", "drools-workshop-events");
    input.put("create-repo", "true");
    input.put("branch", "master");
    input.put("out-dir", tempPath.getAbsolutePath());
    input.put("origin", gitUrl);
    pipelineService.runPipeline("mypipe", input, false);
    assertEquals(6, listener.getEvents().size());
    assertTrue(listener.getEvents().get(0) instanceof BeforePipelineExecutionEvent);
    assertTrue(listener.getEvents().get(1) instanceof BeforeStageExecutionEvent);
    assertTrue(listener.getEvents().get(2) instanceof AfterStageExecutionEvent);
    assertTrue(listener.getEvents().get(3) instanceof BeforeStageExecutionEvent);
    assertTrue(listener.getEvents().get(4) instanceof AfterStageExecutionEvent);
    assertTrue(listener.getEvents().get(5) instanceof AfterPipelineExecutionEvent);
}
Also used : BeforePipelineExecutionEvent(org.guvnor.ala.pipeline.events.BeforePipelineExecutionEvent) Input(org.guvnor.ala.pipeline.Input) AfterStageExecutionEvent(org.guvnor.ala.pipeline.events.AfterStageExecutionEvent) PipelineConfigStage(org.guvnor.ala.pipeline.PipelineConfigStage) MavenProjectConfigImpl(org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl) BeforeStageExecutionEvent(org.guvnor.ala.pipeline.events.BeforeStageExecutionEvent) GitConfigImpl(org.guvnor.ala.source.git.config.impl.GitConfigImpl) ArrayList(java.util.ArrayList) AfterPipelineExecutionEvent(org.guvnor.ala.pipeline.events.AfterPipelineExecutionEvent) PipelineConfigImpl(org.guvnor.ala.pipeline.impl.PipelineConfigImpl) Test(org.junit.Test)

Aggregations

GitConfigImpl (org.guvnor.ala.source.git.config.impl.GitConfigImpl)9 Test (org.junit.Test)7 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)5 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)5 ArrayList (java.util.ArrayList)4 MavenProjectConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenProjectConfigImpl)4 Input (org.guvnor.ala.pipeline.Input)4 MavenBuildConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildConfigImpl)3 MavenBuildExecConfigImpl (org.guvnor.ala.build.maven.config.impl.MavenBuildExecConfigImpl)3 ContextAwareDockerProvisioningConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerProvisioningConfig)3 ContextAwareDockerRuntimeExecConfig (org.guvnor.ala.docker.config.impl.ContextAwareDockerRuntimeExecConfig)3 DockerBuildConfigImpl (org.guvnor.ala.docker.config.impl.DockerBuildConfigImpl)3 DockerProviderConfigImpl (org.guvnor.ala.docker.config.impl.DockerProviderConfigImpl)3 PipelineConfigStage (org.guvnor.ala.pipeline.PipelineConfigStage)3 PipelineConfigImpl (org.guvnor.ala.pipeline.impl.PipelineConfigImpl)3 Source (org.guvnor.ala.source.Source)3 File (java.io.File)2 InputStream (java.io.InputStream)2 MavenProject (org.apache.maven.project.MavenProject)2 RepositoryVisitor (org.guvnor.ala.build.maven.util.RepositoryVisitor)2