Search in sources :

Example 1 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask 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 BuildTask

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

the class ProjectBuilder method buildProject.

void buildProject(BuildConfiguration buildConfiguration, BuildCoordinator buildCoordinator) throws BuildConflictException, InterruptedException, CoreException {
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    BuildTask buildTask = buildProject(buildConfiguration, buildCoordinator, receivedStatuses::add);
    assertAllStatusUpdateReceived(receivedStatuses, buildTask.getId());
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 3 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask 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 BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask 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 5 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask 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

BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)43 Test (org.junit.Test)23 BuildRecord (org.jboss.pnc.model.BuildRecord)15 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)15 Build (org.jboss.pnc.dto.Build)13 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)13 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)13 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)12 BuildOptions (org.jboss.pnc.spi.BuildOptions)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Inject (javax.inject.Inject)11 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)11 CoreException (org.jboss.pnc.spi.exception.CoreException)11 User (org.jboss.pnc.model.User)10 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)10 Date (java.util.Date)9 Set (java.util.Set)9 HashSet (java.util.HashSet)8 List (java.util.List)8