Search in sources :

Example 6 with BuildSetStatusChangedEvent

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

the class ProjectBuilder method buildProjectsAndVerifyResult.

private void buildProjectsAndVerifyResult(BuildConfigurationSet buildConfigurationSet, BuildCoordinator buildCoordinator, int nStatusUpdates, Verifier verifier) throws InterruptedException, CoreException {
    log.info("Building configuration set {}", buildConfigurationSet.getName());
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    List<BuildSetStatusChangedEvent> receivedSetStatuses = new CopyOnWriteArrayList<>();
    BuildSetTask buildSetTask = buildProjectsAndWaitForUpdates(buildConfigurationSet, buildCoordinator, nStatusUpdates, x -> {
    }, receivedStatuses, receivedSetStatuses);
    log.info("Checking if received all status updates...");
    verifier.verify(receivedStatuses, buildSetTask);
}
Also used : BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 7 with BuildSetStatusChangedEvent

use of org.jboss.pnc.spi.events.BuildSetStatusChangedEvent 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 8 with BuildSetStatusChangedEvent

use of org.jboss.pnc.spi.events.BuildSetStatusChangedEvent 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

BuildSetStatusChangedEvent (org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)8 HashSet (java.util.HashSet)4 Set (java.util.Set)4 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)4 Test (org.junit.Test)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Consumer (java.util.function.Consumer)3 Collectors (java.util.stream.Collectors)3 Inject (javax.inject.Inject)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 RebuildMode (org.jboss.pnc.enums.RebuildMode)3 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)3 BuildOptions (org.jboss.pnc.spi.BuildOptions)3 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)3 Collections (java.util.Collections)2 Optional (java.util.Optional)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 Deployment (org.jboss.arquillian.container.test.api.Deployment)2