use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class PncBuilderTest method getCountOfBuildConfigsForGroupBuild.
@Test
void getCountOfBuildConfigsForGroupBuild() throws Exception {
Map<String, BuildConfigurationRef> buildConfigurations = new HashMap<>();
BuildConfigurationRef bc1 = easyRandom.nextObject(BuildConfigurationRef.class);
BuildConfigurationRef bc2 = easyRandom.nextObject(BuildConfigurationRef.class);
BuildConfigurationRef bc3 = easyRandom.nextObject(BuildConfigurationRef.class);
buildConfigurations.put(bc1.getName(), bc1);
buildConfigurations.put(bc2.getName(), bc2);
buildConfigurations.put(bc3.getName(), bc3);
String groupConfigurationId = "5";
String groupBuildId = "1";
GroupConfiguration gc = GroupConfiguration.builder().id(groupConfigurationId).buildConfigs(buildConfigurations).build();
GroupBuild gb = GroupBuild.builder().id(groupBuildId).groupConfig(gc).build();
when(groupBuildClient.getSpecific(groupBuildId)).thenReturn(gb);
when(groupConfigurationClient.getBuildConfigs(groupConfigurationId)).thenReturn(new RemoteCollection<BuildConfiguration>() {
@Override
public int size() {
return buildConfigurations.size();
}
@Override
public Collection<BuildConfiguration> getAll() {
return null;
}
@Override
public Iterator<BuildConfiguration> iterator() {
return null;
}
});
try (PncBuilder builder = new PncBuilder(groupBuildClient, groupConfigurationClient)) {
assertEquals(buildConfigurations.size(), builder.getCountOfBuildConfigsForGroupBuild(groupBuildId));
}
}
use of org.jboss.pnc.dto.BuildConfiguration 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 + "\"");
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class BuildInfoCollector method getBuildsFromLatestGroupConfiguration.
/**
* Get the latest GroupBuildInfo from the groupConfiguration id. If there are no group builds, a runtime exception
* is thrown.
*
* @param groupConfigurationId the group configuration id
* @param temporaryBuild whether the group build is temporary or not
* @return GroupBuildInfo data of the group build and the list of builds
*/
public GroupBuildInfo getBuildsFromLatestGroupConfiguration(String groupConfigurationId, boolean temporaryBuild) {
try {
RemoteCollection<BuildConfiguration> configs = groupConfigurationClient.getBuildConfigs(groupConfigurationId);
Map<String, PncBuild> builds = new HashMap<>();
for (BuildConfiguration config : configs) {
PncBuild build = getLatestBuild(config.getId(), temporaryBuild ? BuildSearchType.ANY : BuildSearchType.PERMANENT);
builds.put(config.getName(), build);
}
// TODO: builds should be enough, getting latest build group to satisfy the current API
return new GroupBuildInfo(getLatestGroupBuild(groupConfigurationId, temporaryBuild), builds);
} catch (RemoteResourceException e) {
throw new RuntimeException("Cannot get list of group builds for group configuration " + groupConfigurationId);
}
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class BuildConfigMappingTest method testAlignmentParametersSet.
@Test
void testAlignmentParametersSet() {
Map<String, String> parameters = new HashMap<>();
parameters.put("ALIGNMENT_PARAMETERS", "-Dtest=true -Dme=false");
BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
assertEquals("-Dtest=true -Dme=false", buildConfig.getAlignmentParameters().stream().findFirst().get());
// make sure no other parameters are set
assertNull(buildConfig.getBuildPodMemory());
assertNull(buildConfig.getBuildCategory());
assertNull(buildConfig.getPigYamlMetadata());
assertNull(buildConfig.getBrewBuildName());
assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
use of org.jboss.pnc.dto.BuildConfiguration in project bacon by project-ncl.
the class BuildConfigMappingTest method testBuilderPodMemorySet.
@Test
void testBuilderPodMemorySet() {
Map<String, String> parameters = new HashMap<>();
parameters.put("BUILDER_POD_MEMORY", "10");
BuildConfiguration buildConfiguration = BuildConfiguration.builder().parameters(parameters).build();
BuildConfigMapping.setBuildConfigFieldsBasedOnParameters(buildConfiguration, buildConfig);
assertTrue(Math.abs(10.0 - buildConfig.getBuildPodMemory()) <= 0.000001);
// make sure no other parameters are set
assertTrue(buildConfig.getAlignmentParameters().size() == 0);
assertNull(buildConfig.getBuildCategory());
assertNull(buildConfig.getPigYamlMetadata());
assertNull(buildConfig.getBrewBuildName());
assertTrue(buildConfig.getExtraRepositories().size() == 0);
}
Aggregations