use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class CancelledBuildTest method buildSingleProjectTestCase.
@Test(timeout = 5_000)
public void buildSingleProjectTestCase() throws Exception {
// given
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastore);
BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastore).coordinator;
List<BuildStatusChangedEvent> receivedStatuses = new ArrayList<>();
Consumer<BuildStatusChangedEvent> onStatusUpdate = (event) -> {
receivedStatuses.add(event);
if (event.getNewStatus().equals(BuildStatus.BUILDING)) {
CompletableFuture.runAsync(() -> {
try {
// wait a bit for build execution to start
Thread.sleep(250);
coordinator.cancel(event.getBuild().getId());
} catch (CoreException | InterruptedException e) {
log.error("Unable to cancel the build.", e);
Assert.fail("Unable to cancel the build.");
}
});
}
};
// when
BuildTask buildTask = buildProject(configurationBuilder.buildConfigurationToCancel(1, "c1-java"), coordinator, onStatusUpdate);
// expect
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals("Too many build records in datastore: " + buildRecords, 1, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
Assert.assertNotNull(buildRecord.getSubmitTime());
Assert.assertNotNull(buildRecord.getStartTime());
Assert.assertNotNull(buildRecord.getEndTime());
Assert.assertEquals(BuildStatus.CANCELLED, buildRecord.getStatus());
String buildTaskId = buildTask.getId();
assertStatusUpdateReceived(receivedStatuses, BuildStatus.BUILDING, buildTaskId);
assertStatusUpdateReceived(receivedStatuses, BuildStatus.CANCELLED, buildTaskId);
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class DatastoreAdapterTest method shouldStoreRepourResult.
@Test
public void shouldStoreRepourResult() throws DatastoreException {
// given
DatastoreMock datastore = new DatastoreMock();
DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
RepourResult repourResult = RepourResultMock.mock();
// when
BuildConfiguration buildConfiguration = BuildConfiguration.Builder.newBuilder().name("Configuration.").build();
BuildConfigurationAudited buildConfigurationAudited = BuildConfigurationAudited.Builder.newBuilder().buildConfiguration(buildConfiguration).build();
BuildTask buildTask = mockBuildTask();
BuildExecutionConfiguration buildExecutionConfiguration = mock(BuildExecutionConfiguration.class);
BuildResult buildResult = new BuildResult(CompletionStatus.SUCCESS, Optional.empty(), "", Optional.of(buildExecutionConfiguration), Optional.of(BuildDriverResultMock.mockResult(BuildStatus.SUCCESS)), Optional.of(RepositoryManagerResultMock.mockResult()), Optional.of(EnvironmentDriverResultMock.mock()), Optional.of(repourResult));
datastoreAdapter.storeResult(buildTask, buildResult);
// then
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals(1, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
Assert.assertEquals(buildRecord.getStatus(), BuildStatus.SUCCESS);
Assert.assertEquals(repourResult.getExecutionRootName(), buildRecord.getExecutionRootName());
Assert.assertEquals(repourResult.getExecutionRootVersion(), buildRecord.getExecutionRootVersion());
Assert.assertEquals(repourResult.getLog(), buildRecord.getRepourLog());
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class DatastoreAdapterTest method shouldStoreRepositoryManagerSuccessResult.
@Test
public void shouldStoreRepositoryManagerSuccessResult() throws DatastoreException {
// given
DatastoreMock datastore = new DatastoreMock();
DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
BuildStatus buildStatus = BuildStatus.SUCCESS;
CompletionStatus completionStatus = CompletionStatus.SUCCESS;
// when
storeResult(datastoreAdapter, buildStatus, completionStatus);
// then
List<BuildRecord> buildRecords = datastore.getBuildRecords();
Assert.assertEquals(1, buildRecords.size());
BuildRecord buildRecord = buildRecords.get(0);
Assert.assertEquals(buildRecord.getStatus(), BuildStatus.SUCCESS);
Assert.assertTrue(buildRecord.getBuildLog().contains(BUILD_LOG));
Assert.assertTrue(buildRecord.getBuildLog().contains(REPOSITORY_MANAGER_LOG));
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldNotBuildTheSameBuildConfigurationSetTwice.
@Test
public void shouldNotBuildTheSameBuildConfigurationSetTwice() throws Exception {
// when
BuildOptions buildOptions1 = new BuildOptions();
// first build
coordinator.build(configSet, user, buildOptions1);
waitForEmptyBuildQueue();
BuildOptions buildOptions2 = new BuildOptions();
// rebuild build
coordinator.build(configSet, user, buildOptions2);
waitForEmptyBuildQueue();
// then
List<BuildRecord> buildRecords = getNonRejectedBuildRecords();
logRecords(buildRecords);
assertThat(buildRecords.size()).isEqualTo(configSet.getBuildConfigurations().size());
}
use of org.jboss.pnc.model.BuildRecord in project pnc by project-ncl.
the class SingleProjectBuildTest method buildWithAdvancedOptionsTest.
@Test
public void buildWithAdvancedOptionsTest() throws Exception {
// given
BuildOptions originalBuildOptions = new BuildOptions(true, true, true, true, RebuildMode.FORCE, AlignmentPreference.PREFER_PERSISTENT);
DatastoreMock datastoreMock = new DatastoreMock();
TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
// when
BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add, originalBuildOptions);
// then
List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
Assert.assertEquals(originalBuildOptions, buildTask.getBuildOptions());
}
Aggregations