use of org.jboss.pnc.dto.GroupBuild 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.dto.GroupBuild 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);
}
use of org.jboss.pnc.dto.GroupBuild 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;
}
use of org.jboss.pnc.dto.GroupBuild in project pnc by project-ncl.
the class WebSocketClientTest method groupBuildToFinish.
private Boolean groupBuildToFinish(String groupBuildId) {
GroupBuild build = null;
try {
build = new GroupBuildClient(RestClientConfiguration.asUser()).getSpecific(groupBuildId);
assertThat(build).isNotNull();
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);
}
return true;
}
Aggregations