Search in sources :

Example 41 with Build

use of org.jboss.pnc.dto.Build 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 42 with Build

use of org.jboss.pnc.dto.Build 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 43 with Build

use of org.jboss.pnc.dto.Build 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)

Example 44 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildTest method dontRebuildTemporaryBuildWhenThereIsNewerPersistentOnSameRev.

// NCL-5192
// Replicates NCL-5192 through explicit dependency instead of implicit
@Test
public void dontRebuildTemporaryBuildWhenThereIsNewerPersistentOnSameRev() throws ClientException {
    BuildConfiguration parent = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-build-agent-0.4")).iterator().next();
    BuildConfiguration dependency = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==termd")).iterator().next();
    Instant oldLastModDateParent = parent.getModificationTime();
    BuildConfiguration updatedParent = parent.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(updatedParent.getId(), updatedParent);
    updatedParent = buildConfigurationClient.getSpecific(updatedParent.getId());
    assertThat(oldLastModDateParent).isNotEqualTo(updatedParent.getModificationTime());
    Instant oldLastModDateDependency = parent.getModificationTime();
    BuildConfiguration updatedDependency = dependency.toBuilder().description("Random Description so it rebuilds").buildScript("mvn" + "   clean deploy -DskipTests=true").build();
    buildConfigurationClient.update(updatedDependency.getId(), updatedDependency);
    assertThat(oldLastModDateDependency).isNotEqualTo(updatedDependency.getModificationTime());
    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 temporaryBuild = buildConfigurationClient.trigger(parent.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(temporaryBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Build persistent build of dependency on the same revision
    Build dependencyPersistentBuild = buildConfigurationClient.trigger(dependency.getId(), getPersistentParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(dependencyPersistentBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Build temporary build of parent and check it gets REJECTED even if it's dependency has newer record
    // (in this case temp build should ignore persistent one)
    Build finalRecord = buildConfigurationClient.trigger(parent.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(finalRecord.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 45 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class ProductMilestoneEndpointTest method testGetBuilds.

@Test
public void testGetBuilds() throws ClientException {
    ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Build> all = client.getBuilds(milestoneId, null);
    assertThat(all).hasSize(1);
}
Also used : ProductMilestoneClient(org.jboss.pnc.client.ProductMilestoneClient) Build(org.jboss.pnc.dto.Build) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

Build (org.jboss.pnc.dto.Build)71 Test (org.junit.Test)52 ContainerTest (org.jboss.pnc.test.category.ContainerTest)35 BuildClient (org.jboss.pnc.client.BuildClient)20 BuildRecord (org.jboss.pnc.model.BuildRecord)18 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)16 BuildStatus (org.jboss.pnc.enums.BuildStatus)15 GroupBuild (org.jboss.pnc.dto.GroupBuild)14 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)14 ArrayList (java.util.ArrayList)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)11 HashSet (java.util.HashSet)10 List (java.util.List)10 Set (java.util.Set)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Date (java.util.Date)9 Page (org.jboss.pnc.dto.response.Page)9 BuildMapper (org.jboss.pnc.mapper.api.BuildMapper)9 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)9