use of org.jboss.pnc.enums.BuildExecutionStatus in project pnc by project-ncl.
the class BuildExecutorMock method startBuilding.
// @Deprecated //CDI workaround
// public BuildExecutorMock() {
// }
//
// @Inject
// public BuildExecutorMock(RepositoryManagerFactory repositoryManagerFactory, BuildDriverFactory
// buildDriverFactory, EnvironmentDriverFactory environmentDriverFactory, Configuration configuration) {
//
// }
@Override
public BuildExecutionSession startBuilding(BuildExecutionConfiguration buildExecutionConfiguration, Consumer<BuildExecutionStatusChangedEvent> onBuildExecutionStatusChangedEvent, String accessToken) throws ExecutorException {
log.info("Starting mock build execution for buildExecutionConfiguration.id {}", buildExecutionConfiguration.getId());
BuildExecutionSession buildExecutionSession = new BuildExecutionSessionMock(buildExecutionConfiguration, onBuildExecutionStatusChangedEvent);
buildExecutionSession.setStatus(BuildExecutionStatus.NEW);
runningExecutions.put(buildExecutionConfiguration.getId(), buildExecutionSession);
Consumer<BuildExecutionStatus> onCompleteInternal = (buildStatus) -> {
log.debug("Removing buildExecutionConfiguration.id [" + buildExecutionConfiguration.getId() + "] form list of running tasks.");
runningExecutions.remove(buildExecutionConfiguration.getId());
buildExecutionSession.setStatus(buildStatus);
};
CompletableFuture<Integer> future = CompletableFuture.supplyAsync(() -> mockBuild(buildExecutionSession), executor).handleAsync((buildPassed, e) -> complete(buildPassed, e, onCompleteInternal), executor);
runningFutures.put(buildExecutionConfiguration.getId(), future);
return buildExecutionSession;
}
use of org.jboss.pnc.enums.BuildExecutionStatus in project pnc by project-ncl.
the class EarlyCancellationTest method testBuild.
private void testBuild(BuildExecutionStatus cancelAfter, BuildExecutionStatus[] expectedStatuses, BuildExecutionStatus[] unexpectedStatuses) 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 (cancelAfter.equals(e.getNewStatus())) {
try {
log.info("Cancelling build ...");
executor.cancel("1");
} catch (ExecutorException e0) {
e0.printStackTrace();
}
}
};
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, cancel, executor);
// check build statuses
checkBuildStatuses(statusChangedEvents, Arrays.asList(expectedStatuses));
buildStatusesShouldNotContain(statusChangedEvents, Arrays.asList(unexpectedStatuses));
}
use of org.jboss.pnc.enums.BuildExecutionStatus in project pnc by project-ncl.
the class EarlyCancellationTest method cancelAfterEnvSetUp.
@Test(timeout = 3000)
public void cancelAfterEnvSetUp() throws InterruptedException, TimeoutException, ExecutorException, BuildDriverException {
BuildExecutionStatus cancelAfter = BuildExecutionStatus.BUILD_ENV_SETUP_COMPLETE_SUCCESS;
BuildExecutionStatus[] expectedStatuses = { BuildExecutionStatus.NEW, BuildExecutionStatus.REPO_SETTING_UP, BuildExecutionStatus.BUILD_ENV_SETTING_UP, BuildExecutionStatus.BUILD_ENV_WAITING, BuildExecutionStatus.BUILD_ENV_SETUP_COMPLETE_SUCCESS, BuildExecutionStatus.BUILD_ENV_DESTROYING, BuildExecutionStatus.BUILD_ENV_DESTROYED, BuildExecutionStatus.FINALIZING_EXECUTION, BuildExecutionStatus.CANCELLED };
BuildExecutionStatus[] unexpectedStatuses = { BuildExecutionStatus.BUILD_SETTING_UP, BuildExecutionStatus.BUILD_WAITING, BuildExecutionStatus.COLLECTING_RESULTS_FROM_BUILD_DRIVER, BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER, BuildExecutionStatus.DONE, BuildExecutionStatus.DONE_WITH_ERRORS };
try {
testBuild(cancelAfter, expectedStatuses, unexpectedStatuses);
} catch (ConfigurationParseException e) {
log.error(e.toString());
}
}
Aggregations