use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class TemporaryBuildsCleanerTest method shouldNotReturnWithNewNoRebuildRecord.
@Test
public void shouldNotReturnWithNewNoRebuildRecord() throws Exception {
// given
BuildRecord tempBr = initBuildRecordBuilder().submitTime(Date.from(Instant.now().minus(2, ChronoUnit.DAYS))).endTime(Date.from(Instant.now().minus(2, ChronoUnit.DAYS))).temporaryBuild(true).build();
tempBr = buildRecordRepository.save(tempBr);
BuildRecord tempNRRBr = initBuildRecordBuilder().status(BuildStatus.NO_REBUILD_REQUIRED).noRebuildCause(tempBr).temporaryBuild(true).build();
tempNRRBr = buildRecordRepository.save(tempNRRBr);
// when
Page<Build> builds = buildProvider.getAllIndependentTemporaryOlderThanTimestamp(0, 50, null, null, Date.from(Instant.now().minus(1, ChronoUnit.DAYS)).getTime());
// then
assertThat(builds.getContent()).extracting("id", String.class).doesNotContain(BuildMapper.idMapper.toDto(tempBr.getId()), BuildMapper.idMapper.toDto(tempNRRBr.getId()));
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class TemporaryBuildsCleanerTest method shouldReturnOnlyTopLevelTemporaryBuilds.
@Test
public void shouldReturnOnlyTopLevelTemporaryBuilds() throws Exception {
// with
// top level BR1
BuildRecord br1 = initBuildRecordBuilder().temporaryBuild(true).build();
br1 = buildRecordRepository.save(br1);
Artifact art1br1 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br1).build();
Artifact art2br1 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br1).build();
artifactRepository.save(art1br1);
artifactRepository.save(art2br1);
Set<Artifact> depArtBr2 = new HashSet<>();
// independent BR2
BuildRecord br2 = initBuildRecordBuilder().temporaryBuild(true).dependencies(depArtBr2).build();
br2 = buildRecordRepository.save(br2);
Artifact art1br2 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br2).build();
Artifact art2br2 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br2).build();
artifactRepository.save(art1br2);
artifactRepository.save(art2br2);
Set<Artifact> depArtBr3 = new HashSet<>();
depArtBr3.add(art1br1);
depArtBr3.add(art1br2);
// create implicitly dependent BR3 (BR3 is dependent on BR1)
BuildRecord br3 = initBuildRecordBuilder().temporaryBuild(true).dependencies(depArtBr3).build();
br3 = buildRecordRepository.save(br3);
Artifact art1br3 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br3).build();
Artifact art2br3 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br3).build();
artifactRepository.save(art1br3);
artifactRepository.save(art2br3);
Set<Artifact> depArtBr4 = new HashSet<>();
depArtBr4.add(art2br2);
depArtBr4.add(art1br3);
// create implicitly dependent BR4 (BR4 is dependent on BR2 and BR3)
BuildRecord br4 = initBuildRecordBuilder().temporaryBuild(true).dependencies(depArtBr4).build();
br4 = buildRecordRepository.save(br4);
Artifact art1br4 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br4).build();
Artifact art2br4 = initArtifactBuilder().artifactQuality(ArtifactQuality.TEMPORARY).buildRecord(br4).build();
artifactRepository.save(art1br4);
artifactRepository.save(art2br4);
BuildRecord finalBr1 = br1;
Condition<Build> hasBr1 = new Condition<>((build -> build.getId().equals(BuildMapper.idMapper.toDto(finalBr1.getId()))), "Is Br1 with id " + BuildMapper.idMapper.toDto(finalBr1.getId()));
BuildRecord finalBr2 = br2;
Condition<Build> hasBr2 = new Condition<>((build -> build.getId().equals(BuildMapper.idMapper.toDto(finalBr2.getId()))), "Is Br2 with id " + BuildMapper.idMapper.toDto(finalBr2.getId()));
BuildRecord finalBr3 = br3;
Condition<Build> hasBr3 = new Condition<>((build -> build.getId().equals(BuildMapper.idMapper.toDto(finalBr3.getId()))), "Is Br3 with id " + BuildMapper.idMapper.toDto(finalBr3.getId()));
BuildRecord finalBr4 = br4;
Condition<Build> hasBr4 = new Condition<>((build -> build.getId().equals(BuildMapper.idMapper.toDto(finalBr4.getId()))), "Is Br4 with id " + BuildMapper.idMapper.toDto(finalBr4.getId()));
// when #1
Page<Build> builds = buildProvider.getAllIndependentTemporaryOlderThanTimestamp(0, 50, null, null, new Date().getTime());
// then #1
assertThat(builds.getContent()).doNotHave(hasBr1).doNotHave(hasBr2).doNotHave(hasBr3).haveExactly(1, hasBr4);
// when #2
temporaryBuildsCleaner.deleteTemporaryBuild(br4.getId(), "");
builds = buildProvider.getAllIndependentTemporaryOlderThanTimestamp(0, 50, null, null, new Date().getTime());
// then #2
assertThat(builds.getContent()).doNotHave(hasBr1).doNotHave(hasBr2).haveExactly(1, hasBr3).doNotHave(hasBr4);
// when #3
temporaryBuildsCleaner.deleteTemporaryBuild(br3.getId(), "");
builds = buildProvider.getAllIndependentTemporaryOlderThanTimestamp(0, 50, null, null, new Date().getTime());
// then #3
assertThat(builds.getContent()).haveExactly(1, hasBr1).haveExactly(1, hasBr2).doNotHave(hasBr3).doNotHave(hasBr4);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method shouldTriggerBuildWithADependencyAndFinishWithoutProblems.
@Test
public void shouldTriggerBuildWithADependencyAndFinishWithoutProblems() throws ClientException {
// given - A BC with a dependency on pnc-1.0.0.DR1
BuildConfiguration buildConfigurationParent = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==dependency-analysis-1.3")).iterator().next();
// Update dependency
BuildConfiguration buildConfigurationChild = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-1.0.0.DR1")).iterator().next();
BuildConfiguration updatedBuildConfigurationChild = buildConfigurationChild.toBuilder().description(buildConfigurationChild.getDescription() + ".").build();
buildConfigurationClient.update(buildConfigurationChild.getId(), updatedBuildConfigurationChild);
// The update of the description should not have changed the lastModificationDate
assertThat(buildConfigurationChild.getModificationTime()).isEqualTo(updatedBuildConfigurationChild.getModificationTime());
// when
Build build = buildConfigurationClient.trigger(buildConfigurationParent.getId(), getBuildParameters(false, true));
BuildsFilterParameters parameters = new BuildsFilterParameters();
parameters.setRunning(true);
RemoteCollection<Build> childBuildCol = buildConfigurationClient.getBuilds(buildConfigurationChild.getId(), parameters);
Build childBuild = childBuildCol.getAll().iterator().next();
// then
assertThat(childBuildCol.size()).isEqualTo(1);
assertThat(buildConfigurationParent.getDependencies().size()).isEqualTo(1);
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(childBuild.getId(), isIn, null), 15, TimeUnit.SECONDS);
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method shouldHaveNoRebuildCauseFilled.
@Test
public void shouldHaveNoRebuildCauseFilled() throws Exception {
// with
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll().iterator().next();
// when #1
Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters(true));
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
// when #2
EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.SUCCESS, BuildStatus.FAILED);
Build rebuild = buildConfigurationClient.trigger(buildConfiguration.getId(), getBuildParameters(false, false));
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(rebuild.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), isNotIn), 15, TimeUnit.SECONDS);
// then
Build refresh = buildClient.getSpecific(rebuild.getId());
assertThat(refresh.getNoRebuildCause()).isNotNull().extracting("id").isEqualTo(build.getId());
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildTest method shouldTriggerBuildAndFinishWithoutProblems.
@Test
public void shouldTriggerBuildAndFinishWithoutProblems() throws ClientException {
// with
BuildConfiguration buildConfiguration = buildConfigurationClient.getAll().iterator().next();
// when
Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getPersistentParameters(true));
assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId(), isIn, null), 15, TimeUnit.SECONDS);
}
Aggregations