use of org.jboss.pnc.enums.BuildExecutionStatus in project pnc by project-ncl.
the class BuildExecutionBase method buildStatusesShouldNotContain.
protected void buildStatusesShouldNotContain(Set<BuildExecutionStatusChangedEvent> statusChangedEvents, List<BuildExecutionStatus> unexpectedStatuses) {
List<BuildExecutionStatus> statusReceived = statusChangedEvents.stream().map(BuildExecutionStatusChangedEvent::getNewStatus).collect(Collectors.toList());
for (BuildExecutionStatusChangedEvent statusChangedEvent : statusChangedEvents) {
BuildExecutionStatus status = statusChangedEvent.getNewStatus();
if (unexpectedStatuses.contains(status)) {
log.info("Received statuses: {}", statusReceived);
Assert.fail("Unexpected status [" + status + "] has been received.");
}
}
}
use of org.jboss.pnc.enums.BuildExecutionStatus 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.enums.BuildExecutionStatus in project pnc by project-ncl.
the class BuildExecutionTest method buildShouldFail.
@Test
public void buildShouldFail() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
BuildConfiguration buildConfiguration = configurationBuilder.buildFailingConfiguration(2, "failed-build", null);
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesBase();
expectedStatuses.add(DONE_WITH_ERRORS);
// check build statuses
checkBuildStatuses(statusChangedEvents, expectedStatuses);
}
use of org.jboss.pnc.enums.BuildExecutionStatus 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.enums.BuildExecutionStatus in project pnc by project-ncl.
the class EarlyCancellationTest method cancelImmediately.
@Test(timeout = 3000)
public void cancelImmediately() throws InterruptedException, TimeoutException, ExecutorException, BuildDriverException {
BuildExecutionStatus cancelAfter = BuildExecutionStatus.NEW;
BuildExecutionStatus[] expectedStatuses = { BuildExecutionStatus.NEW, BuildExecutionStatus.FINALIZING_EXECUTION, BuildExecutionStatus.CANCELLED };
BuildExecutionStatus[] unexpectedStatuses = { BuildExecutionStatus.BUILD_ENV_SETTING_UP, BuildExecutionStatus.BUILD_ENV_WAITING, BuildExecutionStatus.BUILD_ENV_SETUP_COMPLETE_SUCCESS, BuildExecutionStatus.REPO_SETTING_UP, BuildExecutionStatus.BUILD_SETTING_UP, BuildExecutionStatus.BUILD_WAITING, BuildExecutionStatus.COLLECTING_RESULTS_FROM_BUILD_DRIVER, BuildExecutionStatus.COLLECTING_RESULTS_FROM_REPOSITORY_MANAGER, BuildExecutionStatus.BUILD_ENV_DESTROYING, BuildExecutionStatus.BUILD_ENV_DESTROYED, BuildExecutionStatus.DONE, BuildExecutionStatus.DONE_WITH_ERRORS };
try {
testBuild(cancelAfter, expectedStatuses, unexpectedStatuses);
} catch (ConfigurationParseException e) {
log.error(e.toString());
}
}
Aggregations