Skip to content

Commit 18c7c0a

Browse files
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
1 parent d82b46b commit 18c7c0a

File tree

51 files changed

+1326
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1326
-73
lines changed

buildSrc/build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ gradlePlugin {
6767
id = "org.springframework.boot.integration-test"
6868
implementationClass = "org.springframework.boot.build.test.IntegrationTestPlugin"
6969
}
70+
systemTestPlugin {
71+
id = "org.springframework.boot.system-test"
72+
implementationClass = "org.springframework.boot.build.test.SystemTestPlugin"
73+
}
7074
mavenPluginPlugin {
7175
id = "org.springframework.boot.maven-plugin"
7276
implementationClass = "org.springframework.boot.build.mavenplugin.MavenPluginPlugin"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2012-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.build.test;
18+
19+
import org.gradle.api.Plugin;
20+
import org.gradle.api.Project;
21+
import org.gradle.api.plugins.JavaPlugin;
22+
import org.gradle.api.plugins.JavaPluginConvention;
23+
import org.gradle.api.tasks.SourceSet;
24+
import org.gradle.api.tasks.SourceSetContainer;
25+
import org.gradle.api.tasks.testing.Test;
26+
import org.gradle.language.base.plugins.LifecycleBasePlugin;
27+
import org.gradle.plugins.ide.eclipse.EclipsePlugin;
28+
import org.gradle.plugins.ide.eclipse.model.EclipseModel;
29+
30+
/**
31+
* A {@link Plugin} to configure system testing support in a {@link Project}.
32+
*
33+
* @author Andy Wilkinson
34+
* @author Scott Frederick
35+
*/
36+
public class SystemTestPlugin implements Plugin<Project> {
37+
38+
/**
39+
* Name of the {@code systemTest} task.
40+
*/
41+
public static String SYSTEM_TEST_TASK_NAME = "systemTest";
42+
43+
/**
44+
* Name of the {@code systemTest} source set.
45+
*/
46+
public static String SYSTEM_TEST_SOURCE_SET_NAME = "systemTest";
47+
48+
@Override
49+
public void apply(Project project) {
50+
project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> configureSystemTesting(project));
51+
}
52+
53+
private void configureSystemTesting(Project project) {
54+
SourceSet systemTestSourceSet = createSourceSet(project);
55+
createTestTask(project, systemTestSourceSet);
56+
project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
57+
EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
58+
eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add(
59+
project.getConfigurations().getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName())));
60+
});
61+
}
62+
63+
private SourceSet createSourceSet(Project project) {
64+
SourceSetContainer sourceSets = project.getConvention().getPlugin(JavaPluginConvention.class).getSourceSets();
65+
SourceSet systemTestSourceSet = sourceSets.create(SYSTEM_TEST_SOURCE_SET_NAME);
66+
SourceSet mainSourceSet = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME);
67+
systemTestSourceSet
68+
.setCompileClasspath(systemTestSourceSet.getCompileClasspath().plus(mainSourceSet.getOutput()));
69+
systemTestSourceSet
70+
.setRuntimeClasspath(systemTestSourceSet.getRuntimeClasspath().plus(mainSourceSet.getOutput()));
71+
return systemTestSourceSet;
72+
}
73+
74+
private void createTestTask(Project project, SourceSet systemTestSourceSet) {
75+
Test systemTest = project.getTasks().create(SYSTEM_TEST_TASK_NAME, Test.class);
76+
systemTest.setGroup(LifecycleBasePlugin.VERIFICATION_GROUP);
77+
systemTest.setDescription("Runs system tests.");
78+
systemTest.setTestClassesDirs(systemTestSourceSet.getOutput().getClassesDirs());
79+
systemTest.setClasspath(systemTestSourceSet.getRuntimeClasspath());
80+
systemTest.shouldRunAfter(JavaPlugin.TEST_TASK_NAME);
81+
}
82+
83+
}

ci/pipeline.yml

+89
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ anchors:
4141
BRANCH: ((branch))
4242
<<: *gradle-enterprise-task-params
4343
<<: *docker-hub-task-params
44+
run-system-tests-task-params: &run-system-tests-task-params
45+
privileged: true
46+
timeout: ((task-timeout))
47+
file: git-repo/ci/tasks/run-system-tests.yml
48+
params:
49+
BRANCH: ((branch))
50+
<<: *gradle-enterprise-task-params
51+
<<: *docker-hub-task-params
4452
artifactory-repo-put-params: &artifactory-repo-put-params
4553
signing_key: ((signing-key))
4654
signing_passphrase: ((signing-passphrase))
@@ -165,6 +173,12 @@ resources:
165173
source:
166174
<<: *registry-image-resource-source
167175
repository: ((docker-hub-organization))/spring-boot-ci-jdk16
176+
- name: paketo-builder-base-image
177+
type: registry-image
178+
icon: docker
179+
source:
180+
repository: paketobuildpacks/builder
181+
tag: base
168182
- name: artifactory-repo
169183
type: artifactory-resource
170184
icon: package-variant
@@ -668,11 +682,86 @@ jobs:
668682
- put: homebrew-tap-repo
669683
params:
670684
repository: updated-homebrew-tap-repo
685+
- name: run-system-tests
686+
serial: true
687+
public: true
688+
plan:
689+
- get: ci-image
690+
- get: git-repo
691+
- get: paketo-builder-base-image
692+
trigger: true
693+
- get: daily
694+
trigger: true
695+
- do:
696+
- task: run-system-tests
697+
image: ci-image
698+
<<: *run-system-tests-task-params
699+
on_failure:
700+
do:
701+
- put: slack-alert
702+
params:
703+
<<: *slack-fail-params
704+
- put: slack-alert
705+
params:
706+
<<: *slack-success-params
707+
- name: jdk11-run-system-tests
708+
serial: true
709+
public: true
710+
plan:
711+
- get: ci-image-jdk11
712+
- get: git-repo
713+
- get: paketo-builder-base-image
714+
trigger: true
715+
- get: daily
716+
trigger: true
717+
- do:
718+
- task: run-system-tests
719+
image: ci-image-jdk11
720+
<<: *run-system-tests-task-params
721+
on_failure:
722+
do:
723+
- put: slack-alert
724+
params:
725+
<<: *slack-fail-params
726+
- put: slack-alert
727+
params:
728+
<<: *slack-success-params
729+
- name: jdk16-run-system-tests
730+
serial: true
731+
public: true
732+
plan:
733+
- get: ci-image-jdk16
734+
- get: git-repo
735+
- get: paketo-builder-base-image
736+
trigger: true
737+
- get: daily
738+
trigger: true
739+
- do:
740+
- task: run-system-tests
741+
image: ci-image-jdk16
742+
privileged: true
743+
timeout: ((task-timeout))
744+
file: git-repo/ci/tasks/run-system-tests.yml
745+
params:
746+
BRANCH: ((branch))
747+
TOOLCHAIN_JAVA_VERSION: 16
748+
<<: *gradle-enterprise-task-params
749+
<<: *docker-hub-task-params
750+
on_failure:
751+
do:
752+
- put: slack-alert
753+
params:
754+
<<: *slack-fail-params
755+
- put: slack-alert
756+
params:
757+
<<: *slack-success-params
671758
groups:
672759
- name: "builds"
673760
jobs: ["build", "jdk11-build", "jdk16-build", "windows-build"]
674761
- name: "releases"
675762
jobs: ["stage-milestone", "stage-rc", "stage-release", "promote-milestone", "promote-rc", "promote-release", "create-github-release", "publish-gradle-plugin", "publish-to-sdkman", "update-homebrew-tap"]
763+
- name: "system-tests"
764+
jobs: ["run-system-tests", "jdk11-run-system-tests", "jdk16-run-system-tests"]
676765
- name: "ci-images"
677766
jobs: ["build-ci-images", "detect-docker-updates", "detect-jdk-updates", "detect-ubuntu-image-updates"]
678767
- name: "pull-requests"

ci/scripts/run-system-tests.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/common.sh
5+
6+
pushd git-repo > /dev/null
7+
if [[ -d /opt/openjdk-toolchain ]]; then
8+
./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/
9+
else
10+
./gradlew -Dorg.gradle.internal.launcher.welcomeMessageEnabled=false --no-daemon --max-workers=4 --rerun-tasks systemTest
11+
fi
12+
popd > /dev/null

ci/tasks/run-system-tests.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
platform: linux
3+
inputs:
4+
- name: git-repo
5+
caches:
6+
- path: gradle
7+
params:
8+
BRANCH:
9+
CI: true
10+
GRADLE_ENTERPRISE_ACCESS_KEY:
11+
GRADLE_ENTERPRISE_CACHE_USERNAME:
12+
GRADLE_ENTERPRISE_CACHE_PASSWORD:
13+
GRADLE_ENTERPRISE_URL: https://ge.spring.io
14+
run:
15+
path: bash
16+
args:
17+
- -ec
18+
- |
19+
source /docker-lib.sh
20+
start_docker
21+
${PWD}/git-repo/ci/scripts/run-system-tests.sh

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ include "spring-boot-tests:spring-boot-integration-tests:spring-boot-configurati
7575
include "spring-boot-tests:spring-boot-integration-tests:spring-boot-launch-script-tests"
7676
include "spring-boot-tests:spring-boot-integration-tests:spring-boot-loader-tests"
7777
include "spring-boot-tests:spring-boot-integration-tests:spring-boot-server-tests"
78+
include "spring-boot-system-tests:spring-boot-image-tests"
7879

7980
file("${rootDir}/spring-boot-project/spring-boot-starters").eachDirMatch(~/spring-boot-starter.*/) {
8081
include "spring-boot-project:spring-boot-starters:${it.name}"

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/GettingStartedDocumentationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
2020
import org.junit.jupiter.api.extension.ExtendWith;
2121

2222
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
23-
import org.springframework.boot.gradle.testkit.GradleBuild;
23+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
2424

2525
/**
2626
* Tests for the getting started documentation.

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/IntegratingWithActuatorDocumentationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.junit.jupiter.api.extension.ExtendWith;
2626

2727
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
28-
import org.springframework.boot.gradle.testkit.GradleBuild;
28+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
2929

3030
import static org.assertj.core.api.Assertions.assertThat;
3131

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/ManagingDependenciesDocumentationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,8 +20,8 @@
2020
import org.junit.jupiter.api.extension.ExtendWith;
2121

2222
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
23-
import org.springframework.boot.gradle.testkit.Dsl;
24-
import org.springframework.boot.gradle.testkit.GradleBuild;
23+
import org.springframework.boot.testsupport.gradle.testkit.Dsl;
24+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
2525

2626
import static org.assertj.core.api.Assertions.assertThat;
2727
import static org.junit.jupiter.api.Assumptions.assumingThat;

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/PackagingDocumentationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import org.junit.jupiter.api.extension.ExtendWith;
3434

3535
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
36-
import org.springframework.boot.gradle.testkit.GradleBuild;
36+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
3737
import org.springframework.util.FileCopyUtils;
3838

3939
import static org.assertj.core.api.Assertions.assertThat;

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/PublishingDocumentationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.junit.jupiter.api.extension.ExtendWith;
2323

2424
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
25-
import org.springframework.boot.gradle.testkit.GradleBuild;
25+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
2626

2727
import static org.assertj.core.api.Assertions.assertThat;
2828

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/docs/RunningDocumentationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.junit.jupiter.api.extension.ExtendWith;
2828

2929
import org.springframework.boot.gradle.junit.GradleMultiDslExtension;
30-
import org.springframework.boot.gradle.testkit.GradleBuild;
30+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
3131

3232
import static org.assertj.core.api.Assertions.assertThat;
3333

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/dsl/BuildInfoDslIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
import org.springframework.boot.gradle.junit.GradleCompatibility;
2828
import org.springframework.boot.gradle.tasks.buildinfo.BuildInfo;
29-
import org.springframework.boot.gradle.testkit.GradleBuild;
29+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
3030

3131
import static org.assertj.core.api.Assertions.assertThat;
3232

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleBuildFieldSetter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@
2121
import org.junit.jupiter.api.extension.BeforeEachCallback;
2222
import org.junit.jupiter.api.extension.ExtensionContext;
2323

24-
import org.springframework.boot.gradle.testkit.GradleBuild;
24+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
2525
import org.springframework.util.ReflectionUtils;
2626

2727
/**

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.junit.jupiter.api.extension.ExtendWith;
2727
import org.junit.jupiter.api.extension.Extension;
2828

29-
import org.springframework.boot.gradle.testkit.GradleBuild;
29+
import org.springframework.boot.testsupport.gradle.testkit.GradleBuild;
3030

3131
/**
3232
* {@link Extension} that runs {@link TestTemplate templated tests} against multiple

0 commit comments

Comments
 (0)