Search in sources :

Example 21 with BuildConfigurationSet

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"));
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 22 with BuildConfigurationSet

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();
}
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 23 with BuildConfigurationSet

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

Example 24 with BuildConfigurationSet

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;
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) Arquillian(org.jboss.arquillian.junit.Arquillian) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) TimeoutException(java.util.concurrent.TimeoutException) WITH_DATASTORE(org.jboss.pnc.coordinator.test.BuildCoordinatorDeployments.Options.WITH_DATASTORE) BuildSetStatusNotifications(org.jboss.pnc.coordinator.notifications.buildSetTask.BuildSetStatusNotifications) RebuildMode(org.jboss.pnc.enums.RebuildMode) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) Inject(javax.inject.Inject) HashSet(java.util.HashSet) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildQueue(org.jboss.pnc.coordinator.builder.BuildQueue) Logger(org.slf4j.Logger) WITH_BPM(org.jboss.pnc.coordinator.test.BuildCoordinatorDeployments.Options.WITH_BPM) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) Collection(java.util.Collection) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) Set(java.util.Set) Test(org.junit.Test) BuildRecord(org.jboss.pnc.model.BuildRecord) BuildStatus(org.jboss.pnc.enums.BuildStatus) Collectors(java.util.stream.Collectors) BuildSetCallBack(org.jboss.pnc.coordinator.notifications.buildSetTask.BuildSetCallBack) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) Consumer(java.util.function.Consumer) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) CoreException(org.jboss.pnc.spi.exception.CoreException) ChronoUnit(java.time.temporal.ChronoUnit) Assertions.fail(org.assertj.core.api.Assertions.fail) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) TestEntitiesFactory(org.jboss.pnc.mock.model.builders.TestEntitiesFactory) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) Optional(java.util.Optional) Assert(org.junit.Assert) Wait(org.jboss.pnc.test.util.Wait) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildSetCallBack(org.jboss.pnc.coordinator.notifications.buildSetTask.BuildSetCallBack) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)

Example 25 with BuildConfigurationSet

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

Aggregations

BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)29 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)11 Test (org.junit.Test)11 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)8 BuildOptions (org.jboss.pnc.spi.BuildOptions)8 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 CoreException (org.jboss.pnc.spi.exception.CoreException)5 Inject (javax.inject.Inject)4 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Consumer (java.util.function.Consumer)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 BuildSetStatusChangedEvent (org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)3 ArrayList (java.util.ArrayList)2