Search in sources :

Example 36 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildEndpointTest method shouldGetBuilds.

@Test
@InSequence(10)
public void shouldGetBuilds() throws RemoteResourceException {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Build> all = client.getAll(null, null);
    assertThat(all).hasSize(4);
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 37 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildEndpointTest method shouldFilterByBuildConfigurationNameNotLike.

@Test
public void shouldFilterByBuildConfigurationNameNotLike() throws Exception {
    BuildClient client = new BuildClient(RestClientConfiguration.asAnonymous());
    String buildConfigName = DatabaseDataInitializer.PNC_PROJECT_BUILD_CFG_ID;
    BuildsFilterParameters filter = new BuildsFilterParameters();
    filter.setBuildConfigName("!*" + buildConfigName.substring(1, buildConfigName.length() - 2) + "*");
    List<String> buildConfigNames = client.getAll(filter, null).getAll().stream().map(Build::getBuildConfigRevision).map(BuildConfigurationRevisionRef::getName).collect(Collectors.toList());
    // from DatabaseDataInitializer
    assertThat(buildConfigNames).hasSize(2);
    assertThat(buildConfigNames).doesNotContain(buildConfigName);
}
Also used : Build(org.jboss.pnc.dto.Build) BuildClient(org.jboss.pnc.client.BuildClient) BuildsFilterParameters(org.jboss.pnc.rest.api.parameters.BuildsFilterParameters) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 38 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildTest method shouldRejectAfterBuildingTwoTempBuildsOnSameRevision.

@Test
public void shouldRejectAfterBuildingTwoTempBuildsOnSameRevision() throws ClientException {
    BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==maven-plugin-test")).iterator().next();
    BuildConfiguration updatedConfiguration = buildConfiguration.toBuilder().description("Random Description to be able to trigger build again so that temporary build will be first on this revision").buildScript("mvn" + "   clean deploy -DskipTests=true").build();
    buildConfigurationClient.update(updatedConfiguration.getId(), updatedConfiguration);
    Build temporaryBuild = buildConfigurationClient.trigger(updatedConfiguration.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(temporaryBuild.getId(), EnumSet.of(BuildStatus.SUCCESS), null), 15, TimeUnit.SECONDS);
    Build secondTempBuild = buildConfigurationClient.trigger(updatedConfiguration.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(secondTempBuild.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), EnumSet.of(BuildStatus.SUCCESS, BuildStatus.REJECTED)), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 39 with Build

use of org.jboss.pnc.dto.Build in project pnc by project-ncl.

the class BuildTest method shouldBuildTemporaryBuildAndNotAssignItToMilestone.

@Test
public void shouldBuildTemporaryBuildAndNotAssignItToMilestone() throws ClientException {
    // BC pnc-1.0.0.DR1 is assigned to a product version containing an active product milestone see
    // DatabaseDataInitializer#initiliazeProjectProductData
    BuildConfiguration buildConfiguration = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-1.0.0.DR1")).iterator().next();
    // when
    Build build = buildConfigurationClient.trigger(buildConfiguration.getId(), getTemporaryParameters(true));
    // then
    assertThat(build).isNotNull().extracting("id").isNotNull().isNotEqualTo("");
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(build.getId()), 15, TimeUnit.SECONDS);
    Build updatedBuild = buildClient.getSpecific(build.getId());
    assertThat(updatedBuild.getProductMilestone()).isNull();
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 40 with Build

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

Aggregations

Build (org.jboss.pnc.dto.Build)71 Test (org.junit.Test)52 ContainerTest (org.jboss.pnc.test.category.ContainerTest)35 BuildClient (org.jboss.pnc.client.BuildClient)20 BuildRecord (org.jboss.pnc.model.BuildRecord)18 BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)16 BuildStatus (org.jboss.pnc.enums.BuildStatus)15 GroupBuild (org.jboss.pnc.dto.GroupBuild)14 BuildPageInfo (org.jboss.pnc.facade.providers.api.BuildPageInfo)14 ArrayList (java.util.ArrayList)12 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)11 HashSet (java.util.HashSet)10 List (java.util.List)10 Set (java.util.Set)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 Date (java.util.Date)9 Page (org.jboss.pnc.dto.response.Page)9 BuildMapper (org.jboss.pnc.mapper.api.BuildMapper)9 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)9