use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldNotBuildTheSameBuildConfigurationTwice.
@Test
public void shouldNotBuildTheSameBuildConfigurationTwice() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration testConfiguration = config("shouldNotBuildTheSameBuildConfigurationTwice");
BuildOptions buildOptions = new BuildOptions();
buildOptions.setBuildDependencies(false);
// when
coordinator.build(testConfiguration, user, buildOptions);
waitForEmptyBuildQueue();
coordinator.build(testConfiguration, user, buildOptions);
waitForEmptyBuildQueue();
// then
// there should be one non build
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(1);
// there should be stored one NO_REBUILD_REQUIRED
List<BuildRecord> collectNoRebuildRequired = buildRecordRepository.queryAll().stream().filter(r -> r.getStatus() == BuildStatus.NO_REBUILD_REQUIRED).collect(Collectors.toList());
assertThat(collectNoRebuildRequired.size()).isEqualTo(1);
assertThat(collectNoRebuildRequired.iterator().next().getNoRebuildCause()).isNotNull();
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldRerunTheSameBuildConfigurationIfRebuildAllIsSpecified.
@Test
public void shouldRerunTheSameBuildConfigurationIfRebuildAllIsSpecified() throws Exception {
buildRecordRepository.clear();
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
// when
coordinator.build(configA, user, buildOptions);
waitForEmptyBuildQueue();
coordinator.build(configA, user, buildOptions);
waitForEmptyBuildQueue();
// then
List<BuildRecord> buildRecords = getNonRejectedBuildRecords();
assertThat(buildRecords.size()).isEqualTo(2);
logRecords(buildRecords);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class DatastoreMock method storeCompletedBuild.
@Override
public BuildRecord storeCompletedBuild(BuildRecord.Builder buildRecordBuilder, List<Artifact> builtArtifacts, List<Artifact> dependencies) {
buildRecordBuilder.dependencies(dependencies);
BuildRecord buildRecord = Mockito.spy(buildRecordBuilder.build());
Mockito.when(buildRecord.getBuiltArtifacts()).thenReturn(new HashSet<>(builtArtifacts));
BuildConfiguration buildConfiguration = buildRecord.getBuildConfigurationAudited().getBuildConfiguration();
log.info("Storing build " + buildConfiguration);
synchronized (this) {
boolean exists = getBuildRecords().stream().anyMatch(br -> br.equals(buildRecord));
if (exists) {
throw new PersistenceException("Unique constraint violation, the record with id [" + buildRecord.getId() + "] already exists.");
}
buildRecords.add(buildRecord);
}
return buildRecord;
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class DefaultBuildCoordinator method completeNoBuild.
public void completeNoBuild(BuildTask buildTask, CompletionStatus completionStatus) {
String buildTaskId = buildTask.getId();
BuildCoordinationStatus coordinationStatus = BuildCoordinationStatus.SYSTEM_ERROR;
try {
if (CompletionStatus.NO_REBUILD_REQUIRED.equals(completionStatus)) {
updateBuildTaskStatus(buildTask, BuildCoordinationStatus.REJECTED_ALREADY_BUILT);
// TODO cancel should be here enable in 2.0 as CANCELed is not failed build
// } else if (CompletionStatus.CANCELLED.equals(completionStatus)) {
// updateBuildTaskStatus(buildTask, BuildCoordinationStatus.CANCELLED);
} else {
throw new BuildCoordinationException(String.format("Invalid status %s.", completionStatus));
}
log.debug("Storing no build required result. Id: {}", buildTaskId);
BuildRecord buildRecord = datastoreAdapter.storeRecordForNoRebuild(buildTask);
if (buildRecord.getStatus().completedSuccessfully()) {
coordinationStatus = BuildCoordinationStatus.DONE;
} else {
log.warn("[buildTaskId: {}] Something went wrong while storing the success result. The status has changed to {}.", buildTaskId, buildRecord.getStatus());
coordinationStatus = BuildCoordinationStatus.SYSTEM_ERROR;
}
} catch (Throwable e) {
log.error("[buildTaskId: " + buildTaskId + "] Cannot store results to datastore.", e);
coordinationStatus = BuildCoordinationStatus.SYSTEM_ERROR;
} finally {
updateBuildTaskStatus(buildTask, coordinationStatus);
}
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class BuildResultPushManagerTest method shouldRejectWithMissingData.
@Test
public void shouldRejectWithMissingData() {
// given
BuildRecord record = buildRecord(false);
// when
Result result = release(record);
// then
assertThat(result).extracting(Result::getStatus).isEqualTo(BuildPushStatus.SYSTEM_ERROR);
assertThat(result.getMessage()).containsIgnoringCase("attribute BREW_BUILD_NAME");
}
Aggregations