Search in sources :

Example 16 with BuildConfigurationSet

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

the class ProjectBuilder method buildProjectsAndWaitForUpdates.

private BuildSetTask buildProjectsAndWaitForUpdates(BuildConfigurationSet buildConfigurationSet, BuildCoordinator buildCoordinator, int nStatusUpdates, Consumer<BuildStatusChangedEvent> onStatusUpdate, List<BuildStatusChangedEvent> receivedStatuses, List<BuildSetStatusChangedEvent> receivedSetStatuses) throws InterruptedException, CoreException {
    Consumer<BuildStatusChangedEvent> onStatusUpdateInternal = (statusUpdate) -> {
        log.debug("Received status change event [" + (i++) + "]: {}.", statusUpdate);
        receivedStatuses.add(statusUpdate);
        onStatusUpdate.accept(statusUpdate);
    };
    final Semaphore semaphore = registerReleaseListenersAndAcquireSemaphore(onStatusUpdateInternal, nStatusUpdates);
    final Semaphore buildSetSemaphore = registerBuildSetListeners(receivedSetStatuses, BUILD_SET_STATUS_UPDATES);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, MockUser.newTestUser(1), buildOptions);
    assertBuildStartedSuccessfully(buildSetTask);
    log.info("Waiting to receive all {} status updates...", nStatusUpdates);
    waitForStatusUpdates(nStatusUpdates, semaphore, "");
    log.debug("All status updates should be received. Semaphore has {} free entries.", semaphore.availablePermits());
    log.info("Waiting to receive all {} build set status updates...", BUILD_SET_STATUS_UPDATES);
    waitForStatusUpdates(BUILD_SET_STATUS_UPDATES, buildSetSemaphore, "build set task: " + buildSetTask);
    log.debug("All status updates should be received. Semaphore has {} free entries.", semaphore.availablePermits());
    return buildSetTask;
}
Also used : BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Arrays(java.util.Arrays) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildCoordinationStatus(org.jboss.pnc.enums.BuildCoordinationStatus) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) LoggerFactory(org.slf4j.LoggerFactory) BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) RebuildMode(org.jboss.pnc.enums.RebuildMode) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) Inject(javax.inject.Inject) TestCDIBuildSetStatusChangedReceiver(org.jboss.pnc.coordinator.test.event.TestCDIBuildSetStatusChangedReceiver) Assert.fail(org.junit.Assert.fail) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConflictException(org.jboss.pnc.spi.exception.BuildConflictException) Before(org.junit.Before) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) TestCDIBuildStatusChangedReceiver(org.jboss.pnc.coordinator.test.event.TestCDIBuildStatusChangedReceiver) Artifact(org.jboss.pnc.model.Artifact) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) DatastoreException(org.jboss.pnc.spi.datastore.DatastoreException) Set(java.util.Set) Assert.assertTrue(org.junit.Assert.assertTrue) BuildStatus(org.jboss.pnc.enums.BuildStatus) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) List(java.util.List) MockUser(org.jboss.pnc.mock.model.MockUser) CoreException(org.jboss.pnc.spi.exception.CoreException) Dependent(javax.enterprise.context.Dependent) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) ArtifactBuilder(org.jboss.pnc.mock.model.builders.ArtifactBuilder) Collections(java.util.Collections) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) Semaphore(java.util.concurrent.Semaphore)

Example 17 with BuildConfigurationSet

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

the class ReadDependenciesTest method createDependenciesTestCase.

@Test
public void createDependenciesTestCase() throws DatastoreException {
    BuildConfigurationSet buildConfigurationSet = configurationBuilder.buildConfigurationSet(1);
    User user = User.Builder.newBuilder().id(1).username("test-user").build();
    BuildSetTask buildSetTask = null;
    try {
        buildSetTask = createBuildSetTask(buildConfigurationSet, user);
    } catch (CoreException e) {
        Assert.fail(e.getMessage());
    }
    Assert.assertEquals("Missing build tasks in set.", 5, buildSetTask.getBuildTasks().size());
    BuildTask buildTask2 = buildSetTask.getBuildTasks().stream().filter(task -> task.getBuildConfigurationAudited().getId().equals(2)).findFirst().get();
    Assert.assertEquals("Wrong number of dependencies.", 2, buildTask2.getDependencies().size());
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) User(org.jboss.pnc.model.User) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) CoreException(org.jboss.pnc.spi.exception.CoreException) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) Test(org.junit.Test)

Example 18 with BuildConfigurationSet

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

the class TestProjectConfigurationBuilder method buildConfigurationSetWithCycleDependency.

public BuildConfigurationSet buildConfigurationSetWithCycleDependency() {
    BuildConfigurationSet buildConfigurationSet = new BuildConfigurationSet();
    buildConfigurationSet.setName("test-cycle");
    buildConfigurationWithCycleDependency(buildConfigurationSet);
    return buildConfigurationSet;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Example 19 with BuildConfigurationSet

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

the class TestProjectConfigurationBuilder method buildConfigurationSetWithFailedDependenciesAndDelay.

public BuildConfigurationSet buildConfigurationSetWithFailedDependenciesAndDelay(Integer configurationSetId) {
    BuildConfigurationSet buildConfigurationSet = new BuildConfigurationSet();
    buildConfigurationSet.setName("test-build-configuration-failed-deps");
    buildConfigurationSet.setId(configurationSetId);
    buildConfigurationWithTransitiveDependenciesThatFail(buildConfigurationSet);
    return buildConfigurationSet;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Example 20 with BuildConfigurationSet

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

the class TestProjectConfigurationBuilder method buildConfigurationSet.

public BuildConfigurationSet buildConfigurationSet(Integer configurationSetId) {
    BuildConfigurationSet buildConfigurationSet = new BuildConfigurationSet();
    buildConfigurationSet.setName("test-build-configuration");
    buildConfigurationSet.setId(configurationSetId);
    buildConfigurationWithDependencies(buildConfigurationSet);
    return buildConfigurationSet;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet)

Aggregations

BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)29 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)11 Test (org.junit.Test)11 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)8 BuildOptions (org.jboss.pnc.spi.BuildOptions)8 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 CoreException (org.jboss.pnc.spi.exception.CoreException)5 Inject (javax.inject.Inject)4 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Set (java.util.Set)3 Consumer (java.util.function.Consumer)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 BuildSetStatusChangedEvent (org.jboss.pnc.spi.events.BuildSetStatusChangedEvent)3 ArrayList (java.util.ArrayList)2