Merge branch '3.1.x'

Closes gh-37741
pull/37745/head
Phillip Webb 1 year ago
commit b0b3adb1b7

@ -29,6 +29,7 @@ dependencies {
implementation("com.fasterxml.jackson.core:jackson-databind:2.11.4")
implementation("com.gradle:gradle-enterprise-gradle-plugin:3.12.1")
implementation("com.tngtech.archunit:archunit:1.0.0")
implementation("de.undercouch.download:de.undercouch.download.gradle.plugin:5.5.0")
implementation("commons-codec:commons-codec:1.13")
implementation("io.spring.javaformat:spring-javaformat-gradle-plugin:${javaFormatVersion}")
implementation("org.apache.maven:maven-embedder:3.6.3")

@ -7,6 +7,7 @@ outputs:
- name: git-repo
caches:
- path: gradle
- path: build/downloads
- path: embedmongo
params:
BRANCH:

@ -2,10 +2,14 @@ plugins {
id "java"
id "org.springframework.boot.conventions"
id "org.springframework.boot.integration-test"
id "de.undercouch.download"
}
description = "Spring Boot Launch Script Integration Tests"
def jdkVersion = "17.0.8.1+1"
def jdkArch = "aarch64".equalsIgnoreCase(System.getProperty("os.arch")) ? "aarch64" : "amd64"
configurations {
app
}
@ -38,6 +42,26 @@ task buildApp(type: GradleBuild) {
tasks = ["build"]
}
task downloadJdk(type: Download) {
def destFolder = new File(rootProject.buildDir, "downloads/jdk/bellsoft")
destFolder.mkdirs()
src "https://download.bell-sw.com/java/${jdkVersion}/bellsoft-jdk${jdkVersion}-linux-${jdkArch}.tar.gz"
dest destFolder
tempAndMove true
overwrite false
}
task syncJdkDownloads(type: Sync) {
dependsOn downloadJdk
from "${rootProject.buildDir}/downloads/jdk/bellsoft/"
include "bellsoft-jdk${jdkVersion}-linux-${jdkArch}.tar.gz"
into "${project.buildDir}/downloads/jdk/bellsoft/"
}
processIntTestResources {
dependsOn syncJdkDownloads
}
intTest {
dependsOn buildApp
}

@ -17,12 +17,9 @@
package org.springframework.boot.launchscript;
import java.io.File;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import org.assertj.core.api.Condition;
@ -50,11 +47,6 @@ import static org.hamcrest.Matchers.containsString;
*/
abstract class AbstractLaunchScriptIntegrationTests {
private static final Map<Architecture, URI> JAVA_DOWNLOAD_URLS = Map.of(Architecture.AMD64,
URI.create("https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz"),
Architecture.AARCH64,
URI.create("https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-aarch64.tar.gz"));
protected static final char ESC = 27;
private final String scriptsDir;
@ -108,9 +100,7 @@ abstract class AbstractLaunchScriptIntegrationTests {
private static final class LaunchScriptTestContainer extends GenericContainer<LaunchScriptTestContainer> {
private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) {
super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version)
.withDockerfile(Paths.get("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"))
.withBuildArg("JAVA_DOWNLOAD_URL", getJavaDownloadUrl()));
super(createImage(os, version));
withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar");
withCopyFileToContainer(
MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"),
@ -123,14 +113,15 @@ abstract class AbstractLaunchScriptIntegrationTests {
withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5)));
}
private static String getJavaDownloadUrl() {
Architecture architecture = Architecture.current();
Assert.notNull(architecture,
() -> String.format("Failed to find current architecture. Value of os.arch is: '%s'",
System.getProperty("os.arch")));
URI uri = JAVA_DOWNLOAD_URLS.get(architecture);
Assert.notNull(uri, () -> String.format("No JDK download URL for architecture %s found", architecture));
return uri.toString();
private static ImageFromDockerfile createImage(String os, String version) {
ImageFromDockerfile image = new ImageFromDockerfile(
"spring-boot-launch-script/" + os.toLowerCase() + "-" + version);
image.withFileFromFile("Dockerfile",
new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"));
for (File file : new File("build/downloads/jdk/bellsoft").listFiles()) {
image.withFileFromFile("downloads/" + file.getName(), file);
}
return image;
}
private static File findApplication() {
@ -142,30 +133,4 @@ abstract class AbstractLaunchScriptIntegrationTests {
}
private enum Architecture {
AMD64, AARCH64;
/**
* Returns the current architecture.
* @return the current architecture or {@code null}
*/
static Architecture current() {
String arch = System.getProperty("os.arch");
if (arch == null) {
return null;
}
switch (arch) {
case "amd64":
case "x86_64":
return AMD64;
case "aarch64":
return AARCH64;
default:
return null;
}
}
}
}

@ -1,7 +1,10 @@
FROM redhat/ubi9:9.2-722 as prepare
COPY downloads/* /opt/download/
RUN mkdir -p /opt/jdk && \
cd /opt/jdk && \
tar xzf /opt/download/* --strip-components=1
FROM redhat/ubi9:9.2-722
ARG JAVA_DOWNLOAD_URL=https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz
ENV JAVA_HOME /opt/openjdk
COPY --from=prepare /opt/jdk /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV PATH $JAVA_HOME/bin:$PATH
RUN mkdir -p /opt/openjdk && \
cd /opt/openjdk && \
curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1

@ -1,9 +1,11 @@
FROM ubuntu:jammy-20230624 as prepare
COPY downloads/* /opt/download/
RUN mkdir -p /opt/jdk && \
cd /opt/jdk && \
tar xzf /opt/download/* --strip-components=1
FROM ubuntu:jammy-20230624
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
mkdir -p /opt/openjdk
ARG JAVA_DOWNLOAD_URL=https://download.bell-sw.com/java/17.0.8.1+1/bellsoft-jdk17.0.8.1+1-linux-amd64.tar.gz
ENV JAVA_HOME /opt/openjdk
RUN apt-get update && apt-get install -y software-properties-common curl
COPY --from=prepare /opt/jdk /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV PATH $JAVA_HOME/bin:$PATH
RUN cd /opt/openjdk && \
curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1

@ -2,10 +2,14 @@ plugins {
id "java"
id "org.springframework.boot.conventions"
id "org.springframework.boot.integration-test"
id "de.undercouch.download"
}
description = "Spring Boot Loader Integration Tests"
def oracleJdkVersion = "17.0.8"
def oracleJdkArch = "aarch64".equalsIgnoreCase(System.getProperty("os.arch")) ? "aarch64" : "x86"
configurations {
app
}
@ -39,6 +43,26 @@ task buildApp(type: GradleBuild) {
tasks = ["build"]
}
task downloadJdk(type: Download) {
def destFolder = new File(rootProject.buildDir, "downloads/jdk/oracle")
destFolder.mkdirs()
src "https://download.oracle.com/java/17/archive/jdk-${oracleJdkVersion}_linux-${oracleJdkArch}_bin.tar.gz"
dest destFolder
tempAndMove true
overwrite false
}
task syncJdkDownloads(type: Sync) {
dependsOn downloadJdk
from "${rootProject.buildDir}/downloads/jdk/oracle/"
include "jdk-${oracleJdkVersion}_linux-${oracleJdkArch}_bin.tar.gz"
into "${project.buildDir}/downloads/jdk/oracle/"
}
processIntTestResources {
dependsOn syncJdkDownloads
}
intTest {
dependsOn buildApp
}

@ -127,10 +127,11 @@ class LoaderIntegrationTests {
}
static JavaRuntime oracleJdk17() {
String arch = System.getProperty("os.arch");
String dockerFile = ("aarch64".equals(arch)) ? "Dockerfile-aarch64" : "Dockerfile";
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk-17")
.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/" + dockerFile));
ImageFromDockerfile image = new ImageFromDockerfile("spring-boot-loader/oracle-jdk");
image.withFileFromFile("Dockerfile", new File("src/intTest/resources/conf/oracle-jdk-17/Dockerfile"));
for (File file : new File("build/downloads/jdk/oracle").listFiles()) {
image.withFileFromFile("downloads/" + file.getName(), file);
}
return new JavaRuntime("Oracle JDK 17", JavaVersion.SEVENTEEN, () -> new GenericContainer<>(image));
}

@ -1,8 +1,10 @@
FROM ubuntu:jammy-20230624 as prepare
COPY downloads/* /opt/download/
RUN mkdir -p /opt/jdk && \
cd /opt/jdk && \
tar xzf /opt/download/* --strip-components=1
FROM ubuntu:jammy-20230624
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
mkdir -p /opt/oraclejdk && \
cd /opt/oraclejdk && \
curl -L https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz | tar zx --strip-components=1
ENV JAVA_HOME /opt/oraclejdk
COPY --from=prepare /opt/jdk /opt/jdk
ENV JAVA_HOME /opt/jdk
ENV PATH $JAVA_HOME/bin:$PATH

@ -1,8 +0,0 @@
FROM ubuntu:jammy-20230624
RUN apt-get update && \
apt-get install -y software-properties-common curl && \
mkdir -p /opt/oraclejdk && \
cd /opt/oraclejdk && \
curl -L https://download.oracle.com/java/17/archive/jdk-17.0.8_linux-aarch64_bin.tar.gz | tar zx --strip-components=1
ENV JAVA_HOME /opt/oraclejdk
ENV PATH $JAVA_HOME/bin:$PATH
Loading…
Cancel
Save