use of org.jboss.pnc.model.BuildConfiguration 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.BuildConfiguration in project pnc by project-ncl.
the class OutsideGroupDependentConfigsTest method initialize.
@Before
public void initialize() throws DatastoreException, ConfigurationParseException {
config1 = buildConfig("1");
configA = buildConfig("A", config1);
configB = buildConfig("B", configA);
BuildConfiguration configC = buildConfig("C");
configSet = configSet(configA, configB, configC);
buildConfigurationRepository = spy(new BuildConfigurationRepositoryMock());
when(buildConfigurationRepository.queryWithPredicates(any())).thenReturn(new ArrayList<>(configSet.getBuildConfigurations()));
super.initialize();
saveConfig(config1);
configSet.getBuildConfigurations().forEach(this::saveConfig);
insertNewBuildRecords(config1, configA, configB, configC);
makeResult(configA).dependOn(config1);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldBuildConfigurationAndUnbuiltDependency.
@Test
public void shouldBuildConfigurationAndUnbuiltDependency() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration testConfiguration = config("shouldBuildConfigurationAndUnbuiltDependency");
BuildConfiguration dependency = config("dependency");
testConfiguration.addDependency(dependency);
BuildOptions buildOptions = new BuildOptions();
// when
coordinator.build(testConfiguration, user, buildOptions);
waitForEmptyBuildQueue();
// then
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class SkippingBuiltConfigsTest method shouldNotRebuildAlreadyBuiltDependency.
@Test
public void shouldNotRebuildAlreadyBuiltDependency() throws Exception {
coordinator.start();
buildRecordRepository.clear();
// given
BuildConfiguration testConfiguration = config("shouldNotRebuildAlreadyBuiltDependency");
BuildConfiguration dependency = config("dependency");
testConfiguration.addDependency(dependency);
BuildOptions buildOptions = new BuildOptions();
coordinator.build(dependency, user, buildOptions);
waitForEmptyBuildQueue();
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(1);
// when
coordinator.build(testConfiguration, user, buildOptions);
waitForEmptyBuildQueue();
// then
assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
use of org.jboss.pnc.model.BuildConfiguration in project pnc by project-ncl.
the class EarlyCancellationTest method testBuild.
private void testBuild(BuildExecutionStatus cancelAfter, BuildExecutionStatus[] expectedStatuses, BuildExecutionStatus[] unexpectedStatuses) throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException, ConfigurationParseException {
BuildConfiguration buildConfiguration = configurationBuilder.build(1, "c1-java");
Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
DefaultBuildExecutor executor = new DefaultBuildExecutor(repositoryManagerFactory, buildDriverFactory, environmentDriverFactory, new Configuration(), null);
Consumer<BuildExecutionStatusChangedEvent> cancel = (e) -> {
if (cancelAfter.equals(e.getNewStatus())) {
try {
log.info("Cancelling build ...");
executor.cancel("1");
} catch (ExecutorException e0) {
e0.printStackTrace();
}
}
};
runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper, cancel, executor);
// check build statuses
checkBuildStatuses(statusChangedEvents, Arrays.asList(expectedStatuses));
buildStatusesShouldNotContain(statusChangedEvents, Arrays.asList(unexpectedStatuses));
}
Aggregations