use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.
the class WildflyRuntimeTest method waitForAppBuildTest.
@Test
public void waitForAppBuildTest() {
final Optional<Source> _source = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "master", gitUrl, "drools-workshop-build", "true"));
assertTrue(_source.isPresent());
final Source source = _source.get();
assertNotNull(source);
List<String> goals = new ArrayList<>();
goals.add("package");
Properties properties = new Properties();
properties.setProperty("failIfNoTests", "false");
final Path projectRoot = source.getPath();
final InputStream pomStream = org.uberfire.java.nio.file.Files.newInputStream(projectRoot.resolve("pom.xml"));
final MavenProject project = MavenProjectLoader.parseMavenPom(pomStream);
RepositoryVisitor repositoryVisitor = new RepositoryVisitor(projectRoot, project.getName());
final String expectedBinary = project.getArtifact().getArtifactId() + "-" + project.getArtifact().getVersion() + "." + project.getArtifact().getType();
final org.guvnor.ala.build.maven.model.MavenProject mavenProject = new MavenProjectImpl(project.getId(), project.getArtifact().getType(), project.getName(), expectedBinary, source.getPath(), source.getPath(), source.getPath().resolve("target").resolve(expectedBinary).toAbsolutePath(), repositoryVisitor.getRoot().getAbsolutePath(), null);
final File pom = new File(mavenProject.getTempDir(), "pom.xml");
MavenBuildExecutor.executeMaven(pom, properties, goals.toArray(new String[0]));
final File file = new File(repositoryVisitor.getRoot().getAbsolutePath() + "/target/" + mavenProject.getExpectedBinary());
WildflyClient wildflyClient = new WildflyClient("", "admin", "Admin#70365", ip, 8080, 9990);
wildflyClient.deploy(file);
final String id = file.getName();
WildflyAppState appState = wildflyClient.getAppState(id);
assertNotNull(appState);
assertTrue(appState.getState().equals(RUNNING));
wildflyClient.undeploy(id);
appState = wildflyClient.getAppState(id);
assertNotNull(appState);
assertTrue(appState.getState().equals(UNKNOWN));
wildflyClient.deploy(file);
appState = wildflyClient.getAppState(id);
assertNotNull(appState);
assertTrue(appState.getState().equals(RUNNING));
}
use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.
the class RestPipelineImplTest method testAPI.
@Test
public void testAPI() {
ProviderTypeList allProviderTypes = runtimeService.getProviderTypes(0, 10, "", true);
assertEquals(2, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfig() {
};
runtimeService.registerProvider(dockerProviderConfig);
ProviderList allProviders = runtimeService.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
Provider p = allProviders.getItems().get(0);
assertTrue(p instanceof DockerProvider);
// by construction.
int systemPipelines = 2;
PipelineConfigsList allPipelineConfigs = pipelineService.getPipelineConfigs(0, 10, "", true);
assertNotNull(allPipelineConfigs);
assertEquals(systemPipelines, allPipelineConfigs.getItems().size());
List<PipelineConfigStage> configs = new ArrayList<>();
configs.add(new PipelineConfigStage("GitConfig", new GitConfigImpl()));
configs.add(new PipelineConfigStage("MavenProjectConfig", new MavenProjectConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildConfig", new MavenBuildConfigImpl()));
configs.add(new PipelineConfigStage("DockerBuildConfig", new DockerBuildConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildExecConfigImpl", new MavenBuildExecConfigImpl()));
configs.add(new PipelineConfigStage("DockerProviderConfig", new DockerProviderConfigImpl()));
configs.add(new PipelineConfigStage("ContextAwareDockerProvisioningConfig", new ContextAwareDockerProvisioningConfig()));
configs.add(new PipelineConfigStage("ContextAwareDockerRuntimeExecConfig", new ContextAwareDockerRuntimeExecConfig()));
pipelineService.newPipeline(new PipelineConfigImpl("mypipe", configs));
pipelineService.newPipeline(new PipelineConfigImpl("wildlfyPipe", configs), WildflyProviderType.instance());
pipelineService.newPipeline(new PipelineConfigImpl("dockerPipe", configs), DockerProviderType.instance());
allPipelineConfigs = pipelineService.getPipelineConfigs(0, 10, "", true);
int createdPipelines = 3;
int totalPipelines = systemPipelines + createdPipelines;
assertEquals(totalPipelines, allPipelineConfigs.getItems().size());
PipelineConfigsList wildflyConfigs = pipelineService.getPipelineConfigs(WildflyProviderType.instance().getProviderTypeName(), WildflyProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(2, wildflyConfigs.getItems().size());
List<String> wildflyPipelineNames = pipelineService.getPipelineNames(WildflyProviderType.instance().getProviderTypeName(), WildflyProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(2, wildflyPipelineNames.size());
assertTrue(wildflyPipelineNames.contains("wildlfyPipe"));
assertTrue(wildflyPipelineNames.contains(SYSTEM_PIPELINE1));
PipelineConfigsList dockerConfigs = pipelineService.getPipelineConfigs(DockerProviderType.instance().getProviderTypeName(), DockerProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(1, dockerConfigs.getItems().size());
List<String> dockerPipelineNames = pipelineService.getPipelineNames(DockerProviderType.instance().getProviderTypeName(), DockerProviderType.instance().getVersion(), 0, 10, "", true);
assertEquals(1, dockerPipelineNames.size());
assertTrue(dockerPipelineNames.contains("dockerPipe"));
Input input = new Input();
input.put("provider-name", "local");
input.put("repo-name", "drools-workshop");
input.put("create-repo", "true");
input.put("branch", "master");
input.put("out-dir", tempPath.getAbsolutePath());
input.put("origin", gitUrl);
String pipelineExecutionId = pipelineService.runPipeline("mypipe", input, false);
RuntimeQueryResultItemList itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertEquals(pipelineExecutionId, itemList.getItems().get(0).getPipelineExecutionId());
pipelineService.deletePipelineExecution(pipelineExecutionId);
itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertNull(itemList.getItems().get(0).getPipelineExecutionId());
RuntimeList allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
runtimeService.destroyRuntime(allRuntimes.getItems().get(0).getId(), true);
allRuntimes = runtimeService.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
assertEquals(18, // 8 Stages x 2 + 2 pipeline events
listener.getEvents().size());
pipelineExecutionId = pipelineService.runPipeline("mypipe", input, true);
pipelineService.stopPipelineExecution(pipelineExecutionId);
itemList = runtimeService.executeQuery(RuntimeQueryBuilder.newInstance().withPipelineExecutionId(pipelineExecutionId).build());
assertEquals(1, itemList.getItems().size());
assertEquals(pipelineExecutionId, itemList.getItems().get(0).getPipelineExecutionId());
assertEquals(PipelineExecutorTask.Status.STOPPED.name(), itemList.getItems().get(0).getPipelineStatus());
}
use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.
the class MavenCliOutputTest method buildAppAndWaitForMavenOutputTest.
@Test
public void buildAppAndWaitForMavenOutputTest() throws IOException {
final Optional<Source> _source = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "master", gitUrl, "drools-workshop", "true"));
assertTrue(_source.isPresent());
final Source source = _source.get();
boolean buildProcessReady = false;
Throwable error = null;
PipedOutputStream baosOut = new PipedOutputStream();
PipedOutputStream baosErr = new PipedOutputStream();
final PrintStream out = new PrintStream(baosOut, true);
final PrintStream err = new PrintStream(baosErr, true);
// Build the project in a different thread
new Thread(() -> {
buildMavenProject(source, out, err);
}).start();
// Use the PipeOutputStream to read the execution output and validate that the application was built.
StringBuilder sb = new StringBuilder();
BufferedReader bufferedReader;
bufferedReader = new BufferedReader(new InputStreamReader(new PipedInputStream(baosOut)));
String line;
while (!(buildProcessReady || error != null)) {
if ((line = bufferedReader.readLine()) != null) {
sb.append(line).append("\n");
if (line.contains("Building war:")) {
buildProcessReady = true;
out.close();
err.close();
baosOut.close();
baosErr.close();
}
}
}
assertTrue(sb.toString().contains("Building war:"));
assertTrue(buildProcessReady);
assertTrue(error == null);
}
use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.
the class CloneTestJUnitTest method hello.
@Test
public void hello() throws Exception {
final String repoName = "drools-workshop-build";
final Optional<Source> source = new GitConfigExecutor(new InMemorySourceRegistry()).apply(new GitConfigImpl(tempPath.getAbsolutePath(), "main", gitUrl, repoName, "true"));
assertTrue(source.isPresent());
final String targetRepoDir = tempPath.getAbsolutePath() + "/" + repoName + ".git";
Git git = Git.open(new File(targetRepoDir));
assertNotNull(git.getRepository().exactRef(Constants.HEAD));
}
use of org.guvnor.ala.source.git.config.impl.GitConfigImpl in project kie-wb-common by kiegroup.
the class PipelineEndpointsTestIT method checkService.
@Ignore
public void checkService() {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(APP_URL);
ResteasyWebTarget restEasyTarget = (ResteasyWebTarget) target;
PipelineService proxyPipeline = restEasyTarget.proxy(PipelineService.class);
RuntimeProvisioningService proxyRuntime = restEasyTarget.proxy(RuntimeProvisioningService.class);
ProviderTypeList allProviderTypes = proxyRuntime.getProviderTypes(0, 10, "", true);
assertNotNull(allProviderTypes);
assertEquals(3, allProviderTypes.getItems().size());
DockerProviderConfig dockerProviderConfig = new DockerProviderConfigImpl();
proxyRuntime.registerProvider(dockerProviderConfig);
ProviderList allProviders = proxyRuntime.getProviders(0, 10, "", true);
assertEquals(1, allProviders.getItems().size());
assertTrue(allProviders.getItems().get(0) instanceof DockerProvider);
PipelineConfigsList allPipelines = proxyPipeline.getPipelineConfigs(0, 10, "", true);
assertNotNull(allPipelines);
assertEquals(0, allPipelines.getItems().size());
List<PipelineConfigStage> configs = new ArrayList<>();
configs.add(new PipelineConfigStage("GitConfig", new GitConfigImpl()));
configs.add(new PipelineConfigStage("MavenProjectConfig", new MavenProjectConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildConfig", new MavenBuildConfigImpl()));
configs.add(new PipelineConfigStage("DockerBuildConfig", new DockerBuildConfigImpl()));
configs.add(new PipelineConfigStage("MavenBuildExecConfig", new MavenBuildExecConfigImpl()));
configs.add(new PipelineConfigStage("DockerProviderConfig", new DockerProviderConfigImpl()));
configs.add(new PipelineConfigStage("ContextAwareDockerProvisioning", new ContextAwareDockerProvisioningConfig()));
configs.add(new PipelineConfigStage("ContextAwareDockerRuntimeExec", new ContextAwareDockerRuntimeExecConfig()));
String newPipeline = proxyPipeline.newPipeline(new PipelineConfigImpl("mypipe", configs));
Input input = new Input();
input.put("repo-name", "drools-workshop");
input.put("create-repo", "true");
input.put("branch", "master");
input.put("out-dir", tempPath.getAbsolutePath());
input.put("origin", gitUrl);
proxyPipeline.runPipeline("mypipe", input, false);
RuntimeList allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(1, allRuntimes.getItems().size());
proxyRuntime.destroyRuntime(allRuntimes.getItems().get(0).getId(), true);
allRuntimes = proxyRuntime.getRuntimes(0, 10, "", true);
assertEquals(0, allRuntimes.getItems().size());
}
Aggregations