Skip to content

Commit

Permalink
Merge pull request #281 from jfdenise/stability_testing
Browse files Browse the repository at this point in the history
Add tests for stability handling, fix findings.
  • Loading branch information
jfdenise authored Mar 8, 2024
2 parents 900f21d + 8c7ac42 commit e54a295
Show file tree
Hide file tree
Showing 73 changed files with 3,279 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public interface WfConstants {
String EXTENSIONS_STANDALONE = "extensions-standalone";
String GALLEON_PASSIVE = "galleon.passive";
String HOST = "host";
String JBOSS_STABILITY = "jboss.stability";
String LAYOUT = "layout";
String LAYERS = "layers";
String LAYERS_CONF = "layers.conf";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import org.jboss.galleon.maven.plugin.util.MavenArtifactRepositoryManager;
import org.jboss.galleon.spec.FeaturePackPlugin;
import org.jboss.galleon.spec.FeaturePackSpec;
import org.jboss.galleon.spec.FeatureSpec;
import org.jboss.galleon.spec.PackageDependencySpec;
import org.jboss.galleon.spec.PackageSpec;
import org.jboss.galleon.universe.FeaturePackLocation;
Expand All @@ -93,6 +94,7 @@
import org.jboss.galleon.util.StringUtils;
import org.jboss.galleon.util.ZipUtils;
import org.jboss.galleon.xml.FeaturePackXmlWriter;
import org.jboss.galleon.xml.FeatureSpecXmlParser;
import org.jboss.galleon.xml.PackageXmlParser;
import org.jboss.galleon.xml.PackageXmlWriter;
import org.wildfly.channel.ChannelManifest;
Expand Down Expand Up @@ -349,7 +351,7 @@ protected void buildFeaturePack(FeaturePackDescription.Builder fpBuilder, WildFl
Util.copyIfExists(resourcesDir, fpDir, Constants.LAYERS);
Util.copyIfExists(resourcesDir, fpDir, Constants.CONFIGS);

Util.copyDirIfExists(resourcesDir.resolve(Constants.FEATURES), fpDir.resolve(Constants.FEATURES));
addFeatures(resourcesDir.resolve(Constants.FEATURES), fpDir.resolve(Constants.FEATURES));
Util.copyDirIfExists(resourcesDir.resolve(Constants.FEATURE_GROUPS), fpDir.resolve(Constants.FEATURE_GROUPS));

final Path resourcesWildFly = getWildFlyResourcesDir();
Expand Down Expand Up @@ -475,13 +477,6 @@ private void addConfigPackages(final Path configDir, final Path packagesDir, fin
final Path packageDir = packagesDir.resolve(configPackage.getFileName());
final Path packageFile = packageDir.resolve(Constants.PACKAGE_XML);
final Path packageXml = configPackage.resolve(Constants.PACKAGE_XML);
if (Files.exists(packageFile) && Files.exists(packageXml)) {
warn("File " + packageFile + " already exists, replacing with " + packageXml);
}
if (!Files.exists(packageDir)) {
Util.mkdirs(packageDir);
}
IoUtils.copy(configPackage, packageDir);

if (Files.exists(packageXml)) {
final PackageSpec pkgSpec;
Expand All @@ -492,13 +487,69 @@ private void addConfigPackages(final Path configDir, final Path packagesDir, fin
throw new MojoExecutionException("Failed to parse " + packageXml, e);
}
}
Stability packageStability = pkgSpec.getStability();
if (packageStability != null) {
if (stability != null && !stability.enables(packageStability)) {
getLog().warn("Package " + pkgSpec.getName() + " is not included in the feature-pack. "
+ "Package stability '"
+ packageStability + "' is not enabled by the '" + stability
+ "' stability level that is the feature-pack minimum stability level.");
continue;
}
}
fpBuilder.addPackage(pkgSpec);
}

if (Files.exists(packageFile) && Files.exists(packageXml)) {
warn("File " + packageFile + " already exists, replacing with " + packageXml);
}
if (!Files.exists(packageDir)) {
Util.mkdirs(packageDir);
}
IoUtils.copy(configPackage, packageDir);
}
} catch (IOException e) {
throw new MojoExecutionException("Failed to process config packages", e);
}
}
private void addFeatures(final Path configDir, final Path featuresDir) throws MojoExecutionException {
if (!Files.exists(configDir)) {
return;
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(configDir)) {
for (Path configFeature : stream) {
final Path featureDir = featuresDir.resolve(configFeature.getFileName());
final Path featureXml = configFeature.resolve(Constants.SPEC_XML);
if (!Files.exists(featureXml)) {
throw new MojoExecutionException("Feature spec " + featureXml + " doesn't exist ");
}
final FeatureSpec featureSpec;
try (BufferedReader reader = Files.newBufferedReader(featureXml)) {
try {
featureSpec = FeatureSpecXmlParser.getInstance().parse(reader);
} catch (ProvisioningDescriptionException | XMLStreamException e) {
throw new MojoExecutionException("Failed to parse " + featureXml, e);
}
}
Stability featureStability = featureSpec.getStability();
if (featureStability != null) {
if (stability != null && !stability.enables(featureStability)) {
getLog().warn("Feature " + featureSpec.getName() + " is not included in the feature-pack. "
+ "Feature stability '"
+ featureStability + "' is not enabled by the '" + stability
+ "' stability level that is the feature-pack minimum stability level.");
continue;
}
}
if (!Files.exists(featureDir)) {
Util.mkdirs(featureDir);
}
IoUtils.copy(configFeature, featureDir);
}
} catch (IOException e) {
throw new MojoExecutionException("Failed to process feature spec", e);
}
}

private void persistExtensions(final Path resourcesWildFly, String name, List<String> extensions) throws MojoExecutionException {
try {
Expand Down Expand Up @@ -722,7 +773,7 @@ private void packageModules(FeaturePackDescription.Builder fpBuilder,
final ModuleParseResult parsedModule;
try {
parsedModule = ModuleXmlParser.parse(moduleXml, WfConstants.UTF8, targetToAlias);
String packageStability = parsedModule.getProperty("org.jboss.stability");
String packageStability = parsedModule.getProperty(WfConstants.JBOSS_STABILITY);
if (packageStability != null) {
Stability stab = Stability.fromString(packageStability);
if (stability != null && !stability.enables(stab)) {
Expand Down
107 changes: 107 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<module>maven-plugin</module>
<module>feature-spec-gen</module>
<module>docs</module>
<module>testsuite</module>
</modules>

<properties>
Expand Down Expand Up @@ -96,6 +97,10 @@
<license.failIfMissing>true</license.failIfMissing>
<license.failIfUnknown>true</license.failIfUnknown>

<!-- test suite -->
<version.org.wildfly.common>1.6.0.Final</version.org.wildfly.common>
<maven.repo.local>${settings.localRepository}</maven.repo.local>

<galleon-plugins.repo.scm.connection>[email protected]:wildfly/galleon-plugins.git</galleon-plugins.repo.scm.connection>
<galleon-plugins.repo.scm.url>https://github.com/wildfly/galleon-plugins</galleon-plugins.repo.scm.url>
</properties>
Expand Down Expand Up @@ -404,6 +409,89 @@
<artifactId>maven-filtering</artifactId>
<version>${version.org.apache.maven.shared}</version>
</dependency>

<!-- test suite -->
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>preview-feature-pack</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>community-feature-pack</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>experimental-feature-pack</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>default-feature-pack</artifactId>
<version>${project.version}</version>
<type>zip</type>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>test-subsystem-experimental</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>test-subsystem-preview</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>test-subsystem-community</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>test-subsystem-default</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-core-galleon-pack</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
<type>zip</type>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-version</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-controller</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-service</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-server</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-subsystem-test</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
<scope>provided</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -456,6 +544,25 @@
<artifactId>adoc-maven-plugin-descriptor</artifactId>
<version>${version.adoc-maven-plugin-descriptor}</version>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-galleon-maven-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<!-- feature-spec-gen uses wildfly-embedded to generate the feature specs, hence the designated wildfly-embedded version must match the pack one -->
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-embedded</artifactId>
<version>${version.org.wildfly.core.wildfly-core}</version>
</dependency>
<!-- If you add a dependency on wildfly-embedded you need to bring your own transitives -->
<dependency>
<groupId>org.wildfly.common</groupId>
<artifactId>wildfly-common</artifactId>
<version>${version.org.wildfly.common}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down
42 changes: 42 additions & 0 deletions testsuite/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2019 Red Hat, Inc. and/or its affiliates
and other contributors as indicated by the @author tags.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>wildfly-provisioning-parent</artifactId>
<version>7.0.0.Beta4-SNAPSHOT</version>
</parent>
<properties>
<!-- Don't deploy the testsuite modules -->
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<artifactId>wildfly-galleon-plugins-testsuite</artifactId>
<packaging>pom</packaging>

<name>WildFly Galleon Plugins testsuite</name>
<url>http://maven.apache.org</url>

<modules>
<module>test-feature-packs</module>
<module>tests</module>
</modules>
</project>
57 changes: 57 additions & 0 deletions testsuite/test-feature-packs/common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright The WildFly Authors
~ SPDX-License-Identifier: Apache-2.0
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wildfly.galleon-plugins</groupId>
<artifactId>wildfly-galleon-plugins-test-feature-packs</artifactId>
<version>7.0.0.Beta4-SNAPSHOT</version>
</parent>

<artifactId>wildfly-galleon-plugins-test-feature-pack-common</artifactId>

<name>WildFly Galleon Plugins Test Feature Pack common</name>
<packaging>pom</packaging>
<description>WildFly Galleon Plugins Test Feature Pack common</description>


<properties>
<!-- Don't deploy the testsuite modules -->
<maven.deploy.skip>true</maven.deploy.skip>
</properties>

<build>
<finalName>${server.output.dir.prefix}-test-feature-pack-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
~ Copyright The WildFly Authors
~ SPDX-License-Identifier: Apache-2.0
-->

<build xmlns="urn:wildfly:feature-pack-build:3.1" producer="${featurepack.producer}">
<dependencies>
<dependency group-id="org.wildfly.core" artifact-id="wildfly-core-galleon-pack">
<name>org.wildfly.core:wildfly-core-galleon-pack</name>
<default-configs inherit="false">
<include model="standalone" name="standalone.xml"/>
</default-configs>
</dependency>
</dependencies>
<default-packages>
<package name="modules.all"/>
</default-packages>
<plugins>
<plugin artifact="org.wildfly.galleon-plugins:wildfly-galleon-plugins"/>
</plugins>
<generate-feature-specs>
<extensions>
<standalone>
<!-- Contains all extensions, if an extension doesn't exist at actual feature-pack build time, it is ignored -->
<extension>org.wildfly.galleon.plugins.test.subsystem.experimental</extension>
<extension>org.wildfly.galleon.plugins.test.subsystem.preview</extension>
<extension>org.wildfly.galleon.plugins.test.subsystem.community</extension>
<extension>org.wildfly.galleon.plugins.test.subsystem.default</extension>
</standalone>
</extensions>
</generate-feature-specs>
</build>
Loading

0 comments on commit e54a295

Please sign in to comment.