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