Search in sources :

Example 26 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class SkippingBuiltConfigsTest method shouldNotBuildTheSameBuildConfigurationSetTwice.

@Test
public void shouldNotBuildTheSameBuildConfigurationSetTwice() throws Exception {
    // when
    BuildOptions buildOptions1 = new BuildOptions();
    // first build
    coordinator.build(configSet, user, buildOptions1);
    waitForEmptyBuildQueue();
    BuildOptions buildOptions2 = new BuildOptions();
    // rebuild build
    coordinator.build(configSet, user, buildOptions2);
    waitForEmptyBuildQueue();
    // then
    List<BuildRecord> buildRecords = getNonRejectedBuildRecords();
    logRecords(buildRecords);
    assertThat(buildRecords.size()).isEqualTo(configSet.getBuildConfigurations().size());
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 27 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class StatusUpdatesTest method createBuildSetTask.

public BuildSetTask createBuildSetTask(BuildConfigurationSet buildConfigurationSet, User user) throws CoreException {
    BuildTasksInitializer buildTasksInitializer = new BuildTasksInitializer(datastoreAdapter, 1L);
    AtomicInteger atomicInteger = new AtomicInteger(1);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    return buildTasksInitializer.createBuildSetTask(buildConfigurationSet, user, buildOptions, () -> Sequence.nextBase32Id(), buildQueue.getUnfinishedTasks());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildTasksInitializer(org.jboss.pnc.coordinator.builder.BuildTasksInitializer)

Example 28 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class ProjectBuilder method buildProjectsAndWaitForUpdates.

private BuildSetTask buildProjectsAndWaitForUpdates(BuildConfigurationSet buildConfigurationSet, BuildCoordinator buildCoordinator, int nStatusUpdates, Consumer<BuildStatusChangedEvent> onStatusUpdate, List<BuildStatusChangedEvent> receivedStatuses, List<BuildSetStatusChangedEvent> receivedSetStatuses) throws InterruptedException, CoreException {
    Consumer<BuildStatusChangedEvent> onStatusUpdateInternal = (statusUpdate) -> {
        log.debug("Received status change event [" + (i++) + "]: {}.", statusUpdate);
        receivedStatuses.add(statusUpdate);
        onStatusUpdate.accept(statusUpdate);
    };
    final Semaphore semaphore = registerReleaseListenersAndAcquireSemaphore(onStatusUpdateInternal, nStatusUpdates);
    final Semaphore buildSetSemaphore = registerBuildSetListeners(receivedSetStatuses, BUILD_SET_STATUS_UPDATES);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, MockUser.newTestUser(1), buildOptions);
    assertBuildStartedSuccessfully(buildSetTask);
    log.info("Waiting to receive all {} status updates...", nStatusUpdates);
    waitForStatusUpdates(nStatusUpdates, semaphore, "");
    log.debug("All status updates should be received. Semaphore has {} free entries.", semaphore.availablePermits());
    log.info("Waiting to receive all {} build set status updates...", BUILD_SET_STATUS_UPDATES);
    waitForStatusUpdates(BUILD_SET_STATUS_UPDATES, buildSetSemaphore, "build set task: " + buildSetTask);
    log.debug("All status updates should be received. Semaphore has {} free entries.", semaphore.availablePermits());
    return buildSetTask;
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Arrays(java.util.Arrays) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildCoordinationStatus(org.jboss.pnc.enums.BuildCoordinationStatus) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) RebuildMode(org.jboss.pnc.enums.RebuildMode) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) Inject(javax.inject.Inject) TestCDIBuildSetStatusChangedReceiver(org.jboss.pnc.coordinator.test.event.TestCDIBuildSetStatusChangedReceiver) Assert.fail(org.junit.Assert.fail) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConflictException(org.jboss.pnc.spi.exception.BuildConflictException) Before(org.junit.Before) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) TestCDIBuildStatusChangedReceiver(org.jboss.pnc.coordinator.test.event.TestCDIBuildStatusChangedReceiver) Artifact(org.jboss.pnc.model.Artifact) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) BuildStatus(org.jboss.pnc.enums.BuildStatus) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) List(java.util.List) MockUser(org.jboss.pnc.mock.model.MockUser) CoreException(org.jboss.pnc.spi.exception.CoreException) Dependent(javax.enterprise.context.Dependent) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) ArtifactBuilder(org.jboss.pnc.mock.model.builders.ArtifactBuilder) Collections(java.util.Collections) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) Semaphore(java.util.concurrent.Semaphore)

Example 29 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class SingleProjectBuildTest method buildWithAdvancedOptionsTest.

@Test
public void buildWithAdvancedOptionsTest() throws Exception {
    // given
    BuildOptions originalBuildOptions = new BuildOptions(true, true, true, true, RebuildMode.FORCE, AlignmentPreference.PREFER_PERSISTENT);
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add, originalBuildOptions);
    // then
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    Assert.assertEquals(originalBuildOptions, buildTask.getBuildOptions());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 30 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class SingleProjectBuildTest method buildWithBasicOptionsTest.

@Test
public void buildWithBasicOptionsTest() throws Exception {
    // given
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add);
    // then
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    Assert.assertEquals(new BuildOptions(), buildTask.getBuildOptions());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) 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