Search in sources :

Example 31 with BuildOptions

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;
}
Also used : Base32LongID(org.jboss.pnc.model.Base32LongID) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildRecord(org.jboss.pnc.model.BuildRecord) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord)

Example 32 with BuildOptions

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();
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions)

Example 33 with BuildOptions

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);
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions)

Example 34 with 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();
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetCallBack(org.jboss.pnc.coordinator.notifications.buildSetTask.BuildSetCallBack) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 35 with BuildOptions

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();
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatus(org.jboss.pnc.enums.BuildStatus) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Aggregations

BuildOptions (org.jboss.pnc.spi.BuildOptions)35 Test (org.junit.Test)21 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)11 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)10 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)9 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)9 BuildRecord (org.jboss.pnc.model.BuildRecord)8 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)5 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 BuildStatus (org.jboss.pnc.enums.BuildStatus)4 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)4 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)4 BuildConflictException (org.jboss.pnc.spi.exception.BuildConflictException)4 CoreException (org.jboss.pnc.spi.exception.CoreException)4 Collections (java.util.Collections)3 Date (java.util.Date)3 List (java.util.List)3