Search in sources :

Example 1 with BuildSetStatus

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

the class BuildCoordinationTest method buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess.

@Test
public void buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess() throws CoreException, TimeoutException, InterruptedException {
    BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
    testProjectConfigurationBuilder.buildConfigurationWithDependencies(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());
    Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
    assertThat(maybeSetRecord.isPresent()).isTrue();
    Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
    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) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Example 2 with BuildSetStatus

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

the class BuildCoordinationTest method shouldBuildSetWithOneConfiguration.

@Test
public void shouldBuildSetWithOneConfiguration() throws CoreException, TimeoutException, InterruptedException {
    BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
    testProjectConfigurationBuilder.build(223, "Project-223", buildConfigurationSet);
    ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.IMPLICIT_DEPENDENCY_CHECK);
    BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
    Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
    // check the result
    Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
    Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
    assertThat(maybeSetRecord.isPresent()).isTrue();
    Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
    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) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Example 3 with BuildSetStatus

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

the class DefaultBuildCoordinator method updateBuildSetTaskStatus.

private void updateBuildSetTaskStatus(BuildSetTask buildSetTask, BuildSetStatus status, String description) {
    log.info("Setting new status {} on buildSetTask.id {}. Description: {}.", status, buildSetTask.getId(), description);
    BuildSetStatus oldStatus = buildSetTask.getStatus();
    Optional<BuildConfigSetRecord> buildConfigSetRecord = buildSetTask.getBuildConfigSetRecord();
    // Completed BuildSets are updated using BuildSetTask#taskStatusUpdatedToFinalState()
    if (buildConfigSetRecord.isPresent() && REJECTED_STATES.containsKey(status)) {
        buildConfigSetRecord.get().setStatus(REJECTED_STATES.get(status));
        try {
            datastoreAdapter.saveBuildConfigSetRecord(buildConfigSetRecord.get());
        } catch (DatastoreException de) {
            log.warn("Failed to update build config set record to REJECTED status: " + de);
        }
    }
    buildConfigSetRecord.ifPresent(record -> sendSetStatusChangeEvent(buildSetTask, status, oldStatus, record, description));
    buildSetTask.setStatus(status);
    buildSetTask.setStatusDescription(description);
}
Also used : BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord)

Example 4 with BuildSetStatus

use of org.jboss.pnc.spi.BuildSetStatus 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 5 with BuildSetStatus

use of org.jboss.pnc.spi.BuildSetStatus 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)

Aggregations

BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)5 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)4 BuildOptions (org.jboss.pnc.spi.BuildOptions)4 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)4 Test (org.junit.Test)4 BuildStatus (org.jboss.pnc.enums.BuildStatus)2 DatastoreException (org.jboss.pnc.spi.datastore.DatastoreException)2 ChronoUnit (java.time.temporal.ChronoUnit)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TimeoutException (java.util.concurrent.TimeoutException)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.fail (org.assertj.core.api.Assertions.fail)1 Deployment (org.jboss.arquillian.container.test.api.Deployment)1