Search in sources :

Example 11 with BuildConfiguration

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

the class SkippingBuiltConfigsTest method shouldTriggerTheSameBuildConfigurationWithNewRevision.

@Test
public void shouldTriggerTheSameBuildConfigurationWithNewRevision() throws Exception {
    coordinator.start();
    buildRecordRepository.clear();
    // given
    BuildConfiguration testConfiguration = config("shouldRejectBCWithNewRevision");
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setBuildDependencies(false);
    // when
    coordinator.build(testConfiguration, user, buildOptions);
    BuildConfiguration updatedConfiguration = updateConfiguration(testConfiguration);
    BuildSetTask buildSetTask;
    boolean rejected = false;
    try {
        buildSetTask = coordinator.build(updatedConfiguration, user, buildOptions);
    } catch (BuildConflictException e) {
        rejected = true;
    }
    // then
    Assert.assertFalse("The task was rejected.", rejected);
    waitForEmptyBuildQueue();
    assertThat(getNonRejectedBuildRecords().size()).isEqualTo(2);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConflictException(org.jboss.pnc.spi.exception.BuildConflictException) Test(org.junit.Test)

Example 12 with BuildConfiguration

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

the class SkippingBuiltConfigsTest method shouldNotBuildTheSameBuildConfigurationTwice.

@Test
public void shouldNotBuildTheSameBuildConfigurationTwice() throws Exception {
    coordinator.start();
    buildRecordRepository.clear();
    // given
    BuildConfiguration testConfiguration = config("shouldNotBuildTheSameBuildConfigurationTwice");
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setBuildDependencies(false);
    // when
    coordinator.build(testConfiguration, user, buildOptions);
    waitForEmptyBuildQueue();
    coordinator.build(testConfiguration, user, buildOptions);
    waitForEmptyBuildQueue();
    // then
    // there should be one non build
    assertThat(getNonRejectedBuildRecords().size()).isEqualTo(1);
    // there should be stored one NO_REBUILD_REQUIRED
    List<BuildRecord> collectNoRebuildRequired = buildRecordRepository.queryAll().stream().filter(r -> r.getStatus() == BuildStatus.NO_REBUILD_REQUIRED).collect(Collectors.toList());
    assertThat(collectNoRebuildRequired.size()).isEqualTo(1);
    assertThat(collectNoRebuildRequired.iterator().next().getNoRebuildCause()).isNotNull();
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Logger(org.slf4j.Logger) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) BuildRecord(org.jboss.pnc.model.BuildRecord) Mockito.spy(org.mockito.Mockito.spy) RebuildMode(org.jboss.pnc.enums.RebuildMode) Collectors(java.util.stream.Collectors) BuildStatus(org.jboss.pnc.enums.BuildStatus) ArrayList(java.util.ArrayList) List(java.util.List) ConfigurationParseException(org.jboss.pnc.common.json.ConfigurationParseException) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Assert(org.junit.Assert) BuildConflictException(org.jboss.pnc.spi.exception.BuildConflictException) BuildConfigurationRepositoryMock(org.jboss.pnc.mock.repository.BuildConfigurationRepositoryMock) Before(org.junit.Before) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 13 with BuildConfiguration

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

the class SkippingBuiltConfigsTest method shouldNotTriggerTheSameBuildConfigurationViaDependency.

@Test
public void shouldNotTriggerTheSameBuildConfigurationViaDependency() throws Exception {
    coordinator.start();
    buildRecordRepository.clear();
    // given
    BuildConfiguration configurationA = config("configurationA");
    BuildConfiguration configurationB = config("configurationB");
    configurationA.addDependency(configurationB);
    BuildOptions buildOptions = new BuildOptions();
    // when
    coordinator.build(configurationB, user, buildOptions);
    Thread.sleep(50);
    coordinator.build(configurationA, user, buildOptions);
    // then
    waitForEmptyBuildQueue();
    Assert.assertEquals("There should be 2 build records.", 2, buildRecordRepository.queryAll().size());
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildOptions(org.jboss.pnc.spi.BuildOptions) Test(org.junit.Test)

Example 14 with BuildConfiguration

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

the class WaitForDependencyBuildTest method shouldNotStartParentBuildWhenDependencyIsRunning.

@Test
public void shouldNotStartParentBuildWhenDependencyIsRunning() throws CoreException, TimeoutException, InterruptedException {
    // start dependency
    build(configDependency);
    Wait.forCondition(() -> buildScheduler.isBuilding(configDependency.getId()), 3, ChronoUnit.SECONDS);
    // start parent while dependency is running
    build(configParent);
    // parent should wait for dependency to complete
    BuildTask parentBuildTask = getSubmittedBuildTaskByConfigurationId(configParent.getId()).get();
    assertThat(parentBuildTask.getStatus()).isEqualTo(BuildCoordinationStatus.WAITING_FOR_DEPENDENCIES);
    // complete the dependency
    BuildTask dependencyBuildTask = getScheduledBuildTaskByConfigurationId(configDependency.getId()).get();
    buildScheduler.completeBuild(dependencyBuildTask.getId());
    // check if parent has started
    Wait.forCondition(() -> buildScheduler.isBuilding(parentBuildTask.getBuildConfigurationAudited().getId()), 3, ChronoUnit.SECONDS);
    buildScheduler.completeBuild(parentBuildTask.getId());
    waitForEmptyBuildQueue();
    List<BuildConfiguration> configsWithTasks = getBuiltConfigs();
    assertThat(configsWithTasks).isEmpty();
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) Test(org.junit.Test)

Example 15 with BuildConfiguration

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

the class BuildExecutionTest method buildShouldFail.

@Test
public void buildShouldFail() throws ExecutorException, TimeoutException, InterruptedException, BuildDriverException {
    BuildConfiguration buildConfiguration = configurationBuilder.buildFailingConfiguration(2, "failed-build", null);
    Set<BuildExecutionStatusChangedEvent> statusChangedEvents = new HashSet<>();
    ObjectWrapper<BuildResult> buildExecutionResultWrapper = new ObjectWrapper<>();
    runBuild(buildConfiguration, statusChangedEvents, buildExecutionResultWrapper);
    List<BuildExecutionStatus> expectedStatuses = getBuildExecutionStatusesBase();
    expectedStatuses.add(DONE_WITH_ERRORS);
    // check build statuses
    checkBuildStatuses(statusChangedEvents, expectedStatuses);
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildResult(org.jboss.pnc.spi.BuildResult) ObjectWrapper(org.jboss.pnc.common.util.ObjectWrapper) BuildExecutionStatus(org.jboss.pnc.enums.BuildExecutionStatus) BuildExecutionStatusChangedEvent(org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)65 Test (org.junit.Test)23 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)11 HashSet (java.util.HashSet)10 BuildRecord (org.jboss.pnc.model.BuildRecord)9 Project (org.jboss.pnc.model.Project)9 BuildOptions (org.jboss.pnc.spi.BuildOptions)9 BuildResult (org.jboss.pnc.spi.BuildResult)9 Logger (org.slf4j.Logger)9 LoggerFactory (org.slf4j.LoggerFactory)9 List (java.util.List)8 Set (java.util.Set)8 Inject (javax.inject.Inject)8 ObjectWrapper (org.jboss.pnc.common.util.ObjectWrapper)8 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)8 BuildExecutionStatusChangedEvent (org.jboss.pnc.spi.events.BuildExecutionStatusChangedEvent)8 IdRev (org.jboss.pnc.model.IdRev)7 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)7 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)7 Collectors (java.util.stream.Collectors)5