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();
}
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"));
}
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;
}
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);
}
Aggregations