use of org.jboss.pnc.dto.Build in project bacon by project-ncl.
the class PncBuilder method verifyAllBuildsInGroupBuildInFinalStateWithProperCount.
/**
* This check makes sure that even when a group build is marked as done, we also need to make sure all its builds
* are also done (NCL-6044). We also make sure that the number of builds done is the same as the number of build
* configs in the group build's group config (NCL-6041)
*
* This is done to handle a weird timing error which happens when a group build finishes, the group build status is
* updated before the last individual build status is updated to their final state. This may cause inconsistency in
* the last build data.
*
* This is especially true when the Group build status is NO_REBUILD_REQUIRED, where it is also essential that all
* the individual builds are also in their final state (and logically NO_REBUILD_REQUIRED status) so that we can get
* the no rebuild cause.
*
* @param groupBuildId the group build id
* @return whether all the builds have a final status or not
*/
boolean verifyAllBuildsInGroupBuildInFinalStateWithProperCount(String groupBuildId) {
// log set to info for CPaaS to detect infinite loop
log.info("Checking if all builds in group build {} are in final state with proper count of builds ( {} )", groupBuildId, UrlGenerator.generateGroupBuildUrl(groupBuildId));
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setLatest(false);
filter.setRunning(false);
try {
Collection<Build> builds = groupBuildClient.getBuilds(groupBuildId, filter).getAll();
boolean allFinal = builds.stream().allMatch(b -> b.getStatus().isFinal());
return allFinal && getCountOfBuildConfigsForGroupBuild(groupBuildId) == builds.size();
} catch (ClientException e) {
log.warn("Failed to check if all builds in group build {} have a final status. Assuming it is not finished", groupBuildId, e);
return false;
}
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class AdvancedBuildConfigurationClient method fallbackSupplier.
/**
* Used to retrieve build through through REST when WS Client loses connection and reconnects
*
* @param bcId Id of the BuildConfig where the build was run
* @return
* @throws RemoteResourceException
*/
private Build fallbackSupplier(String bcId) throws RemoteResourceException {
BuildsFilterParameters parameters = new BuildsFilterParameters();
parameters.setLatest(true);
Build build = null;
try (BuildConfigurationClient client = new BuildConfigurationClient(configuration)) {
build = client.getBuilds(bcId, parameters).iterator().next();
}
return build;
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetBuilds.
@Test
public void testGetBuilds() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
RemoteCollection<Build> all = client.getBuilds(configurationId, null);
assertThat(all).hasSize(2).allMatch(b -> configurationId.equals(b.getBuildConfigRevision().getId()));
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldModifyBuiltArtifactQualityLevels.
@Test
public void shouldModifyBuiltArtifactQualityLevels() throws RemoteResourceException {
BuildClient client = new BuildClient(RestClientConfiguration.asSystem());
String buildRecordId = build3Id;
String REASON = "This artifact has become old enough";
ArtifactClient artifactClient = new ArtifactClient(RestClientConfiguration.asSystem());
Artifact newArtifact = artifactClient.create(Artifact.builder().artifactQuality(ArtifactQuality.NEW).buildCategory(BuildCategory.STANDARD).filename("builtArtifactInsertNew.jar").identifier("integration-test:built-artifact-new:jar:1.0").targetRepository(artifactClient.getSpecific("100").getTargetRepository()).md5("insert-md5-22").sha1("insert-22").sha256("insert-22").size(10L).build());
client.setBuiltArtifacts(build3Id, Collections.singletonList(newArtifact.getId()));
client.createBuiltArtifactsQualityLevelRevisions(buildRecordId, "BLACKListed", REASON);
RemoteCollection<Artifact> artifacts = client.getBuiltArtifacts(buildRecordId);
for (Artifact artifact : artifacts) {
assertThat(artifact.getArtifactQuality()).isEqualTo(ArtifactQuality.BLACKLISTED);
assertThat(artifact.getQualityLevelReason()).isEqualTo(REASON);
assertThat(artifact.getModificationUser().getUsername()).isEqualTo("system");
}
Build withAttribute = client.getSpecific(buildRecordId);
assertThat(withAttribute.getAttributes()).contains(entry(Attributes.BLACKLIST_REASON, REASON));
}
use of org.jboss.pnc.dto.Build in project pnc by project-ncl.
the class BuildEndpointTest method shouldFilterByBuildConfigurationNameAndInvalidUserId.
@Test
public void shouldFilterByBuildConfigurationNameAndInvalidUserId() throws Exception {
BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
String username = "random-user-name";
String rsql = "user.username==" + username;
BuildsFilterParameters filter = new BuildsFilterParameters();
filter.setBuildConfigName(buildConfigName);
List<Build> builds = new ArrayList<>(client.getAll(filter, null, Optional.empty(), Optional.of(rsql)).getAll());
assertThat(builds).isEmpty();
}
Aggregations