Search in sources :

Example 71 with BuildConfiguration

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

the class BuildTest method dontRebuildTemporaryBuildWhenThereIsNewerPersistentOnSameRev.

// NCL-5192
// Replicates NCL-5192 through explicit dependency instead of implicit
@Test
public void dontRebuildTemporaryBuildWhenThereIsNewerPersistentOnSameRev() throws ClientException {
    BuildConfiguration parent = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==pnc-build-agent-0.4")).iterator().next();
    BuildConfiguration dependency = buildConfigurationClient.getAll(Optional.empty(), Optional.of("name==termd")).iterator().next();
    Instant oldLastModDateParent = parent.getModificationTime();
    BuildConfiguration updatedParent = parent.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(updatedParent.getId(), updatedParent);
    updatedParent = buildConfigurationClient.getSpecific(updatedParent.getId());
    assertThat(oldLastModDateParent).isNotEqualTo(updatedParent.getModificationTime());
    Instant oldLastModDateDependency = parent.getModificationTime();
    BuildConfiguration updatedDependency = dependency.toBuilder().description("Random Description so it rebuilds").buildScript("mvn" + "   clean deploy -DskipTests=true").build();
    buildConfigurationClient.update(updatedDependency.getId(), updatedDependency);
    assertThat(oldLastModDateDependency).isNotEqualTo(updatedDependency.getModificationTime());
    EnumSet<BuildStatus> isIn = EnumSet.of(BuildStatus.SUCCESS);
    EnumSet<BuildStatus> isNotIn = EnumSet.of(BuildStatus.REJECTED, BuildStatus.NO_REBUILD_REQUIRED);
    // Build temporary builds (parent and dependency) on new revision
    Build temporaryBuild = buildConfigurationClient.trigger(parent.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(temporaryBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Build persistent build of dependency on the same revision
    Build dependencyPersistentBuild = buildConfigurationClient.trigger(dependency.getId(), getPersistentParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(dependencyPersistentBuild.getId(), isIn, isNotIn), 15, TimeUnit.SECONDS);
    // Build temporary build of parent and check it gets REJECTED even if it's dependency has newer record
    // (in this case temp build should ignore persistent one)
    Build finalRecord = buildConfigurationClient.trigger(parent.getId(), getTemporaryParameters());
    ResponseUtils.waitSynchronouslyFor(() -> buildToFinish(finalRecord.getId(), EnumSet.of(BuildStatus.NO_REBUILD_REQUIRED), null), 15, TimeUnit.SECONDS);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupBuild(org.jboss.pnc.dto.GroupBuild) Build(org.jboss.pnc.dto.Build) Instant(java.time.Instant) BuildStatus(org.jboss.pnc.enums.BuildStatus) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 72 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldUpdateBuildConfigurationWithDependencies.

/**
 * Reproducer NCL-5686 - update of build configuration with dependencies, with cache enabled, is possible
 *
 * @throws Exception
 */
@Test
@InSequence(60)
public void shouldUpdateBuildConfigurationWithDependencies() throws ClientException {
    // given
    // Create dependency
    BuildConfiguration dependency = createBuildConfigurationAndValidateResults(projectId, environmentId, repositoryConfigurationId, "pnc-1.0.0.DR1", UUID.randomUUID().toString());
    // Create build configuration
    Map<String, BuildConfigurationRef> dependencies = new HashMap<>();
    dependencies.put(dependency.getId(), dependency);
    BuildConfiguration buildConfiguration = createBuildConfigurationWithDependencyAndValidateResults(projectId, environmentId, repositoryConfigurationId, "dependency-analysis-master", UUID.randomUUID().toString(), dependencies);
    final String updatedBuildScript = "mvn clean deploy -DskipTests=true";
    final Instant modificationTime = Instant.ofEpochMilli(155382545038L);
    BuildConfiguration updatedBuildConfiguration = BuildConfiguration.builder().id(buildConfiguration.getId()).name(buildConfiguration.getName()).buildScript(updatedBuildScript).creationTime(buildConfiguration.getCreationTime()).modificationTime(modificationTime).project(buildConfiguration.getProject()).environment(buildConfiguration.getEnvironment()).parameters(buildConfiguration.getParameters()).scmRepository(buildConfiguration.getScmRepository()).buildType(buildConfiguration.getBuildType()).build();
    // when
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    client.update(updatedBuildConfiguration.getId(), updatedBuildConfiguration);
    BuildConfiguration updatedBC = client.getSpecific(updatedBuildConfiguration.getId());
    // then
    assertThat(updatedBC.getId()).isEqualTo(buildConfiguration.getId());
    assertThat(updatedBC.getName()).isEqualTo("dependency-analysis-master");
    assertThat(updatedBC.getBuildScript()).isEqualTo(updatedBuildScript);
    assertThat(updatedBC.getScmRepository().getId()).isEqualTo(repositoryConfigurationId);
    assertThat(updatedBC.getProject().getId()).isEqualTo(projectId);
    assertThat(updatedBC.getEnvironment().getId()).isEqualTo(environmentId);
    assertThat(modificationTime).isNotEqualTo(updatedBC.getModificationTime());
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) HashMap(java.util.HashMap) Instant(java.time.Instant) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test) InSequence(org.jboss.arquillian.junit.InSequence)

Example 73 with BuildConfiguration

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

the class BuildConfigurationEndpointTest method shouldNotCreateWithInternalUrlNotMatchingPattern.

@Test
public void shouldNotCreateWithInternalUrlNotMatchingPattern() throws ClientException {
    BuildConfigurationClient client = new BuildConfigurationClient(RestClientConfiguration.asUser());
    BuildConfiguration bc = client.getSpecific(configurationId);
    BuildConfiguration newBC = BuildConfiguration.builder().name("othername").buildScript(bc.getBuildScript()).project(bc.getProject()).environment(bc.getEnvironment()).parameters(bc.getParameters()).buildType(bc.getBuildType()).build();
    BuildConfigWithSCMRequest request = BuildConfigWithSCMRequest.builder().buildConfig(newBC).scmUrl("ssh://git@github.com:22/gerrit/newRepo.git").build();
    assertThatThrownBy(() -> client.createWithSCM(request)).hasCauseInstanceOf(BadRequestException.class);
    BuildConfigWithSCMRequest request2 = BuildConfigWithSCMRequest.builder().buildConfig(newBC).scmUrl("ssh://git@github.com:22/foo/newRepo").build();
    assertThatThrownBy(() -> client.createWithSCM(request2)).hasCauseInstanceOf(BadRequestException.class);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigWithSCMRequest(org.jboss.pnc.dto.requests.BuildConfigWithSCMRequest) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 74 with BuildConfiguration

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

the class GroupConfigurationEndpointTest method testAddBuildConfig.

@Test
public void testAddBuildConfig() throws ClientException {
    // with
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "100";
    BuildConfiguration buildConfiguration = bcClient.getAll().iterator().next();
    String bcToAddId = buildConfiguration.getId();
    GroupConfiguration groupConfiguration = client.getSpecific(gcId);
    assertThat(groupConfiguration.getBuildConfigs()).doesNotContainKey(bcToAddId);
    // when
    client.addBuildConfig(gcId, buildConfiguration);
    // then
    assertThat(client.getSpecific(gcId).getBuildConfigs()).containsKey(bcToAddId);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Example 75 with BuildConfiguration

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

the class GroupConfigurationEndpointTest method shouldUpdateAllBuildConfigurations.

@Test
public void shouldUpdateAllBuildConfigurations() throws Exception {
    // with
    GroupConfigurationClient client = new GroupConfigurationClient(RestClientConfiguration.asUser());
    BuildConfigurationClient bcClient = new BuildConfigurationClient(RestClientConfiguration.asUser());
    String gcId = "101";
    BuildConfiguration bc = bcClient.getAll().iterator().next();
    GroupConfiguration gc = client.getSpecific(gcId);
    String bcId = bc.getId();
    Map<String, BuildConfigurationRef> buildConfigurationMap = new HashMap<>();
    buildConfigurationMap.put(bcId, bc);
    GroupConfiguration updated = gc.toBuilder().buildConfigs(buildConfigurationMap).build();
    assertThat(gc.getBuildConfigs()).doesNotContainKey(bcId);
    // when
    client.update(gc.getId(), updated);
    // then
    assertThat(client.getSpecific(gcId).getBuildConfigs()).containsOnlyKeys(bcId);
}
Also used : BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) BuildConfigurationRef(org.jboss.pnc.dto.BuildConfigurationRef) HashMap(java.util.HashMap) GroupConfigurationClient(org.jboss.pnc.client.GroupConfigurationClient) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfigurationClient(org.jboss.pnc.client.BuildConfigurationClient) ContainerTest(org.jboss.pnc.test.category.ContainerTest) Test(org.junit.Test)

Aggregations

BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)90 Test (org.junit.Test)65 ContainerTest (org.jboss.pnc.test.category.ContainerTest)45 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)31 HashMap (java.util.HashMap)17 InSequence (org.jboss.arquillian.junit.InSequence)17 Build (org.jboss.pnc.dto.Build)13 GroupBuild (org.jboss.pnc.dto.GroupBuild)12 SCMRepository (org.jboss.pnc.dto.SCMRepository)10 Test (org.junit.jupiter.api.Test)10 BuildConfigurationRef (org.jboss.pnc.dto.BuildConfigurationRef)9 Instant (java.time.Instant)8 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)7 BuildStatus (org.jboss.pnc.enums.BuildStatus)7 GroupConfigurationClient (org.jboss.pnc.client.GroupConfigurationClient)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 ArrayList (java.util.ArrayList)4 BuildConfigurationRevision (org.jboss.pnc.dto.BuildConfigurationRevision)4 HashSet (java.util.HashSet)3