Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Paketo image building system tests
A new system test plugin is being made available for running test suites that should be run less frequently than with every commit, such as tests that verify Spring Boot compatibility with external projects. CI pipeline configuration for running system tests is also provided. The first system tests verify the behavior of the Spring Boot image building plugins when building images using Paketo buildpacks. Closes gh-25824
- Loading branch information
1 parent
d82b46b
commit 18c7c0a
Showing
51 changed files
with
1,326 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
buildSrc/src/main/java/org/springframework/boot/build/test/SystemTestPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2012-2021 the original author or authors. | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
|
||
package org.springframework.boot.build.test; | ||
|
||
import org.gradle.api.Plugin; | ||
import org.gradle.api.Project; | ||
import org.gradle.api.plugins.JavaPlugin; | ||
import org.gradle.api.plugins.JavaPluginConvention; | ||
import org.gradle.api.tasks.SourceSet; | ||
import org.gradle.api.tasks.SourceSetContainer; | ||
import org.gradle.api.tasks.testing.Test; | ||
import org.gradle.language.base.plugins.LifecycleBasePlugin; | ||
import org.gradle.plugins.ide.eclipse.EclipsePlugin; | ||
import org.gradle.plugins.ide.eclipse.model.EclipseModel; | ||
|
||
/** | ||
* A {@link Plugin} to configure system testing support in a {@link Project}. | ||
* | ||
* @author Andy Wilkinson | ||
* @author Scott Frederick | ||
*/ | ||
public class SystemTestPlugin implements Plugin<Project> { | ||
|
||
/** | ||
* Name of the {@code systemTest} task. | ||
*/ | ||
public static String SYSTEM_TEST_TASK_NAME = "systemTest"; | ||
|
||
/** | ||
* Name of the {@code systemTest} source set. | ||
*/ | ||
public static String SYSTEM_TEST_SOURCE_SET_NAME = "systemTest"; | ||
|
||
@Override | ||
public void apply(Project project) { | ||
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> configureSystemTesting(project)); | ||
} | ||
|
||
private void configureSystemTesting(Project project) { | ||
SourceSet systemTestSourceSet = createSourceSet(project); | ||
createTestTask(project, systemTestSourceSet); | ||
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> { | ||
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class); | ||
eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add( | ||
project.getConfigurations().getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName()))); | ||
}); | ||
} | ||
|
||
private SourceSet createSourceSet(Project project) { | ||
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets(); | ||
SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME); | ||
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); | ||
systemTestSourceSet | ||
.setCompileClasspath(systemTestSourceSet.getCompileClasspath().plus(mainSourceSet.getOutput())); | ||
systemTestSourceSet | ||
.setRuntimeClasspath(systemTestSourceSet.getRuntimeClasspath().plus(mainSourceSet.getOutput())); | ||
return systemTestSourceSet; | ||
} | ||
|
||
private void createTestTask(Project project, SourceSet systemTestSourceSet) { | ||
Test systemTest = project.getTasks().create(SYSTEM_TEST_TASK_NAME, Test.class); | ||
systemTest.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP); | ||
systemTest.setDescription("Runs system tests."); | ||
systemTest.setTestClassesDirs(systemTestSourceSet.getOutput().getClassesDirs()); | ||
systemTest.setClasspath(systemTestSourceSet.getRuntimeClasspath()); | ||
systemTest.shouldRunAfter(JavaPlugin.TEST_TASK_NAME); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
source $(dirname $0)/common.sh | ||
|
||
pushd git-repo > /dev/null | ||
if [[ -d /opt/openjdk-toolchain ]]; then | ||
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --rerun-tasks systemTest -PtoolchainVersion=${TOOLCHAIN_JAVA_VERSION} -Porg.gradle.java.installations.auto-detect=false -Porg.gradle.java.installations.auto-download=false -Porg.gradle.java.installations.paths=/opt/openjdk-toolchain/ | ||
else | ||
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --rerun-tasks systemTest | ||
fi | ||
popd > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
platform: linux | ||
inputs: | ||
- name: git-repo | ||
caches: | ||
- path: gradle | ||
params: | ||
BRANCH: | ||
CI: true | ||
GRADLE_ENTERPRISE_ACCESS_KEY: | ||
GRADLE_ENTERPRISE_CACHE_USERNAME: | ||
GRADLE_ENTERPRISE_CACHE_PASSWORD: | ||
GRADLE_ENTERPRISE_URL: https://ge.spring.io | ||
run: | ||
path: bash | ||
args: | ||
- -ec | ||
- | | ||
source /docker-lib.sh | ||
start_docker | ||
${PWD}/git-repo/ci/scripts/run-system-tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.