use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method mockBuildResult.
private BuildResult mockBuildResult(boolean withSshCredentials) {
BuildResult result = mock(BuildResult.class);
BuildDriverResult driverResult = mock(BuildDriverResult.class);
when(driverResult.getBuildStatus()).thenReturn(BuildStatus.FAILED);
when(result.getBuildDriverResult()).thenReturn(Optional.of(driverResult));
RepositoryManagerResult repoManagerResult = mock(RepositoryManagerResult.class);
when(repoManagerResult.getCompletionStatus()).thenReturn(CompletionStatus.SUCCESS);
when(result.getRepositoryManagerResult()).thenReturn(Optional.of(repoManagerResult));
when(result.getBuildExecutionConfiguration()).thenReturn(Optional.of(mock(BuildExecutionConfiguration.class)));
return result;
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class AbstractDependentBuildTest method buildDriverResult.
private static BuildDriverResult buildDriverResult() {
BuildDriverResult mock = mock(BuildDriverResult.class);
when(mock.getBuildStatus()).thenReturn(BuildStatus.SUCCESS);
return mock;
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class DefaultBuildExecutor method retrieveBuildDriverResults.
private Void retrieveBuildDriverResults(BuildExecutionSession buildExecutionSession, CompletedBuild completedBuild) {
if (completedBuild == null) {
userLog.warn("Unable to retrieve build driver results. Most likely due to cancelled operation.");
return null;
}
try {
buildExecutionSession.setStatus(BuildExecutionStatus.COLLECTING_RESULTS_FROM_BUILD_DRIVER);
BuildDriverResult buildResult = completedBuild.getBuildResult();
BuildStatus buildStatus = buildResult.getBuildStatus();
buildExecutionSession.setBuildDriverResult(buildResult);
if (buildStatus.completedSuccessfully()) {
userLog.info("Build successfully completed.");
buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_COMPLETED_SUCCESS);
} else if (buildStatus.equals(BuildStatus.CANCELLED)) {
userLog.info("Build has been canceled.");
buildExecutionSession.setStatus(BuildExecutionStatus.CANCELLED);
} else {
userLog.warn("Build completed with errors.");
buildExecutionSession.setStatus(BuildExecutionStatus.BUILD_COMPLETED_WITH_ERROR);
}
return null;
} catch (Throwable e) {
throw new BuildProcessException(e, completedBuild.getRunningEnvironment());
}
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class BuildExecutionCancellationTest method testBuild.
@Test(timeout = 3000)
public void testBuild() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException, ConfigurationParseException {
BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
DefaultBuildExecutor executor = new DefaultBuildExecutor(repositoryManagerFactory, buildDriverFactory, environmentDriverFactory, new Configuration(), null);
Consumer<BuildExecutionStatusChangedEvent> cancel = (e) -> {
if (BuildExecutionStatus.BUILD_WAITING.equals(e.getNewStatus())) {
try {
log.info("Cancelling build ...");
Thread.sleep(100);
executor.cancel(e.getBuildTaskId());
} catch (ExecutorException | InterruptedException e0) {
e0.printStackTrace();
}
}
};
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, cancel, executor);
List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesBase();
expectedStatuses.add(BuildExecutionStatus.CANCELLED);
// check build statuses
checkBuildStatuses(statusChangedEvents, expectedStatuses);
// check results
BuildResult buildResult = buildExecutionResultWrapper.get();
BuildDriverResult buildDriverResult = buildResult.getBuildDriverResult().get();
Assert.assertEquals(BuildStatus.CANCELLED, buildDriverResult.getBuildStatus());
}
use of org.jboss.pnc.spi.builddriver.BuildDriverResult in project pnc by project-ncl.
the class DatastoreAdapterTest method storeResult.
private void storeResult(DatastoreAdapter datastoreAdapter, BuildStatus buildStatus, CompletionStatus completionStatus) throws DatastoreException {
BuildDriverResult buildDriverResult = mock(BuildDriverResult.class);
when(buildDriverResult.getBuildStatus()).thenReturn(buildStatus);
when(buildDriverResult.getBuildLog()).thenReturn(BUILD_LOG);
RepositoryManagerResult repositoryManagerResult = mock(RepositoryManagerResult.class);
when(repositoryManagerResult.getCompletionStatus()).thenReturn(completionStatus);
when(repositoryManagerResult.getLog()).thenReturn(REPOSITORY_MANAGER_LOG);
BuildExecutionConfiguration buildExecutionConfiguration = mock(BuildExecutionConfiguration.class);
BuildResult buildResult = new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.of(buildExecutionConfiguration), Optional.of(buildDriverResult), Optional.of(repositoryManagerResult), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(RepourResultMock.mock()));
BuildTask buildTask = mockBuildTask();
datastoreAdapter.storeResult(buildTask, buildResult);
}
Aggregations