use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class LocalBuildScheduler method startBuilding.
@Override
public void startBuilding(BuildTask buildTask) throws CoreException {
Consumer<BuildExecutionStatusChangedEvent> onBuildExecutionStatusChangedEvent = (statusChangedEvent) -> {
try {
log.debug("Received execution status update {}.", statusChangedEvent);
if (statusChangedEvent.getNewStatus().isCompleted()) {
BuildResult buildResult = statusChangedEvent.getBuildResult().get();
log.debug("Notifying build execution completed {}.", statusChangedEvent);
buildCoordinator.completeBuild(buildTask, buildResult);
}
} catch (Throwable t) {
log.error("Failed to notify build completion.", t);
}
};
String contentId = ContentIdentityManager.getBuildContentId(buildTask.getId());
BuildConfigurationAudited configuration = buildTask.getBuildConfigurationAudited();
BuildExecutionConfiguration buildExecutionConfiguration = BuildExecutionConfiguration.build(buildTask.getId(), contentId, buildTask.getUser().getId().toString(), configuration.getBuildScript(), configuration.getId().toString(), configuration.getName(), configuration.getRepositoryConfiguration().getInternalUrl(), configuration.getScmRevision(), null, configuration.getRepositoryConfiguration().getExternalUrl(), configuration.getRepositoryConfiguration().isPreBuildSyncEnabled(), configuration.getBuildEnvironment().getSystemImageId(), configuration.getBuildEnvironment().getSystemImageRepositoryUrl(), configuration.getBuildEnvironment().getSystemImageType(), configuration.getBuildType(), buildTask.getBuildOptions().isKeepPodOnFailure(), configuration.getGenericParameters(), buildTask.getBuildOptions().isTemporaryBuild(), TimeUtils.generateTimestamp(buildTask.getBuildOptions().isTimestampAlignment(), buildTask.getBuildSetTask().getStartTime()), configuration.isBrewPullActive(), configuration.getDefaultAlignmentParams(), buildTask.getBuildOptions().getAlignmentPreference());
try {
buildExecutor.startBuilding(buildExecutionConfiguration, onBuildExecutionStatusChangedEvent, buildTask.getUser().getLoginToken());
} catch (ExecutorException e) {
throw new CoreException("Could not start build execution.", e);
}
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class BuildProviderImplTest method testFilterRunningBuildsByBuildConfigName.
@Test
public void testFilterRunningBuildsByBuildConfigName() {
// Given
mockBuildRecord();
mockBuildTask();
String givenBcName = "bcName";
BuildTask givenBT = mockBuildTask(givenBcName);
// When
BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, givenBcName);
Page<Build> builds = provider.getBuilds(pageInfo);
// Then
assertEquals(1, builds.getTotalHits());
Iterator<Build> it = builds.getContent().iterator();
assertEquals(givenBT.getId(), it.next().getId());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class BuildProviderImplTest method testGetRunningBuilds.
@Test
public void testGetRunningBuilds() {
// Prepare
mockBuildRecord();
// hit
mockBuildTask();
mockBuildRecord();
// hit
mockBuildTask();
mockBuildRecord();
// hit
BuildTask build2 = mockBuildTask();
mockBuildRecord();
// hit
BuildTask build1 = mockBuildTask();
// When
BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, "");
Page<Build> builds = provider.getBuilds(pageInfo);
// Verify
assertEquals(4, builds.getTotalHits());
assertEquals(2, builds.getContent().size());
Iterator<Build> it = builds.getContent().iterator();
assertEquals(build1.getId(), it.next().getId());
assertEquals(build2.getId(), it.next().getId());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class BuildProviderImplTest method testGetSpecificRunning.
@Test
public void testGetSpecificRunning() {
BuildTask task = mockBuildTask();
Build specific = provider.getSpecific(task.getId());
assertThat(specific.getId()).isEqualTo(task.getId());
assertThat(specific.getSubmitTime()).isEqualTo(task.getSubmitTime().toInstant());
}
use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.
the class BuildProviderImplTest method testFilterLikeRunningBuildsByBuildConfigName.
@Test
public void testFilterLikeRunningBuildsByBuildConfigName() {
// Given
mockBuildRecord();
mockBuildTask();
String givenBcName = "VeryLongAndComplicatedBcName";
String givenBcNamePattern = "*LongAndComplicated*";
BuildTask givenBT = mockBuildTask(givenBcName);
// When
BuildPageInfo pageInfo = new BuildPageInfo(0, 2, "", "", false, true, givenBcNamePattern);
Page<Build> builds = provider.getBuilds(pageInfo);
// Then
assertEquals(1, builds.getTotalHits());
Iterator<Build> it = builds.getContent().iterator();
assertEquals(givenBT.getId(), it.next().getId());
}
Aggregations