use of org.jboss.pnc.client.ClientException in project bacon by project-ncl.
the class PncBuilder method getCountOfBuildConfigsForGroupBuild.
/**
* Try to get the count of build configs for a group build's group config. Returns -1 if it couldn't do the request
*
* @param groupBuildId
* @return count, -1 if an error happened
*/
int getCountOfBuildConfigsForGroupBuild(String groupBuildId) {
try {
GroupBuild gb = groupBuildClient.getSpecific(groupBuildId);
GroupConfigurationRef gc = gb.getGroupConfig();
return groupConfigClient.getBuildConfigs(gc.getId()).size();
} catch (ClientException e) {
log.warn("Failed to get count of build configs in the group build {}", groupBuildId, e);
return -1;
}
}
use of org.jboss.pnc.client.ClientException 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.client.ClientException in project pnc by project-ncl.
the class BuildConfigurationEndpointTest method testGetSupportedParameters.
@Test
public void testGetSupportedParameters() throws ClientException {
BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asAnonymous());
Set<Parameter> all = client.getSupportedParameters();
assertThat(all).haveExactly(1, new Condition<>(p -> p.getName().equals(BuildConfigurationParameterKeys.ALIGNMENT_PARAMETERS.name()) && p.getDescription().startsWith("Additional parameters, which will be "), "has PME parameter")).size().isGreaterThanOrEqualTo(4);
}
use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class BuildTest method buildToFinish.
private Boolean buildToFinish(String buildId, EnumSet<BuildStatus> isIn, EnumSet<BuildStatus> isNotIn) {
Build build = null;
logger.debug("Waiting for build {} to finish", buildId);
try {
build = buildClient.getSpecific(buildId);
assertThat(build).isNotNull();
logger.debug("Gotten build with status: {}", build.getStatus());
if (!build.getStatus().isFinal())
return false;
} catch (RemoteResourceNotFoundException e) {
fail(String.format("Build with id:%s not present", buildId), e);
} catch (ClientException e) {
fail("Client has failed in an unexpected way.", e);
}
assertThat(build).isNotNull();
assertThat(build.getStatus()).isNotNull();
if (isIn != null && !isIn.isEmpty())
assertThat(build.getStatus()).isIn(isIn);
if (isNotIn != null && !isNotIn.isEmpty())
assertThat(build.getStatus()).isNotIn(isNotIn);
return true;
}
use of org.jboss.pnc.client.ClientException in project pnc by project-ncl.
the class BuildTest method groupBuildToFinish.
private Boolean groupBuildToFinish(String groupBuildId, EnumSet<BuildStatus> isIn, EnumSet<BuildStatus> isNotIn) {
if (isIn == null)
isIn = EnumSet.noneOf(BuildStatus.class);
if (isNotIn == null)
isNotIn = EnumSet.noneOf(BuildStatus.class);
GroupBuild build = null;
logger.debug("Waiting for build {} to finish", groupBuildId);
try {
build = groupBuildClient.getSpecific(groupBuildId);
assertThat(build).isNotNull();
logger.debug("Gotten build with status: {}", build.getStatus());
if (!build.getStatus().isFinal())
return false;
} catch (RemoteResourceNotFoundException e) {
fail(String.format("Group Build with id:%s not present", groupBuildId), e);
} catch (ClientException e) {
fail("Client has failed in an unexpected way.", e);
}
assertThat(build.getStatus()).isNotIn(isNotIn).isIn(isIn);
return true;
}
Aggregations