use of org.jboss.pnc.model.BuildConfigSetRecord 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.BuildConfigSetRecord 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.BuildConfigSetRecord in project pnc by project-ncl.
the class ProjectWithDependenciesBuildTest method buildProjectTestCase.
@Test
public void buildProjectTestCase() throws Exception {
clearSemaphores();
// given
testCDIBuildSetStatusChangedReceiver.addBuildSetStatusChangedEventListener(this::collectEvent);
DatastoreMock datastoreMock = new DatastoreMock();
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
// when
BuildCoordinatorBeans coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock);
buildProjects(configurationBuilder.buildConfigurationSet(BUILD_SET_ID), coordinator.coordinator);
// expect
List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
log.trace("Found build records: {}", buildRecords.stream().map(br -> "Br.id: " + br.getId() + ", " + br.getBuildConfigurationAudited().getId().toString()).collect(Collectors.joining("; ")));
Assert.assertEquals("Wrong datastore results count.", 5, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
String buildLog = buildRecord.getBuildLog();
Assert.assertTrue("Invalid build log.", buildLog.contains("Finished: SUCCESS"));
assertArtifactsPresent(buildRecord.getBuiltArtifacts());
assertArtifactsPresent(buildRecord.getDependencies());
BuildConfigSetRecord buildConfigSetRecord = datastoreMock.getBuildConfigSetRecords().get(0);
Assert.assertNotNull("End time not set! Record: " + buildConfigSetRecord, buildConfigSetRecord.getEndTime());
Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
Assert.assertEquals(BuildStatus.SUCCESS, buildConfigSetRecord.getStatus());
String events = eventsReceived.stream().map(Object::toString).collect(Collectors.joining("; "));
Assert.assertEquals("Invalid number of received events. Received events: " + events, 2, eventsReceived.size());
Wait.forCondition(coordinator.queue::isEmpty, 1, ChronoUnit.SECONDS, "Not empty build queue: " + coordinator.queue);
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class ProjectWithFailedDependenciesBuildTest method checkDatabaseForResult.
@Test
@InSequence(20)
public void checkDatabaseForResult() {
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals("Wrong datastore results count. Got records: " + buildRecords, 2, buildRecords.size());
Assert.assertEquals(BuildStatus.FAILED, buildRecords.get(0).getStatus());
Assert.assertEquals(BuildStatus.REJECTED_FAILED_DEPENDENCIES, buildRecords.get(1).getStatus());
BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecords().get(0);
Assert.assertNotNull("End time is null.", buildConfigSetRecord.getEndTime());
Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
Assert.assertEquals(BuildStatus.FAILED, buildConfigSetRecord.getStatus());
}
use of org.jboss.pnc.model.BuildConfigSetRecord in project pnc by project-ncl.
the class ProjectWithFailedTransitiveDependenciesBuildTest method checkDatabaseForResult.
@Test
@InSequence(20)
public void checkDatabaseForResult() {
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals("Wrong datastore results count. Got records: " + buildRecords, 3, buildRecords.size());
Assert.assertEquals(BuildStatus.FAILED, buildRecords.get(0).getStatus());
Assert.assertEquals(BuildStatus.REJECTED_FAILED_DEPENDENCIES, buildRecords.get(1).getStatus());
BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecords().get(0);
Assert.assertNotNull("End time is null.", buildConfigSetRecord.getEndTime());
Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
Assert.assertEquals(BuildStatus.FAILED, buildConfigSetRecord.getStatus());
Assert.assertTrue("Build queue should be empty.", buildQueue.isEmpty());
}
Aggregations