Search in sources :

Example 11 with BuildStatusChangedEvent

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

the class ProjectBuilder method buildProjectsAndVerifyResult.

private void buildProjectsAndVerifyResult(BuildConfigurationSet buildConfigurationSet, BuildCoordinator buildCoordinator, int nStatusUpdates, Verifier verifier) throws InterruptedException, CoreException {
    log.info("Building configuration set {}", buildConfigurationSet.getName());
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    List<BuildSetStatusChangedEvent> receivedSetStatuses = new CopyOnWriteArrayList<>();
    BuildSetTask buildSetTask = buildProjectsAndWaitForUpdates(buildConfigurationSet, buildCoordinator, nStatusUpdates, x -> {
    }, receivedStatuses, receivedSetStatuses);
    log.info("Checking if received all status updates...");
    verifier.verify(receivedStatuses, buildSetTask);
}
Also used : BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) BuildSetStatusChangedEvent(org.jboss.pnc.spi.events.BuildSetStatusChangedEvent) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 12 with BuildStatusChangedEvent

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

the class SingleProjectBuildTest method buildWithAdvancedOptionsTest.

@Test
public void buildWithAdvancedOptionsTest() throws Exception {
    // given
    BuildOptions originalBuildOptions = new BuildOptions(true, true, true, true, RebuildMode.FORCE, AlignmentPreference.PREFER_PERSISTENT);
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add, originalBuildOptions);
    // then
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    Assert.assertEquals(originalBuildOptions, buildTask.getBuildOptions());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 13 with BuildStatusChangedEvent

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

the class SingleProjectBuildTest method buildSingleProjectTestCase.

@Test
public void buildSingleProjectTestCase() throws Exception {
    // given
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add);
    // expect
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    String buildLog = buildRecord.getBuildLog();
    Assert.assertTrue("Invalid build log.", buildLog.contains(BuildDriverResultMock.BUILD_LOG));
    assertArtifactsPresent(buildRecord.getBuiltArtifacts());
    assertArtifactsPresent(buildRecord.getDependencies());
    Assert.assertNotNull(buildRecord.getSubmitTime());
    Assert.assertNotNull(buildRecord.getStartTime());
    Assert.assertNotNull(buildRecord.getEndTime());
    receivedStatuses.stream().filter(e -> e.getNewStatus().isFinal()).forEach(e -> Assert.assertNotNull("Final event " + e + " should have end build time.", e.getBuild().getEndTime()));
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildOptions(org.jboss.pnc.spi.BuildOptions) Arquillian(org.jboss.arquillian.junit.Arquillian) BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) RunWith(org.junit.runner.RunWith) AlignmentPreference(org.jboss.pnc.api.enums.AlignmentPreference) Test(org.junit.Test) BuildRecord(org.jboss.pnc.model.BuildRecord) RebuildMode(org.jboss.pnc.enums.RebuildMode) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildDriverResultMock(org.jboss.pnc.mock.builddriver.BuildDriverResultMock) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) Inject(javax.inject.Inject) List(java.util.List) Deployment(org.jboss.arquillian.container.test.api.Deployment) JavaArchive(org.jboss.shrinkwrap.api.spec.JavaArchive) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) Assert(org.junit.Assert) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 14 with BuildStatusChangedEvent

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

the class SingleProjectBuildTest method buildWithBasicOptionsTest.

@Test
public void buildWithBasicOptionsTest() throws Exception {
    // given
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    List<BuildStatusChangedEvent> receivedStatuses = new CopyOnWriteArrayList<>();
    // when
    BuildCoordinator coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock).coordinator;
    BuildTask buildTask = buildProject(configurationBuilder.build(1, "c1-java"), coordinator, receivedStatuses::add);
    // then
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count.", 1, buildRecords.size());
    Assert.assertEquals(new BuildOptions(), buildTask.getBuildOptions());
}
Also used : BuildCoordinator(org.jboss.pnc.spi.coordinator.BuildCoordinator) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildOptions(org.jboss.pnc.spi.BuildOptions) TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Test(org.junit.Test)

Example 15 with BuildStatusChangedEvent

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

the class ProcessProgressNotificationTest method shouldSubscribeToProcessUpdatesNotification.

@Test
public void shouldSubscribeToProcessUpdatesNotification() throws Exception {
    // given
    Integer taskId = 1;
    Build build = BuildMock.newBuild(taskId, BuildStatus.SUCCESS, "Build1");
    BuildStatusChangedEvent buildStatusChangedEvent = new DefaultBuildStatusChangedEvent(build, BuildStatus.NEW, build.getStatus());
    // when
    buildStatusNotificationEvent.fire(buildStatusChangedEvent);
    ProgressUpdatesRequest progressUpdatesRequest = new ProgressUpdatesRequest(Action.SUBSCRIBE, "component-build", taskId.toString());
    String text = JsonOutputConverterMapper.apply(new TypedMessage<>(MessageType.PROCESS_UPDATES, progressUpdatesRequest));
    logger.info("Sending test message:" + text);
    asyncRemote.sendText(text);
    waitForMessages(1);
    // then
    logger.info("Received: " + notificationCollector.getMessages().get(0));
    assertTrue(notificationCollector.getMessages().get(0).startsWith("{\"oldStatus\":\"NEW\",\"build\":{\"id\":\"1\",\"submitTime\":null,\"startTime\":null,\"endTime\":null,\"progress\":null,\"status\":\"SUCCESS\","));
}
Also used : Build(org.jboss.pnc.dto.Build) DefaultBuildStatusChangedEvent(org.jboss.pnc.spi.coordinator.events.DefaultBuildStatusChangedEvent) BuildStatusChangedEvent(org.jboss.pnc.spi.events.BuildStatusChangedEvent) DefaultBuildStatusChangedEvent(org.jboss.pnc.spi.coordinator.events.DefaultBuildStatusChangedEvent) ProgressUpdatesRequest(org.jboss.pnc.notification.ProgressUpdatesRequest) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)17 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)9 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)9 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)9 Test (org.junit.Test)9 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)8 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)7 BuildOptions (org.jboss.pnc.spi.BuildOptions)7 Inject (javax.inject.Inject)6 BuildStatus (org.jboss.pnc.enums.BuildStatus)6 BuildRecord (org.jboss.pnc.model.BuildRecord)6 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 List (java.util.List)5 Consumer (java.util.function.Consumer)5 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)5 CoreException (org.jboss.pnc.spi.exception.CoreException)5 Set (java.util.Set)4 Deployment (org.jboss.arquillian.container.test.api.Deployment)4