Search in sources :

Example 11 with GroupBuild

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;
    }
}
Also used : GroupConfigurationRef(org.jboss.pnc.dto.GroupConfigurationRef) GroupBuild(org.jboss.pnc.dto.GroupBuild) ClientException(org.jboss.pnc.client.ClientException)

Example 12 with GroupBuild

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);
}
Also used : GroupBuildRequest(org.jboss.pnc.dto.requests.GroupBuildRequest) GroupBuild(org.jboss.pnc.dto.GroupBuild) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef) ArrayList(java.util.ArrayList) BuildConfigurationRevision(org.jboss.pnc.dto.BuildConfigurationRevision) BuildStatus(org.jboss.pnc.enums.BuildStatus) GroupBuildParameters(org.jboss.pnc.rest.api.parameters.GroupBuildParameters) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 13 with GroupBuild

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;
}
Also used : RemoteResourceNotFoundException(org.jboss.pnc.client.RemoteResourceNotFoundException) GroupBuild(org.jboss.pnc.dto.GroupBuild) ClientException(org.jboss.pnc.client.ClientException)

Example 14 with GroupBuild

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;
}
Also used : RemoteResourceNotFoundException(org.jboss.pnc.client.RemoteResourceNotFoundException) GroupBuild(org.jboss.pnc.dto.GroupBuild) GroupBuildClient(org.jboss.pnc.client.GroupBuildClient) ClientException(org.jboss.pnc.client.ClientException)

Aggregations

GroupBuild (org.jboss.pnc.dto.GroupBuild)14 Test (org.junit.Test)7 ContainerTest (org.jboss.pnc.test.category.ContainerTest)6 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)5 GroupBuildParameters (org.jboss.pnc.rest.api.parameters.GroupBuildParameters)4 ClientException (org.jboss.pnc.client.ClientException)3 BuildStatus (org.jboss.pnc.enums.BuildStatus)3 HashMap (java.util.HashMap)2 RemoteResourceException (org.jboss.pnc.client.RemoteResourceException)2 RemoteResourceNotFoundException (org.jboss.pnc.client.RemoteResourceNotFoundException)2 Undertow (io.undertow.Undertow)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 InSequence (org.jboss.arquillian.junit.InSequence)1 GroupBuildInfo (org.jboss.pnc.bacon.pig.impl.config.GroupBuildInfo)1 BuildInfoCollector (org.jboss.pnc.bacon.pig.impl.pnc.BuildInfoCollector)1 ImportResult (org.jboss.pnc.bacon.pig.impl.pnc.ImportResult)1 PncBuilder (org.jboss.pnc.bacon.pig.impl.pnc.PncBuilder)1