use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class AbstractDependentBuildTest method configSet.
protected BuildConfigurationSet configSet(BuildConfiguration... configs) {
BuildConfigurationSet set = new BuildConfigurationSet();
Stream.of(configs).forEach(set::addBuildConfiguration);
return set;
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildCoordinationTest method buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess.
@Test
public void buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess() throws CoreException, TimeoutException, InterruptedException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.buildConfigurationWithDependencies(buildConfigurationSet);
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
// check the result
Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
assertThat(maybeSetRecord.isPresent()).isTrue();
Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
assertEmptyQueue();
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class BuildCoordinationTest method shouldBuildSetWithOneConfiguration.
@Test
public void shouldBuildSetWithOneConfiguration() throws CoreException, TimeoutException, InterruptedException {
BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
testProjectConfigurationBuilder.build(223, "Project-223", buildConfigurationSet);
ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.IMPLICIT_DEPENDENCY_CHECK);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
// check the result
Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
assertThat(maybeSetRecord.isPresent()).isTrue();
Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
assertEmptyQueue();
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class CancelledBuildTest method cancelBuildingConfigSetTestCase.
@Test(timeout = 5_000)
public void cancelBuildingConfigSetTestCase() throws Exception {
// given
DatastoreMock datastoreMock = new DatastoreMock();
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
BuildConfigurationSet configurationSet = configurationBuilder.buildConfigurationSetForCancel(1);
List<BuildStatusChangedEvent> receivedStatuses = new ArrayList<>();
Consumer<BuildStatusChangedEvent> onStatusUpdate = (event) -> {
receivedStatuses.add(event);
if (event.getBuild().getBuildConfigRevision().getId().equals("2") && event.getNewStatus().equals(BuildStatus.BUILDING)) {
CompletableFuture.runAsync(() -> {
try {
// wait a bit for build execution to start
Thread.sleep(250);
// we need to get buildConfigSet id to cancel BuildGroup, it is not provided by event class
// directly, so we need to dit it up from buildTaskId that event provides
log.info("Cancelling ...");
coordinator.cancelSet(getBuildConfigSetId(coordinator, event.getBuild().getId()));
} catch (CoreException | InterruptedException e) {
log.error("Unable to cancel the build.", e);
Assert.fail("Unable to cancel the build.");
}
});
}
};
// when
BuildSetTask buildSetTask = buildProjects(configurationSet, coordinator, onStatusUpdate, 2);
// expect
List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
Assert.assertEquals("Incorrect number of build records in datastore: " + buildRecords, 3, buildRecords.size());
for (BuildRecord buildRecord : buildRecords) {
Assert.assertNotNull(buildRecord.getSubmitTime());
switch(buildRecord.getBuildConfigurationId()) {
case 1:
Assert.assertEquals(BuildStatus.CANCELLED, buildRecord.getStatus());
continue;
case 2:
Assert.assertEquals(BuildStatus.CANCELLED, buildRecord.getStatus());
break;
case 3:
Assert.assertEquals(BuildStatus.SUCCESS, buildRecord.getStatus());
break;
default:
Assert.fail("Invalid build configuration ID");
break;
}
Assert.assertNotNull(buildRecord.getStartTime());
Assert.assertNotNull(buildRecord.getEndTime());
}
// 3 is independent, 2 is dependent on 3, 1 is dependent on 2
for (BuildTask buildTask : buildSetTask.getBuildTasks()) {
String buildTaskId = buildTask.getId();
switch(buildTask.getBuildConfigurationAudited().getId()) {
case 1:
// Building status is skipped (cancelled before it can start building)
assertStatusUpdateReceived(receivedStatuses, BuildStatus.WAITING_FOR_DEPENDENCIES, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.CANCELLED, buildTaskId);
break;
case 2:
assertStatusUpdateReceived(receivedStatuses, BuildStatus.WAITING_FOR_DEPENDENCIES, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.ENQUEUED, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.BUILDING, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.CANCELLED, buildTaskId);
break;
case 3:
assertStatusUpdateReceived(receivedStatuses, BuildStatus.ENQUEUED, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.BUILDING, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.SUCCESS, buildTaskId);
break;
default:
break;
}
}
}
use of org.jboss.pnc.model.BuildConfigurationSet in project pnc by project-ncl.
the class ConfigurationsTest method cycleConfigurationTestCase.
// TODO test is not run as expected exception is thrown
@Test(expected = PersistenceException.class)
// configurationBuilder.build...
@InSequence(15)
public void cycleConfigurationTestCase() throws Exception {
BuildConfigurationSet buildConfigurationSet = configurationBuilder.buildConfigurationSetWithCycleDependency();
User user = User.Builder.newBuilder().id(1).build();
BuildOptions buildOptions = new BuildOptions();
buildOptions.setRebuildMode(RebuildMode.FORCE);
BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, user, buildOptions);
Assert.assertEquals(BuildSetStatus.REJECTED, buildSetTask.getStatus());
Assert.assertTrue("Invalid status description: " + buildSetTask.getStatusDescription(), buildSetTask.getStatusDescription().contains("Cycle dependencies found"));
}
Aggregations