Search in sources :

Example 1 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class BuildCoordinationTest method buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess.

@Test
public void buildConfigSetRecordShouldBeMarkedSuccessWhenAllBuildsAreSuccess() throws CoreException, TimeoutException, InterruptedException {
    BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
    testProjectConfigurationBuilder.buildConfigurationWithDependencies(buildConfigurationSet);
    ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
    Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
    // check the result
    Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
    Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
    assertThat(maybeSetRecord.isPresent()).isTrue();
    Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
    assertEmptyQueue();
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Example 2 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class BuildCoordinationTest method shouldBuildSetWithOneConfiguration.

@Test
public void shouldBuildSetWithOneConfiguration() throws CoreException, TimeoutException, InterruptedException {
    BuildConfigurationSet buildConfigurationSet = TestEntitiesFactory.newBuildConfigurationSet();
    testProjectConfigurationBuilder.build(223, "Project-223", buildConfigurationSet);
    ObjectWrapper<BuildSetStatus> lastBuildSetStatus = registerCallback(buildConfigurationSet);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.IMPLICIT_DEPENDENCY_CHECK);
    BuildSetTask buildSetTask = buildCoordinator.build(buildConfigurationSet, TestEntitiesFactory.newUser(), buildOptions);
    Wait.forCondition(lastBuildSetStatus::isSet, 5, ChronoUnit.SECONDS);
    // check the result
    Assert.assertEquals(BuildSetStatus.DONE, lastBuildSetStatus.get());
    Optional<BuildConfigSetRecord> maybeSetRecord = buildSetTask.getBuildConfigSetRecord();
    assertThat(maybeSetRecord.isPresent()).isTrue();
    Assert.assertEquals(BuildStatus.SUCCESS, maybeSetRecord.get().getStatus());
    assertEmptyQueue();
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildSetStatus(org.jboss.pnc.spi.BuildSetStatus) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Example 3 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class ProjectBuilder method buildProject.

BuildTask buildProject(BuildConfiguration buildConfiguration, BuildCoordinator buildCoordinator, Consumer<BuildStatusChangedEvent> onStatusUpdate, BuildOptions buildOptions) throws BuildConflictException, InterruptedException, CoreException {
    log.debug("Building project {}", buildConfiguration.getName());
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    Consumer<BuildStatusChangedEvent> onStatusUpdateInternal = (statusUpdate) -> {
        receivedStatuses.add(statusUpdate);
        onStatusUpdate.accept(statusUpdate);
    };
    // Defines a number of callbacks, which are executed after buildStatus update
    final Semaphore semaphore = registerReleaseListenersAndAcquireSemaphore(onStatusUpdateInternal, N_STATUS_UPDATES_PER_TASK);
    BuildSetTask taskSet = buildCoordinator.build(buildConfiguration, MockUser.newTestUser(1), buildOptions);
    Set<BuildTask> buildTasks = taskSet.getBuildTasks();
    assertThat(buildTasks).hasSize(1);
    BuildTask buildTask = buildTasks.iterator().next();
    log.info("Started build task {}", buildTask);
    assertBuildStartedSuccessfully(buildTask);
    waitForStatusUpdates(N_STATUS_UPDATES_PER_TASK, semaphore, "");
    return buildTask;
}
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) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) Semaphore(java.util.concurrent.Semaphore) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 4 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class ReadDependenciesTest method createBuildSetTask.

public BuildSetTask createBuildSetTask(BuildConfigurationSet buildConfigurationSet, User user) throws CoreException {
    BuildTasksInitializer buildTasksInitializer = new BuildTasksInitializer(datastoreAdapter, 1L);
    AtomicInteger atomicInteger = new AtomicInteger(1);
    BuildOptions buildOptions = new BuildOptions();
    buildOptions.setRebuildMode(RebuildMode.FORCE);
    return buildTasksInitializer.createBuildSetTask(buildConfigurationSet, user, buildOptions, () -> Sequence.nextBase32Id(), buildQueue.getUnfinishedTasks());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BuildOptions(org.jboss.pnc.spi.BuildOptions) BuildTasksInitializer(org.jboss.pnc.coordinator.builder.BuildTasksInitializer)

Example 5 with BuildOptions

use of org.jboss.pnc.spi.BuildOptions in project pnc by project-ncl.

the class DefaultBuildCoordinatorTest method mockBuildTask.

private BuildTask mockBuildTask() {
    BuildConfiguration buildConfiguration = new BuildConfiguration();
    buildConfiguration.setId(12);
    buildConfiguration.setProject(new Project());
    buildConfiguration.setRepositoryConfiguration(RepositoryConfigurationMock.newTestRepository());
    buildConfiguration.setBuildEnvironment(BuildEnvironmentMock.newTest());
    BuildOptions buildOptions = new BuildOptions(false, true, false, false, RebuildMode.IMPLICIT_DEPENDENCY_CHECK, AlignmentPreference.PREFER_PERSISTENT);
    BuildTask buildTask = BuildTask.build(BuildConfigurationAudited.fromBuildConfiguration(buildConfiguration, 13), buildOptions, MockUser.newTestUser(1), "1", null, new Date(), null, "context-id", Optional.empty());
    buildTask.setStatus(BuildCoordinationStatus.DONE);
    return buildTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) Project(org.jboss.pnc.model.Project) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) Date(java.util.Date)

Aggregations

BuildOptions (org.jboss.pnc.spi.BuildOptions)35 Test (org.junit.Test)21 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)11 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)10 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)9 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)9 BuildRecord (org.jboss.pnc.model.BuildRecord)8 BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)5 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)5 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)4 BuildStatus (org.jboss.pnc.enums.BuildStatus)4 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)4 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)4 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)4 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)4 BuildConflictException (org.jboss.pnc.spi.exception.BuildConflictException)4 CoreException (org.jboss.pnc.spi.exception.CoreException)4 Collections (java.util.Collections)3 Date (java.util.Date)3 List (java.util.List)3