Search in sources :

Example 11 with BuildStatus

use of org.jboss.pnc.enums.BuildStatus in project pnc by project-ncl.

the class DatastoreAdapterTest method shouldStoreRepositoryManagerSuccessResult.

@Test
public void shouldStoreRepositoryManagerSuccessResult() throws DatastoreException {
    // given
    DatastoreMock datastore = new DatastoreMock();
    DatastoreAdapter datastoreAdapter = new DatastoreAdapter(datastore);
    BuildStatus buildStatus = BuildStatus.SUCCESS;
    CompletionStatus completionStatus = CompletionStatus.SUCCESS;
    // when
    storeResult(datastoreAdapter, buildStatus, completionStatus);
    // then
    List<BuildRecord> buildRecords = datastore.getBuildRecords();
    Assert.assertEquals(1, buildRecords.size());
    BuildRecord buildRecord = buildRecords.get(0);
    Assert.assertEquals(buildRecord.getStatus(), BuildStatus.SUCCESS);
    Assert.assertTrue(buildRecord.getBuildLog().contains(BUILD_LOG));
    Assert.assertTrue(buildRecord.getBuildLog().contains(REPOSITORY_MANAGER_LOG));
}
Also used : CompletionStatus(org.jboss.pnc.spi.coordinator.CompletionStatus) DatastoreMock(org.jboss.pnc.mock.datastore.DatastoreMock) BuildStatus(org.jboss.pnc.enums.BuildStatus) DatastoreAdapter(org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter) BuildRecord(org.jboss.pnc.model.BuildRecord) Test(org.junit.Test)

Example 12 with BuildStatus

use of org.jboss.pnc.enums.BuildStatus in project pnc by project-ncl.

the class BuildTest method shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems.

@Test
public void shouldTriggerGroupBuildWithBCInRevisionAndFinishWithoutProblems() throws ClientException {
    // given
    GroupConfiguration groupConfiguration = groupConfigurationClient.getAll().iterator().next();
    assertThat(groupConfiguration.getBuildConfigs()).isNotEmpty();
    List<BuildConfigurationRevisionRef> buildConfigurationRevisions = new ArrayList<>();
    BuildConfigurationRevision buildConfigurationRevision = BuildConfigurationRevision.builder().id(groupConfiguration.getBuildConfigs().keySet().iterator().next()).rev(1).name(groupConfiguration.getName()).build();
    buildConfigurationRevisions.add(buildConfigurationRevision);
    GroupBuildRequest groupConfigWithAuditedBCsRest = GroupBuildRequest.builder().buildConfigurationRevisions(buildConfigurationRevisions).build();
    GroupBuildParameters groupBuildParameters = new GroupBuildParameters();
    groupBuildParameters.setRebuildMode(RebuildMode.FORCE);
    // when
    GroupBuild groupBuild = groupConfigurationClient.trigger(groupConfiguration.getId(), groupBuildParameters, groupConfigWithAuditedBCsRest);
    // then
    assertThat(groupBuild).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED);
    ResponseUtils.waitSynchronouslyFor(() -> groupBuildToFinish(groupBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
Also used : GroupBuildRequest(org.jboss.pnc.dto.requests.GroupBuildRequest) GroupBuild(org.jboss.pnc.dto.GroupBuild) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) ArrayList(java.util.ArrayList) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildStatus(org.jboss.pnc.enums.BuildStatus) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 13 with BuildStatus

use of org.jboss.pnc.enums.BuildStatus in project pnc by project-ncl.

the class BuildTest method shouldNotTriggerANewPersistentBuildWithoutForceIfOnlyDescriptionChanged.

@Test
public void shouldNotTriggerANewPersistentBuildWithoutForceIfOnlyDescriptionChanged() throws ClientException {
    BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==maven-plugin-test")).iterator().next();
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED, BuildStatus.NO_REBUILD_REQUIRED);
    // Build persistent builds (parent and dependency) on new revision
    Build persistentBuild = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters(true));
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(persistentBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Updating the description only won't create a new revision, as description is not audited anymore
    Instant oldLastModDate = buildConfiguration.getModificationTime();
    BuildConfiguration updatedConfiguration = buildConfiguration.toBuilder().description("Random Description to be able to trigger build again so that persistent build will be first on this revision").build();
    buildConfigurationClient.update(updatedConfiguration.getId(), updatedConfiguration);
    assertThat(oldLastModDate).isEqualTo(updatedConfiguration.getModificationTime());
    Build build2 = buildConfigurationClient.trigger(updatedConfiguration.getId(), getPersistentParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build2.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), null), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) Instant(java.time.Instant) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 14 with BuildStatus

use of org.jboss.pnc.enums.BuildStatus in project pnc by project-ncl.

the class BuildTest method shouldNotTriggerANewTemporaryBuildWithoutForceIfOnlyDescriptionChanged.

@Test
public void shouldNotTriggerANewTemporaryBuildWithoutForceIfOnlyDescriptionChanged() throws ClientException {
    BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==maven-plugin-test")).iterator().next();
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED, BuildStatus.NO_REBUILD_REQUIRED);
    // Build temporary builds (parent and dependency) on new revision
    Build persistentBuild = buildConfigurationClient.trigger(buildConfiguration.getId(), getTemporaryParameters(true));
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(persistentBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Updating the description only won't create a new revision, as description is not audited anymore
    Instant oldLastModDate = buildConfiguration.getModificationTime();
    BuildConfiguration updatedConfiguration = buildConfiguration.toBuilder().description("Random Description to be able to trigger build again so that temporary build will be first on this revision").build();
    buildConfigurationClient.update(updatedConfiguration.getId(), updatedConfiguration);
    assertThat(oldLastModDate).isEqualTo(updatedConfiguration.getModificationTime());
    Build build2 = buildConfigurationClient.trigger(updatedConfiguration.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build2.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), null), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) Instant(java.time.Instant) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 15 with BuildStatus

use of org.jboss.pnc.enums.BuildStatus in project pnc by project-ncl.

the class BuildTest method shouldTriggerPersistentWithoutForceAfterTemporaryOnTheSameRev.

@Test
public void shouldTriggerPersistentWithoutForceAfterTemporaryOnTheSameRev() throws ClientException {
    BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==maven-plugin-test")).iterator().next();
    // Updating the description only won't create a new revision, as description is not audited anymore
    Instant oldLastModDate = buildConfiguration.getModificationTime();
    BuildConfiguration updatedConfiguration = buildConfiguration.toBuilder().description("Random Description to be able to trigger build again so that temporary build will be first on this revision").buildScript("mvn" + " clean deploy -DskipTests=true").build();
    buildConfigurationClient.update(updatedConfiguration.getId(), updatedConfiguration);
    updatedConfiguration = buildConfigurationClient.getSpecific(updatedConfiguration.getId());
    assertThat(oldLastModDate).isNotEqualTo(updatedConfiguration.getModificationTime());
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED, BuildStatus.NO_REBUILD_REQUIRED);
    Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    Build afterTempPersistentBuild = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(afterTempPersistentBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) Instant(java.time.Instant) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildStatus (org.jboss.pnc.enums.BuildStatus)20 Test (org.junit.Test)14 GroupBuild (org.jboss.pnc.dto.GroupBuild)10 ContainerTest (org.jboss.pnc.test.category.ContainerTest)10 Build (org.jboss.pnc.dto.Build)9 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)7 Instant (java.time.Instant)4 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)3 DatastoreMock (org.jboss.pnc.mock.datastore.DatastoreMock)3 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)3 BuildDriverResult (org.jboss.pnc.spi.builddriver.BuildDriverResult)3 Consumer (java.util.function.Consumer)2 DatastoreAdapter (org.jboss.pnc.coordinator.builder.datastore.DatastoreAdapter)2 BuildCoordinationStatus (org.jboss.pnc.enums.BuildCoordinationStatus)2 TestProjectConfigurationBuilder (org.jboss.pnc.mock.model.builders.TestProjectConfigurationBuilder)2 BuildRecord (org.jboss.pnc.model.BuildRecord)2 CompletionStatus (org.jboss.pnc.spi.coordinator.CompletionStatus)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 ArrayList (java.util.ArrayList)1