use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class AbstractDependentBuildTest method buildConfig.
protected BuildConfiguration buildConfig(String name, BuildConfiguration... dependencies) {
int id = configIdSequence.getAndIncrement();
Project project = Project.Builder.newBuilder().id(1).name("Mock project").build();
BuildConfiguration config = BuildConfiguration.Builder.newBuilder().id(id).name(name).project(project).repositoryConfiguration(RepositoryConfigurationMock.newTestRepository()).buildEnvironment(BuildEnvironmentMock.newTest()).build();
Stream.of(dependencies).forEach(config::addDependency);
return config;
}
use of org.jboss.pnc.model.BuildConfiguration 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.model.BuildConfiguration 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;
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class DefaultBuildCoordinatorTest method shouldCreateNoRebuildRequiredRecords.
@Test
public void shouldCreateNoRebuildRequiredRecords() throws CoreException, TimeoutException, InterruptedException {
when(datastore.requiresRebuild(any(BuildConfigurationAudited.class), any(Boolean.class), any(Boolean.class), nullable(AlignmentPreference.class), anySet())).thenReturn(false);
BuildConfigurationAudited bca1 = new BuildConfigurationAudited();
IdRev idRev1 = new IdRev(BC_1.getId(), BC_1.getId() * 1000 + 1);
bca1.setIdRev(idRev1);
bca1.setId(idRev1.getId());
bca1.setRev(idRev1.getRev());
bca1.setProject(PROJECT);
when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_1.getId())).thenReturn(bca1);
BuildConfigurationAudited bca3 = new BuildConfigurationAudited();
IdRev idRev3 = new IdRev(BC_3.getId(), BC_3.getId() * 1000 + 1);
bca3.setIdRev(idRev3);
bca3.setId(idRev3.getId());
bca3.setRev(idRev3.getRev());
bca3.setProject(PROJECT);
when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_3.getId())).thenReturn(bca3);
Set<BuildConfiguration> buildConfigs = new HashSet<>();
buildConfigs.add(BC_1);
buildConfigs.add(BC_3);
when(datastore.getBuildConfigurations(any())).thenReturn(buildConfigs);
Set<BuildRecord> storedRecords = new HashSet<>();
when(datastore.storeRecordForNoRebuild(any())).thenAnswer(new SaveRecordForNoRebuildAnswer(storedRecords));
BuildSetTask bsTask = coordinator.build(BCS, USER, BUILD_OPTIONS);
coordinator.start();
assertThat(bsTask.getBuildConfigSetRecord().get().getStatus()).isEqualTo(BuildStatus.NO_REBUILD_REQUIRED);
Wait.forCondition(() -> storedRecords.size() == 2, 3, ChronoUnit.SECONDS);
assertThat(storedRecords.size()).isEqualTo(2);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildEnvironmentTest method shouldReportErrorInCaseOfPodCreationFailure.
@Test
public void shouldReportErrorInCaseOfPodCreationFailure() throws ExecutorException, InterruptedException, TimeoutException {
BuildConfiguration buildConfiguration = configurationBuilder.build(123, "Pod creation failure");
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, true);
checkBuildStatuses(statusChangedEvents, Arrays.asList(BUILD_ENV_SETTING_UP, BUILD_ENV_WAITING, BUILD_ENV_SETUP_COMPLETE_WITH_ERROR, // supported yet
DONE_WITH_ERRORS));
assertNoState(statusChangedEvents, BUILD_ENV_SETUP_COMPLETE_SUCCESS);
assertNoState(statusChangedEvents, BUILD_SETTING_UP);
}
Aggregations