use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationSetWithAudited.
@Test
public void testBuildBuildConfigurationSetWithAudited() throws BuildConflictException, CoreException, DatastoreException {
BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
BuildConfigurationAudited bca3 = mockDatastoreWithBCAudited(BC_3, 9);
BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
reqBCA.setName("build-config-changed");
when(datastore.getBuildConfigurations(BCS)).thenReturn(BCS.getBuildConfigurations());
Map<Integer, BuildConfigurationAudited> overrides = Collections.singletonMap(1, reqBCA);
BuildSetTask buildSetTask = coordinator.build(BCS, overrides, USER, BUILD_OPTIONS);
assertEquals(2, buildSetTask.getBuildTasks().size());
BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
assertNotNull(buildTask);
assertNull(buildSetTask.getBuildTask(bca));
// Dependencies outside group are not build
assertNull(buildSetTask.getBuildTask(bcaDep));
assertNotNull(buildSetTask.getBuildTask(bca3));
assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class ProjectBuilder method buildProject.
void buildProject(BuildConfiguration buildConfiguration, BuildCoordinator buildCoordinator) throws BuildConflictException, InterruptedException, CoreException {
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
BuildTask buildTask = buildProject(buildConfiguration, buildCoordinator, receivedStatuses::add);
assertAllStatusUpdateReceived(receivedStatuses, buildTask.getId());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class ProjectBuilder method buildProject.
BuildTask buildProject(BuildConfiguration buildConfiguration, BuildCoordinator buildCoordinator, Consumer<BuildStatusChangedEvent> onStatusUpdate, BuildOptions buildOptions) throws BuildConflictException, InterruptedException, CoreException {
log.debug("Building project {}", buildConfiguration.getName());
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
Consumer<BuildStatusChangedEvent> onStatusUpdateInternal = (statusUpdate) -> {
receivedStatuses.add(statusUpdate);
onStatusUpdate.accept(statusUpdate);
};
// Defines a number of callbacks, which are executed after buildStatus update
final Semaphore semaphore = registerReleaseListenersAndAcquireSemaphore(onStatusUpdateInternal, N_STATUS_UPDATES_PER_TASK);
BuildSetTask taskSet = buildCoordinator.build(buildConfiguration, MockUser.newTestUser(1), buildOptions);
Set<BuildTask> buildTasks = taskSet.getBuildTasks();
assertThat(buildTasks).hasSize(1);
BuildTask buildTask = buildTasks.iterator().next();
log.info("Started build task {}", buildTask);
assertBuildStartedSuccessfully(buildTask);
waitForStatusUpdates(N_STATUS_UPDATES_PER_TASK, semaphore, "");
return buildTask;
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationAudited.
@Test
public void testBuildBuildConfigurationAudited() throws BuildConflictException, CoreException {
assertTrue("Test assumes that we build with dependencies", BUILD_OPTIONS.isBuildDependencies());
BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
reqBCA.setName("build-config-changed");
BuildSetTask buildSetTask = coordinator.build(reqBCA, USER, BUILD_OPTIONS);
assertEquals(2, buildSetTask.getBuildTasks().size());
BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
assertNotNull(buildTask);
assertNotNull(buildSetTask.getBuildTask(bcaDep));
assertNull(buildSetTask.getBuildTask(bca));
assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method mockBuildTask.
private BuildTask mockBuildTask() {
BuildConfiguration buildConfiguration = new BuildConfiguration();
buildConfiguration.setId(12);
buildConfiguration.setProject(new Project());
buildConfiguration.setRepositoryConfiguration(RepositoryConfigurationMock.newTestRepository());
buildConfiguration.setBuildEnvironment(BuildEnvironmentMock.newTest());
BuildOptions buildOptions = new BuildOptions(false, true, false, false, RebuildMode.IMPLICIT_DEPENDENCY_CHECK, AlignmentPreference.PREFER_PERSISTENT);
BuildTask buildTask = BuildTask.build(BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, 13), buildOptions, MockUser.newTestUser(1), "1", null, new Date(), null, "context-id", Optional.empty());
buildTask.setStatus(BuildCoordinationStatus.DONE);
return buildTask;
}
Aggregations