use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldTriggerTheSameBuildConfigurationWithNewRevision.
@Test
public void shouldTriggerTheSameBuildConfigurationWithNewRevision() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration testConfiguration = config("shouldRejectBCWithNewRevision");
BuildOptions buildOptions = new BuildOptions();
buildOptions.setBuildDependencies(false);
// when
coordinator.build(testConfiguration, user, buildOptions);
BuildConfiguration updatedConfiguration = updateConfiguration(testConfiguration);
BuildSetTask buildSetTask;
boolean rejected = false;
try {
buildSetTask = coordinator.build(updatedConfiguration, user, buildOptions);
} catch (BuildConflictException e) {
rejected = true;
}
// then
Assert.assertFalse("The task was rejected.", rejected);
waitForEmptyBuildQueue();
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
use of org.jboss.pnc.model.BuildConfiguration 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.BuildConfiguration in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldNotTriggerTheSameBuildConfigurationViaDependency.
@Test
public void shouldNotTriggerTheSameBuildConfigurationViaDependency() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration configurationA = config("configurationA");
BuildConfiguration configurationB = config("configurationB");
configurationA.addDependency(configurationB);
BuildOptions buildOptions = new BuildOptions();
// when
coordinator.build(configurationB, user, buildOptions);
Thread.sleep(50);
coordinator.build(configurationA, user, buildOptions);
// then
waitForEmptyBuildQueue();
Assert.assertEquals("There should be 2 build records.", 2, buildRecordRepository.queryAll().size());
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class WaitForDependencyBuildTest method shouldNotStartParentBuildWhenDependencyIsRunning.
@Test
public void shouldNotStartParentBuildWhenDependencyIsRunning() throws CoreException, TimeoutException, InterruptedException {
// start dependency
build(configDependency);
Wait.forCondition(() -> buildScheduler.isBuilding(configDependency.getId()), 3, ChronoUnit.SECONDS);
// start parent while dependency is running
build(configParent);
// parent should wait for dependency to complete
BuildTask parentBuildTask = getSubmittedBuildTaskByConfigurationId(configParent.getId()).get();
assertThat(parentBuildTask.getStatus()).isEqualTo(BuildCoordinationStatus.WAITING_FOR_DEPENDENCIES);
// complete the dependency
BuildTask dependencyBuildTask = getScheduledBuildTaskByConfigurationId(configDependency.getId()).get();
buildScheduler.completeBuild(dependencyBuildTask.getId());
// check if parent has started
Wait.forCondition(() -> buildScheduler.isBuilding(parentBuildTask.getBuildConfigurationAudited().getId()), 3, ChronoUnit.SECONDS);
buildScheduler.completeBuild(parentBuildTask.getId());
waitForEmptyBuildQueue();
List<BuildConfiguration> configsWithTasks = getBuiltConfigs();
assertThat(configsWithTasks).isEmpty();
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class BuildExecutionTest method buildShouldFail.
@Test
public void buildShouldFail() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
BuildConfiguration buildConfiguration = configurationBuilder.buildFailingConfiguration(2, "failed-build", null);
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesBase();
expectedStatuses.add(DONE_WITH_ERRORS);
// check build statuses
checkBuildStatuses(statusChangedEvents, expectedStatuses);
}
Aggregations