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);
}
}
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;
}
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());
}
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);
}
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);
}
Aggregations