use of org.jboss.pnc.spi.BuildSetStatus in project pnc by project-ncl.
the class BuildCoordinationTest method buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess.
@Test
public void buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess() throws CoreException, TimeoutException, InterruptedException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.buildConfigurationWithDependencies(buildConfigurationSet);
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
// check the result
Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
assertThat(maybeSetRecord.isPresent()).isTrue();
Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
assertEmptyQueue();
}
use of org.jboss.pnc.spi.BuildSetStatus in project pnc by project-ncl.
the class BuildCoordinationTest method shouldBuildSetWithOneConfiguration.
@Test
public void shouldBuildSetWithOneConfiguration() throws CoreException, TimeoutException, InterruptedException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.build(223, "Project-223", buildConfigurationSet);
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.IMPLICIT_DEPENDENCY_CHECK);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
// check the result
Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
assertThat(maybeSetRecord.isPresent()).isTrue();
Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
assertEmptyQueue();
}
use of org.jboss.pnc.spi.BuildSetStatus in project pnc by project-ncl.
the class DefaultBuildCoordinator method updateBuildSetTaskStatus.
private void updateBuildSetTaskStatus(BuildSetTask buildSetTask, BuildSetStatus status, String description) {
log.info("Setting new status {} on buildSetTask.id {}. Description: {}.", status, buildSetTask.getId(), description);
BuildSetStatus oldStatus = buildSetTask.getStatus();
Optional<BuildConfigSetRecord> buildConfigSetRecord = buildSetTask.getBuildConfigSetRecord();
// Completed BuildSets are updated using BuildSetTask#taskStatusUpdatedToFinalState()
if (buildConfigSetRecord.isPresent() && REJECTED_STATES.containsKey(status)) {
buildConfigSetRecord.get().setStatus(REJECTED_STATES.get(status));
try {
datastoreAdapter.saveBuildConfigSetRecord(buildConfigSetRecord.get());
} catch (DatastoreException de) {
log.warn("Failed to update build config set record to REJECTED status: " + de);
}
}
buildConfigSetRecord.ifPresent(record -> sendSetStatusChangeEvent(buildSetTask, status, oldStatus, record, description));
buildSetTask.setStatus(status);
buildSetTask.setStatusDescription(description);
}
use of org.jboss.pnc.spi.BuildSetStatus in project pnc by project-ncl.
the class BuildCoordinationTest method buildConfigSetRecordShouldBeMarkedFailedOnFailure.
@Test
public void buildConfigSetRecordShouldBeMarkedFailedOnFailure() throws CoreException, TimeoutException, InterruptedException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.buildConfigurationWithDependenciesThatFail(buildConfigurationSet);
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
// check the result
Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
datastoreMock.getBuildConfigSetRecordById(buildConfigurationSet.getId());
Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
assertThat(maybeSetRecord.isPresent()).isTrue();
Assert.assertEquals(BuildStatus.FAILED, maybeSetRecord.get().getStatus());
Collection<BuildStatus> statuses = getBuildStatuses();
// dependent build failed with
Assert.assertTrue(statuses.contains(BuildStatus.REJECTED_FAILED_DEPENDENCIES));
// system error
Assert.assertFalse(statuses.contains(BuildStatus.SYSTEM_ERROR));
assertEmptyQueue();
}
use of org.jboss.pnc.spi.BuildSetStatus in project pnc by project-ncl.
the class BuildCoordinationTest method registerCallback.
private ObjectWrapper<BuildSetStatus> registerCallback(BuildConfigurationSet buildConfigurationSet) {
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = new ObjectWrapper<>();
Consumer<BuildSetStatusChangedEvent> onStatusUpdate = (statusChangedEvent) -> {
if (statusChangedEvent.getNewStatus().isCompleted()) {
lastBuildSetStatus.set(statusChangedEvent.getNewStatus());
}
};
BuildSetCallBack buildSetCallBack = new BuildSetCallBack(buildConfigurationSet.getId(), onStatusUpdate);
buildSetStatusNotifications.subscribe(buildSetCallBack);
return lastBuildSetStatus;
}
Aggregations