use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class StatusUpdatesTest method createBuildResult.
private BuildResult createBuildResult() {
IndyRepositoryManagerResult repoManagerResult = new IndyRepositoryManagerResult(Collections.emptyList(), Collections.emptyList(), RandomStringUtils.randomNumeric(4));
BuildDriverResult driverResult = new BuildDriverResult() {
@Override
public String getBuildLog() {
return "";
}
@Override
public BuildStatus getBuildStatus() {
return BuildStatus.SUCCESS;
}
@Override
public Optional<String> getOutputChecksum() {
return Optional.of("3678bbe366b11f7216bd03ad33f583d9");
}
};
return new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.empty(), Optional.of(driverResult), Optional.of(repoManagerResult), Optional.empty(), Optional.empty());
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class BuildExecutionTest method testBuild.
@Test
public void testBuild() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesSuccess();
// check build statuses
checkBuildStatuses(statusChangedEvents, expectedStatuses);
// check results
BuildResult buildResult = buildExecutionResultWrapper.get();
// check results: logs
BuildDriverResult buildDriverResult = buildResult.getBuildDriverResult().get();
String buildLog = buildDriverResult.getBuildLog();
Assert.assertTrue("Invalid build log.", buildLog.contains("Finished: SUCCESS"));
// check results: artifacts
RepositoryManagerResult repositoryManagerResult = buildResult.getRepositoryManagerResult().get();
Assert.assertTrue("Missing build artifacts.", repositoryManagerResult.getBuiltArtifacts().size() > 0);
Assert.assertTrue("Missing build dependencies.", repositoryManagerResult.getDependencies().size() > 0);
Artifact artifact = repositoryManagerResult.getBuiltArtifacts().iterator().next();
Assert.assertTrue("Invalid built artifact in the result.", artifact.getIdentifier().startsWith(ArtifactBuilder.IDENTIFIER_PREFIX));
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class BuildExecutorMock method cancel.
@Override
public void cancel(String executionConfigurationId) throws ExecutorException {
BuildExecutionSession buildExecutionSession = runningExecutions.get(executionConfigurationId);
if (buildExecutionSession == null) {
log.error("Unable to cancel build {}. The build is not running.", executionConfigurationId);
return;
}
log.info("Cancelling build {}.", executionConfigurationId);
runningFutures.get(executionConfigurationId).cancel(true);
BuildDriverResult driverResult = BuildDriverResultMock.mockResult(BuildStatus.CANCELLED);
buildExecutionSession.setBuildDriverResult(driverResult);
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class BuildResultMapper method toDTO.
public BuildResultRest toDTO(BuildResult buildResult) {
CompletionStatus completionStatus = buildResult.getCompletionStatus();
ProcessException processException = buildResult.getProcessException().orElse(null);
String processLog = buildResult.getProcessLog();
BuildExecutionConfigurationRest buildExecutionConfiguration;
if (buildResult.getBuildExecutionConfiguration().isPresent()) {
BuildExecutionConfiguration bec = buildResult.getBuildExecutionConfiguration().get();
buildExecutionConfiguration = new BuildExecutionConfigurationRest(bec);
} else {
buildExecutionConfiguration = null;
}
BuildDriverResultRest buildDriverResult;
if (buildResult.getBuildDriverResult().isPresent()) {
BuildDriverResult result = buildResult.getBuildDriverResult().get();
buildDriverResult = new BuildDriverResultRest(result);
} else {
buildDriverResult = null;
}
RepositoryManagerResultRest repositoryManagerResult;
if (buildResult.getRepositoryManagerResult().isPresent()) {
RepositoryManagerResult result = buildResult.getRepositoryManagerResult().get();
repositoryManagerResult = repositoryManagerResultMapper.toDTO(result);
} else {
repositoryManagerResult = null;
}
EnvironmentDriverResult environmentDriverResult;
if (buildResult.getEnvironmentDriverResult().isPresent()) {
environmentDriverResult = buildResult.getEnvironmentDriverResult().get();
} else {
environmentDriverResult = null;
}
RepourResult repourResult = buildResult.getRepourResult().orElse(null);
return new BuildResultRest(completionStatus, processException, processLog, buildExecutionConfiguration, buildDriverResult, repositoryManagerResult, environmentDriverResult, repourResult);
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class BlockedBuildDriverMock method complete.
protected void complete(BuildExecutionSession buildExecutionSession, final RunningEnvironment runningEnvironment, Consumer<CompletedBuild> onComplete) throws InterruptedException {
log.info("Running blocked build ...");
semaphore.acquire();
setBuildStatus(TestProjectConfigurationBuilder.CANCEL);
log.info("Blocked build canceled.");
onComplete.accept(new CompletedBuild() {
@Override
public BuildDriverResult getBuildResult() throws BuildDriverException {
return getBuildResultMock(runningEnvironment);
}
@Override
public RunningEnvironment getRunningEnvironment() {
return runningEnvironment;
}
});
}
Aggregations