Search in sources :

Example 1 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationSetWithAudited.

@Test
public void testBuildBuildConfigurationSetWithAudited() throws BuildConflictException, CoreException, DatastoreException {
    BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
    BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
    BuildConfigurationAudited bca3 = mockDatastoreWithBCAudited(BC_3, 9);
    BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
    reqBCA.setName("build-config-changed");
    when(datastore.getBuildConfigurations(BCS)).thenReturn(BCS.getBuildConfigurations());
    Map<Integer, BuildConfigurationAudited> overrides = Collections.singletonMap(1, reqBCA);
    BuildSetTask buildSetTask = coordinator.build(BCS, overrides, USER, BUILD_OPTIONS);
    assertEquals(2, buildSetTask.getBuildTasks().size());
    BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
    assertNotNull(buildTask);
    assertNull(buildSetTask.getBuildTask(bca));
    // Dependencies outside group are not build
    assertNull(buildSetTask.getBuildTask(bcaDep));
    assertNotNull(buildSetTask.getBuildTask(bca3));
    assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
    assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
    assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Test(org.junit.Test)

Example 2 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method mockDatastoreWithBCAudited.

private BuildConfigurationAudited mockDatastoreWithBCAudited(BuildConfiguration bc, int rev) {
    BuildConfigurationAudited bca = toBuildConfigurationAudited(bc, rev);
    when(datastore.getLatestBuildConfigurationAudited(bc.getId())).thenReturn(bca);
    when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(bc.getId())).thenReturn(bca);
    return bca;
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited)

Example 3 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method testBuildBuildConfigurationAudited.

@Test
public void testBuildBuildConfigurationAudited() throws BuildConflictException, CoreException {
    assertTrue("Test assumes that we build with dependencies", BUILD_OPTIONS.isBuildDependencies());
    BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
    BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
    BuildConfigurationAudited reqBCA = toBuildConfigurationAudited(BC_1, 4);
    reqBCA.setName("build-config-changed");
    BuildSetTask buildSetTask = coordinator.build(reqBCA, USER, BUILD_OPTIONS);
    assertEquals(2, buildSetTask.getBuildTasks().size());
    BuildTask buildTask = buildSetTask.getBuildTask(reqBCA);
    assertNotNull(buildTask);
    assertNotNull(buildSetTask.getBuildTask(bcaDep));
    assertNull(buildSetTask.getBuildTask(bca));
    assertEquals(4, buildTask.getBuildConfigurationAudited().getRev().intValue());
    assertEquals("build-config-changed", buildTask.getBuildConfigurationAudited().getName());
    assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Test(org.junit.Test)

Example 4 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method testBuildBuildConfiguration.

@Test
public void testBuildBuildConfiguration() throws BuildConflictException, CoreException {
    assertTrue("Test assumes that we build with dependencies", BUILD_OPTIONS.isBuildDependencies());
    BuildConfigurationAudited bca = mockDatastoreWithBCAudited(BC_1, 5);
    BuildConfigurationAudited bcaDep = mockDatastoreWithBCAudited(BC_2, 2);
    BuildSetTask buildSetTask = coordinator.build(BC_1, USER, BUILD_OPTIONS);
    assertEquals(2, buildSetTask.getBuildTasks().size());
    assertNotNull(buildSetTask.getBuildTask(bca));
    assertNotNull(buildSetTask.getBuildTask(bcaDep));
    assertSame(BUILD_OPTIONS, buildSetTask.getBuildOptions());
}
Also used : BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Test(org.junit.Test)

Example 5 with BuildConfigurationAudited

use of org.jboss.pnc.model.BuildConfigurationAudited in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method shouldCreateNoRebuildRequiredRecords.

@Test
public void shouldCreateNoRebuildRequiredRecords() throws CoreException, TimeoutException, InterruptedException {
    when(datastore.requiresRebuild(any(BuildConfigurationAudited.class), any(Boolean.class), any(Boolean.class), nullable(AlignmentPreference.class), anySet())).thenReturn(false);
    BuildConfigurationAudited bca1 = new BuildConfigurationAudited();
    IdRev idRev1 = new IdRev(BC_1.getId(), BC_1.getId() * 1000 + 1);
    bca1.setIdRev(idRev1);
    bca1.setId(idRev1.getId());
    bca1.setRev(idRev1.getRev());
    bca1.setProject(PROJECT);
    when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_1.getId())).thenReturn(bca1);
    BuildConfigurationAudited bca3 = new BuildConfigurationAudited();
    IdRev idRev3 = new IdRev(BC_3.getId(), BC_3.getId() * 1000 + 1);
    bca3.setIdRev(idRev3);
    bca3.setId(idRev3.getId());
    bca3.setRev(idRev3.getRev());
    bca3.setProject(PROJECT);
    when(datastore.getLatestBuildConfigurationAuditedLoadBCDependencies(BC_3.getId())).thenReturn(bca3);
    Set<BuildConfiguration> buildConfigs = new HashSet<>();
    buildConfigs.add(BC_1);
    buildConfigs.add(BC_3);
    when(datastore.getBuildConfigurations(any())).thenReturn(buildConfigs);
    Set<BuildRecord> storedRecords = new HashSet<>();
    when(datastore.storeRecordForNoRebuild(any())).thenAnswer(new SaveRecordForNoRebuildAnswer(storedRecords));
    BuildSetTask bsTask = coordinator.build(BCS, USER, BUILD_OPTIONS);
    coordinator.start();
    assertThat(bsTask.getBuildConfigSetRecord().get().getStatus()).isEqualTo(BuildStatus.NO_REBUILD_REQUIRED);
    Wait.forCondition(() -> storedRecords.size() == 2, 3, ChronoUnit.SECONDS);
    assertThat(storedRecords.size()).isEqualTo(2);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) AlignmentPreference(org.jboss.pnc.api.enums.AlignmentPreference) IdRev(org.jboss.pnc.model.IdRev) BuildRecord(org.jboss.pnc.model.BuildRecord) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)35 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)12 IdRev (org.jboss.pnc.model.IdRev)12 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)10 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)10 Test (org.junit.Test)8 HashSet (java.util.HashSet)7 BuildRecord (org.jboss.pnc.model.BuildRecord)6 Date (java.util.Date)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Map (java.util.Map)4 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 Inject (javax.inject.Inject)4 Base32LongID (org.jboss.pnc.model.Base32LongID)4 Collections (java.util.Collections)3 List (java.util.List)3 Optional (java.util.Optional)3 Stateless (javax.ejb.Stateless)3