use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class DatastoreAdapter method initBuildRecordBuilder.
/**
* Initialize a new BuildRecord.Builder based on the data contained in the BuildTask. Note, this must be done inside
* a transaction because it fetches the BuildRecordSet entities from the database.
*
* @return The initialized build record builder
*/
private BuildRecord.Builder initBuildRecordBuilder(BuildTask buildTask) {
BuildOptions buildOptions = buildTask.getBuildOptions();
BuildRecord.Builder builder = BuildRecord.Builder.newBuilder().id(buildTask.getId()).buildConfigurationAudited(buildTask.getBuildConfigurationAudited()).user(buildTask.getUser()).submitTime(buildTask.getSubmitTime()).startTime(buildTask.getStartTime()).productMilestone(buildTask.getProductMilestone()).temporaryBuild(buildOptions.isTemporaryBuild()).alignmentPreference(buildOptions.getAlignmentPreference()).noRebuildCause(buildTask.getNoRebuildCause());
if (buildTask.getEndTime() == null) {
buildTask.setEndTime(Date.from(Instant.now()));
}
builder.endTime(buildTask.getEndTime());
if (buildTask.getBuildConfigSetRecordId() != null) {
BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecordById(buildTask.getBuildConfigSetRecordId());
builder.buildConfigSetRecord(buildConfigSetRecord);
}
List<Base32LongID> dependencies = buildTask.getDependencies().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
builder.dependencyBuildRecordIds(dependencies.toArray(new Base32LongID[dependencies.size()]));
List<Base32LongID> dependants = buildTask.getDependants().stream().map(BuildTask::getId).map(Base32LongID::new).collect(Collectors.toList());
builder.dependentBuildRecordIds(dependants.toArray(new Base32LongID[dependants.size()]));
return builder;
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class AbstractDependentBuildTest method build.
protected void build(BuildConfigurationSet configSet, RebuildMode rebuildMode) throws CoreException {
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(rebuildMode);
coordinator.build(configSet, user, buildOptions);
coordinator.start();
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class AbstractDependentBuildTest method build.
protected void build(BuildConfiguration config) {
BuildOptions buildOptions = new BuildOptions();
build(config, buildOptions);
}
use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.
the class BuildCoordinationTest method buildSetTaskCallbacksShouldBeCalled.
@Test
public void buildSetTaskCallbacksShouldBeCalled() throws DatastoreException, TimeoutException, InterruptedException, CoreException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.buildConfigurationWithDependencies(buildConfigurationSet);
Set<BuildSetStatusChangedEvent> buildSetStatusChangedEvents = new HashSet<>();
Consumer<BuildSetStatusChangedEvent> statusChangeEventConsumer = buildSetStatusChangedEvents::add;
BuildSetCallBack buildSetCallBack = new BuildSetCallBack(buildConfigurationSet.getId(), statusChangeEventConsumer);
log.info("Subscribing new listener for buildSetTask.id {}.", buildSetCallBack.getBuildSetConfigurationId());
buildSetStatusNotifications.subscribe(buildSetCallBack);
log.info("Running builds ...");
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(() -> contains(buildSetStatusChangedEvents, BuildSetStatus.NEW), 2000, ChronoUnit.MILLIS, () -> "Did not receive status update to NEW for task set. Received: " + buildSetStatusChangedEvents);
Wait.forCondition(() -> contains(buildSetStatusChangedEvents, BuildSetStatus.DONE), 2000, ChronoUnit.MILLIS, () -> "Did not receive status update to DONE for task set. Received: " + buildSetStatusChangedEvents);
assertEmptyQueue();
}
use of org.jboss.pnc.spi.BuildOptions 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();
}
Aggregations