Search in sources :

Example 21 with BuildOptions

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

the class GroupConfigurationEndpointImpl method triggerBuild.

private GroupBuild triggerBuild(String groupConfigId, Optional<GroupBuildRequest> buildConfigRevisions, GroupBuildParameters buildParams) {
    try {
        BuildOptions buildOptions = toBuildOptions(buildParams);
        int groupBuildId = buildTriggerer.triggerGroupBuild(Integer.parseInt(groupConfigId), buildConfigRevisions, buildOptions);
        return groupBuildProvider.getSpecific(Integer.toString(groupBuildId));
    } catch (BuildConflictException ex) {
        throw new AlreadyRunningException(ex, ex.getBuildTaskId());
    } catch (CoreException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : AlreadyRunningException(org.jboss.pnc.facade.validation.AlreadyRunningException) CoreException(org.jboss.pnc.spi.exception.CoreException) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConflictException(org.jboss.pnc.spi.exception.BuildConflictException) GroupConfigurationEndpoint(org.jboss.pnc.rest.api.endpoints.GroupConfigurationEndpoint)

Example 22 with BuildOptions

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

the class GroupConfigurationEndpointImpl method toBuildOptions.

private BuildOptions toBuildOptions(GroupBuildParameters buildParams) {
    BuildOptions buildOptions = new BuildOptions(buildParams.isTemporaryBuild(), false, false, false, buildParams.getRebuildMode(), buildParams.getAlignmentPreference());
    checkBuildOptionsValidity(buildOptions);
    return buildOptions;
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions)

Example 23 with BuildOptions

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

the class CancelledBuildByBpmTest method buildSingleProjectTestCase.

@Test(timeout = 5_000)
public void buildSingleProjectTestCase() throws Exception {
    // given
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastoreMock);
    SystemConfig systemConfig = createConfiguration();
    BuildQueue queue = new BuildQueue(systemConfig);
    BlockingQueue<BuildStatusChangedEvent> receivedStatuses = new ArrayBlockingQueue<>(5);
    Consumer<BuildStatusChangedEvent> onStatusUpdate = receivedStatuses::add;
    EventListener buildStatusChangedEventNotifier = new EventListener(onStatusUpdate);
    BlockingQueue<BpmTask> task = new ArrayBlockingQueue<>(5);
    Consumer<BpmTask> onBpmTaskCreated = task::add;
    BuildSchedulerFactory buildSchedulerFactory = new BuildSchedulerFactory(onBpmTaskCreated);
    BuildCoordinator coordinator = new DefaultBuildCoordinator(datastoreAdapter, buildStatusChangedEventNotifier, null, buildSchedulerFactory, queue, systemConfig, groupBuildMapper, buildMapper);
    coordinator.start();
    queue.initSemaphore();
    coordinator.build(configurationBuilder.buildConfigurationToCancel(1, "c1-bpm"), MockUser.newTestUser(1), new BuildOptions());
    waitForStatus(receivedStatuses, BuildStatus.BUILDING);
    BpmTask bpmTask = task.poll(1, TimeUnit.SECONDS);
    BuildResultRest result = new BuildResultRest();
    result.setCompletionStatus(CompletionStatus.CANCELLED);
    // when
    bpmTask.notify(BUILD_COMPLETE, result);
    waitForStatus(receivedStatuses, BuildStatus.CANCELLED);
    // expect
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Too many build records in datastore: " + buildRecords, 1, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    Assert.assertNotNull(buildRecord.getSubmitTime());
    Assert.assertNotNull(buildRecord.getStartTime());
    Assert.assertNotNull(buildRecord.getEndTime());
    Assert.assertEquals(BuildStatus.CANCELLED, buildRecord.getStatus());
}
Also used : BuildQueue(org.jboss.pnc.coordinator.builder.BuildQueue) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) DefaultBuildCoordinator(org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator) SystemConfig(org.jboss.pnc.common.json.moduleconfig.SystemConfig) BpmTask(org.jboss.pnc.bpm.BpmTask) 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) BuildResultRest(org.jboss.pnc.bpm.model.BuildResultRest) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) BuildOptions(org.jboss.pnc.spi.BuildOptions) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) DefaultBuildCoordinator(org.jboss.pnc.coordinator.builder.DefaultBuildCoordinator) Test(org.junit.Test)

Example 24 with BuildOptions

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

the class SkippingBuiltConfigsTest method shouldBuildConfigurationAndUnbuiltDependency.

@Test
public void shouldBuildConfigurationAndUnbuiltDependency() throws Exception {
    coordinator.start();
    buildRecordRepository.clear();
    // given
    BuildConfiguration testConfiguration = config("shouldBuildConfigurationAndUnbuiltDependency");
    BuildConfiguration dependency = config("dependency");
    testConfiguration.addDependency(dependency);
    BuildOptions buildOptions = new BuildOptions();
    // when
    coordinator.build(testConfiguration, user, buildOptions);
    waitForEmptyBuildQueue();
    // then
    assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildOptions(org.jboss.pnc.spi.BuildOptions) Test(org.junit.Test)

Example 25 with BuildOptions

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

the class SkippingBuiltConfigsTest method shouldNotRebuildAlreadyBuiltDependency.

@Test
public void shouldNotRebuildAlreadyBuiltDependency() throws Exception {
    coordinator.start();
    buildRecordRepository.clear();
    // given
    BuildConfiguration testConfiguration = config("shouldNotRebuildAlreadyBuiltDependency");
    BuildConfiguration dependency = config("dependency");
    testConfiguration.addDependency(dependency);
    BuildOptions buildOptions = new BuildOptions();
    coordinator.build(dependency, user, buildOptions);
    waitForEmptyBuildQueue();
    assertThat(getNonRejectedBuildRecords().size()).isEqualTo(1);
    // when
    coordinator.build(testConfiguration, user, buildOptions);
    waitForEmptyBuildQueue();
    // then
    assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildOptions(org.jboss.pnc.spi.BuildOptions) 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