use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildConfigurationSetRepositoryTest method shouldSaveBCSetWithBCs.
@Test
public void shouldSaveBCSetWithBCs() {
// given
BuildConfigurationFactory buildConfigurationFactory = new BuildConfigurationFactory();
BuildConfiguration buildConfiguration1 = buildConfigurationFactory.createDetached("One");
BuildConfiguration buildConfiguration2 = buildConfigurationFactory.createDetached("Two");
BuildConfiguration buildConfiguration3 = buildConfigurationFactory.createDetached("Three");
BuildConfigurationSet buildConfigurationSet = BuildConfigurationSet.Builder.newBuilder().name("Build Group").buildConfiguration(buildConfiguration1).build();
// when
BuildConfigurationSet buildConfigurationSetSaved = buildConfigurationSetRepository.save(buildConfigurationSet);
// then
List<BuildConfiguration> buildConfigurationsLoaded = buildConfigurationRepository.queryWithPredicates(withBuildConfigurationSetId(buildConfigurationSetSaved.getId()), isNotArchived());
assertThat(buildConfigurationsLoaded).isNotEmpty();
assertThat(buildConfigurationsLoaded.size()).isEqualTo(1);
assertThat(buildConfiguration1.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
assertThat(buildConfiguration2.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
assertThat(buildConfiguration3.getDefaultAlignmentParams().contains("-DdependencySource=REST"));
}
use of org.jboss.pnc.model.BuildConfigurationSet 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.model.BuildConfigurationSet 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();
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildCoordinationTest method registerCallback.
private ObjectWrapper<BuildSetStatus> registerCallback(BuildConfigurationSet buildConfigurationSet) {
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = new ObjectWrapper<>();
Consumer<BuildSetStatusChangedEvent> onStatusUpdate = (statusChangedEvent) -> {
if (statusChangedEvent.getNewStatus().isCompleted()) {
lastBuildSetStatus.set(statusChangedEvent.getNewStatus());
}
};
BuildSetCallBack buildSetCallBack = new BuildSetCallBack(buildConfigurationSet.getId(), onStatusUpdate);
buildSetStatusNotifications.subscribe(buildSetCallBack);
return lastBuildSetStatus;
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method shouldUpdateBuildRecordSetIfBuildSetBuilIsRejected.
@Test
public void shouldUpdateBuildRecordSetIfBuildSetBuilIsRejected() throws DatastoreException, CoreException {
BuildConfigurationSet bcSet = BuildConfigurationSet.Builder.newBuilder().buildConfigurations(Collections.emptySet()).name("BCSet").id(1).build();
BuildSetTask bsTask = coordinator.build(bcSet, USER, BUILD_OPTIONS);
assertThat(bsTask.getBuildConfigSetRecord().get().getStatus()).isEqualTo(BuildStatus.NO_REBUILD_REQUIRED);
}
Aggregations