Search in sources :

Example 6 with Environment

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

the class PigTest method shouldCreateProduct.

@Test
@Order(1)
void shouldCreateProduct() throws IOException {
    final Path configFile = CONFIG_LOCATION;
    replaceSuffixInConfigFile(configFile.resolve("build-config.yaml"));
    final Product product = Product.builder().id(UNIVERSAL_ID).name(PRODUCT_NAME).abbreviation(PRODUCT_ABBREVIATION).build();
    final ProductVersion productVersion = ProductVersion.builder().id(UNIVERSAL_ID).version(VERSION).product(product).build();
    final ProductMilestone productMilestone = ProductMilestone.builder().id(UNIVERSAL_ID).productVersion(productVersion).version(MILESTONE).build();
    final ProductVersion productVersionWithCurrentMilestone = productVersion.toBuilder().currentProductMilestone(productMilestone).build();
    final GroupConfiguration groupConfig = GroupConfiguration.builder().id(UNIVERSAL_ID).name(GROUP_NAME).productVersion(productVersionWithCurrentMilestone).build();
    final Project project = Project.builder().id(UNIVERSAL_ID).name(PROJECT_NAME).build();
    final SCMRepository scmRepository = SCMRepository.builder().id(UNIVERSAL_ID).internalUrl(SCM_URL).preBuildSyncEnabled(true).build();
    final Environment environment = Environment.builder().id(UNIVERSAL_ID).deprecated(false).build();
    final BuildConfiguration buildConfig = BuildConfiguration.builder().id(UNIVERSAL_ID).name(BC_NAME).buildScript(BUILD_SCRIPT).scmRevision(SCM_REVISION).creationTime(Instant.now()).modificationTime(Instant.now()).scmRepository(scmRepository).environment(environment).project(project).productVersion(productVersionWithCurrentMilestone).build();
    final GroupConfiguration groupConfigWithBuildConfig = groupConfig.toBuilder().buildConfigs(Collections.singletonMap(UNIVERSAL_ID, buildConfig)).build();
    wmock.list(PRODUCT, new Page<Product>());
    wmock.creation(PRODUCT, product);
    wmock.list(PRODUCT_VERSIONS.apply(UNIVERSAL_ID), new Page<ProductVersion>());
    wmock.creation(PRODUCT_VERSION, productVersion);
    wmock.list(PRODUCT_VERSION_MILESTONES.apply(UNIVERSAL_ID), new Page<ProductMilestone>());
    wmock.creation(PRODUCT_MILESTONE, productMilestone);
    wmock.update(PRODUCT_VERSION, productVersion, productVersionWithCurrentMilestone);
    wmock.list(GROUP_CONFIG, new Page<GroupConfiguration>());
    wmock.creation(GROUP_CONFIG, groupConfig);
    wmock.list(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
    wmock.list(BUILD_CONFIG, new Page<BuildConfiguration>());
    wmock.list(PROJECT, new Page<Project>());
    wmock.creation(PROJECT, project);
    wmock.list(SCM_REPOSITORY, new Page<SCMRepository>());
    wmock.creation(SCM_REPOSITORY_CREATE, RepositoryCreationResponse.builder().repository(scmRepository).build());
    wmock.get(ENVIRONMENT, environment);
    wmock.creation(BUILD_CONFIG, buildConfig);
    wmock.list(BUILD_CONFIG_DEPENDENCIES.apply(UNIVERSAL_ID), new Page<BuildConfiguration>());
    wmock.get(BUILD_CONFIG, buildConfig);
    wmock.creation(BUILD_CONFIG, buildConfig);
    wmock.scenario("add BC to GC").getEntity(GROUP_CONFIG, groupConfig).when().post(GROUP_CONFIG_BUILD_CONFIGS.apply(UNIVERSAL_ID)).then().getEntity(GROUP_CONFIG, groupConfigWithBuildConfig);
    ExecutionResult output = executeAndGetResult("pig", "configure", configFile.toString());
    assertThat(output.getOutput()).contains("name: \"Product Foobar " + SUFFIX + "\"");
}
Also used : Path(java.nio.file.Path) ProductMilestone(org.jboss.pnc.dto.ProductMilestone) Product(org.jboss.pnc.dto.Product) ExecutionResult(org.jboss.pnc.bacon.test.ExecutionResult) ProductVersion(org.jboss.pnc.dto.ProductVersion) GroupConfiguration(org.jboss.pnc.dto.GroupConfiguration) BuildConfiguration(org.jboss.pnc.dto.BuildConfiguration) Project(org.jboss.pnc.dto.Project) Environment(org.jboss.pnc.dto.Environment) SCMRepository(org.jboss.pnc.dto.SCMRepository) Order(org.junit.jupiter.api.Order) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) AbstractTest(org.jboss.pnc.bacon.test.AbstractTest) Test(org.junit.jupiter.api.Test)

Example 7 with Environment

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

the class PncEntitiesImporter method checkForDeprecatedEnvironments.

private void checkForDeprecatedEnvironments(List<BuildConfigData> configs) {
    log.debug("Checking for deprecated environments");
    Set<String> fetched = new HashSet<>();
    Set<String> deprecated = new HashSet<>();
    for (BuildConfigData config : configs) {
        String envId = config.getEnvironmentId();
        // skip if we already downloaded the environment
        if (fetched.contains(envId)) {
            if (deprecated.contains(envId)) {
                log.warn("BuildConfig with the name: " + config.getName() + " is using deprecated environment. (NOTE: changing to updated environment may cause rebuilds)");
            }
            continue;
        }
        Environment env = getEnvironment(envId);
        fetched.add(envId);
        if (env.isDeprecated()) {
            log.warn("BuildConfig with the name: " + config.getName() + " is using deprecated environment. (NOTE: changing to updated environment may cause rebuilds)");
            deprecated.add(envId);
        }
    }
}
Also used : Environment(org.jboss.pnc.dto.Environment) HashSet(java.util.HashSet)

Example 8 with Environment

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

the class EnvironmentEndpointTest method shouldSaveEnvironmentAndDeprecateOldOnes.

@Test
@InSequence(30)
public void shouldSaveEnvironmentAndDeprecateOldOnes() throws ClientException {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asSystem());
    Environment.Builder environmentBuilder = Environment.builder().name("OpenJDK 14.0; Mvn 3.6.5").description("OpenJDK 14.0; Mvn 3.6.5").systemImageRepositoryUrl("quay.io/rh-newcastle").systemImageType(SystemImageType.DOCKER_IMAGE);
    Environment envVers10 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.0").build());
    String envVers10Id = envVers10.getId();
    Environment envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
    Assertions.assertThat(envVers10RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
    Assertions.assertThat(envVers10RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.0");
    Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(false);
    Environment envVers11 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.1").build());
    String envVers11Id = envVers11.getId();
    Environment envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
    Assertions.assertThat(envVers11RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
    Assertions.assertThat(envVers11RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.1");
    Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(false);
    Environment envVers12 = client.createNew(environmentBuilder.systemImageId("builder-rhel-7-j14-mvn3.6.5:1.2").build());
    String envVers12Id = envVers12.getId();
    Environment envVers12RetrievedFromDB = client.getSpecific(envVers12Id);
    Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo("OpenJDK 14.0; Mvn 3.6.5");
    Assertions.assertThat(envVers12RetrievedFromDB.getSystemImageId()).isEqualTo("builder-rhel-7-j14-mvn3.6.5:1.2");
    Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
    envVers10RetrievedFromDB = client.getSpecific(envVers10Id);
    envVers11RetrievedFromDB = client.getSpecific(envVers11Id);
    Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers10RetrievedFromDB.getName());
    Assertions.assertThat(envVers12RetrievedFromDB.getName()).isEqualTo(envVers11RetrievedFromDB.getName());
    Assertions.assertThat(envVers12RetrievedFromDB.isDeprecated()).isEqualTo(false);
    Assertions.assertThat(envVers11RetrievedFromDB.isDeprecated()).isEqualTo(true);
    Assertions.assertThat(envVers10RetrievedFromDB.isDeprecated()).isEqualTo(true);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 9 with Environment

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

the class EnvironmentEndpointTest method testGetSpecificEnvironment.

@Test
@InSequence(20)
public void testGetSpecificEnvironment() throws ClientException {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    Environment environment = client.getSpecific(environmentId);
    // from DatabaseDataInitializer
    assertThat(environment.getName()).isEqualTo("Demo Environment 1");
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Example 10 with Environment

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

the class EnvironmentEndpointTest method testGetAllEnvironments.

@Test
@InSequence(10)
public void testGetAllEnvironments() throws RemoteResourceException {
    EnvironmentClient client = new EnvironmentClient(RestClientConfiguration.asAnonymous());
    RemoteCollection<Environment> all = client.getAll();
    // from DatabaseDataInitializer
    assertThat(all).hasSize(2);
}
Also used : EnvironmentClient(org.jboss.pnc.client.EnvironmentClient) Environment(org.jboss.pnc.dto.Environment) Test(org.junit.Test) ContainerTest(org.jboss.pnc.test.category.ContainerTest) InSequence(org.jboss.arquillian.junit.InSequence)

Aggregations

Environment (org.jboss.pnc.dto.Environment)14 Test (org.junit.Test)8 SCMRepository (org.jboss.pnc.dto.SCMRepository)5 ContainerTest (org.jboss.pnc.test.category.ContainerTest)5 InSequence (org.jboss.arquillian.junit.InSequence)4 EnvironmentClient (org.jboss.pnc.client.EnvironmentClient)4 BuildConfiguration (org.jboss.pnc.dto.BuildConfiguration)4 ProjectRef (org.jboss.pnc.dto.ProjectRef)4 BuildEnvironment (org.jboss.pnc.model.BuildEnvironment)3 BuildConfigurationRevisionRef (org.jboss.pnc.dto.BuildConfigurationRevisionRef)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 AbstractTest (org.jboss.pnc.bacon.test.AbstractTest)1 ExecutionResult (org.jboss.pnc.bacon.test.ExecutionResult)1 BuildConfigurationClient (org.jboss.pnc.client.BuildConfigurationClient)1 GroupConfiguration (org.jboss.pnc.dto.GroupConfiguration)1 Product (org.jboss.pnc.dto.Product)1 ProductMilestone (org.jboss.pnc.dto.ProductMilestone)1 ProductVersion (org.jboss.pnc.dto.ProductVersion)1 Project (org.jboss.pnc.dto.Project)1