Search in sources :

Example 1 with BuildConfigSetRecord

use of org.jboss.pnc.model.BuildConfigSetRecord 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 BuildConfigSetRecord

use of org.jboss.pnc.model.BuildConfigSetRecord 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 BuildConfigSetRecord

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

the class ProjectWithDependenciesBuildTest method buildProjectTestCase.

@Test
public void buildProjectTestCase() throws Exception {
    clearSemaphores();
    // given
    testCDIBuildSetStatusChangedReceiver.addBuildSetStatusChangedEventListener(this::collectEvent);
    DatastoreMock datastoreMock = new DatastoreMock();
    TestProjectConfigurationBuilder configurationBuilder = new TestProjectConfigurationBuilder(datastoreMock);
    // when
    BuildCoordinatorBeans coordinator = buildCoordinatorFactory.createBuildCoordinator(datastoreMock);
    buildProjects(configurationBuilder.buildConfigurationSet(BUILD_SET_ID), coordinator.coordinator);
    // expect
    List<BuildRecord> buildRecords = datastoreMock.getBuildRecords();
    log.trace("Found build records: {}", buildRecords.stream().map(br -> "Br.id: " + br.getId() + ", " + br.getBuildConfigurationAudited().getId().toString()).collect(Collectors.joining("; ")));
    Assert.assertEquals("Wrong datastore results count.", 5, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    String buildLog = buildRecord.getBuildLog();
    Assert.assertTrue("Invalid build log.", buildLog.contains("Finished: SUCCESS"));
    assertArtifactsPresent(buildRecord.getBuiltArtifacts());
    assertArtifactsPresent(buildRecord.getDependencies());
    BuildConfigSetRecord buildConfigSetRecord = datastoreMock.getBuildConfigSetRecords().get(0);
    Assert.assertNotNull("End time not set! Record: " + buildConfigSetRecord, buildConfigSetRecord.getEndTime());
    Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
    Assert.assertEquals(BuildStatus.SUCCESS, buildConfigSetRecord.getStatus());
    String events = eventsReceived.stream().map(Object::toString).collect(Collectors.joining("; "));
    Assert.assertEquals("Invalid number of received events. Received events: " + events, 2, eventsReceived.size());
    Wait.forCondition(coordinator.queue::isEmpty, 1, ChronoUnit.SECONDS, "Not empty build queue: " + coordinator.queue);
}
Also used : TestProjectConfigurationBuilder(org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildRecord(org.jboss.pnc.model.BuildRecord) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test)

Example 4 with BuildConfigSetRecord

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

the class ProjectWithFailedDependenciesBuildTest method checkDatabaseForResult.

@Test
@InSequence(20)
public void checkDatabaseForResult() {
    List<BuildRecord> buildRecords = datastore.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count. Got records: " + buildRecords, 2, buildRecords.size());
    Assert.assertEquals(BuildStatus.FAILED, buildRecords.get(0).getStatus());
    Assert.assertEquals(BuildStatus.REJECTED_FAILED_DEPENDENCIES, buildRecords.get(1).getStatus());
    BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecords().get(0);
    Assert.assertNotNull("End time is null.", buildConfigSetRecord.getEndTime());
    Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
    Assert.assertEquals(BuildStatus.FAILED, buildConfigSetRecord.getStatus());
}
Also used : BuildRecord(org.jboss.pnc.model.BuildRecord) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 5 with BuildConfigSetRecord

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

the class ProjectWithFailedTransitiveDependenciesBuildTest method checkDatabaseForResult.

@Test
@InSequence(20)
public void checkDatabaseForResult() {
    List<BuildRecord> buildRecords = datastore.getBuildRecords();
    Assert.assertEquals("Wrong datastore results count. Got records: " + buildRecords, 3, buildRecords.size());
    Assert.assertEquals(BuildStatus.FAILED, buildRecords.get(0).getStatus());
    Assert.assertEquals(BuildStatus.REJECTED_FAILED_DEPENDENCIES, buildRecords.get(1).getStatus());
    BuildConfigSetRecord buildConfigSetRecord = datastore.getBuildConfigSetRecords().get(0);
    Assert.assertNotNull("End time is null.", buildConfigSetRecord.getEndTime());
    Assert.assertTrue(buildConfigSetRecord.getEndTime().getTime() > buildConfigSetRecord.getStartTime().getTime());
    Assert.assertEquals(BuildStatus.FAILED, buildConfigSetRecord.getStatus());
    Assert.assertTrue("Build queue should be empty.", buildQueue.isEmpty());
}
Also used : BuildRecord(org.jboss.pnc.model.BuildRecord) BuildConfigSetRecord(org.jboss.pnc.model.BuildConfigSetRecord) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

BuildConfigSetRecord (org.jboss.pnc.model.BuildConfigSetRecord)23 Test (org.junit.Test)10 BuildRecord (org.jboss.pnc.model.BuildRecord)9 BuildOptions (org.jboss.pnc.spi.BuildOptions)8 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)7 BuildSetStatus (org.jboss.pnc.spi.BuildSetStatus)7 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)7 HashSet (java.util.HashSet)6 User (org.jboss.pnc.model.User)6 DatastoreException (org.jboss.pnc.spi.datastore.DatastoreException)6 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)5 CoreException (org.jboss.pnc.spi.exception.CoreException)5 Optional (java.util.Optional)4 Set (java.util.Set)4 DatastoreAdapter (org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Collections (java.util.Collections)3 Date (java.util.Date)3 Event (javax.enterprise.event.Event)3