diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/AbstractLaunchScriptIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/AbstractLaunchScriptIntegrationTests.java index 9dfc5cbd4ad..58fb2dbc2a0 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/AbstractLaunchScriptIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/AbstractLaunchScriptIntegrationTests.java @@ -17,9 +17,12 @@ 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; @@ -43,9 +46,15 @@ import static org.hamcrest.Matchers.containsString; * @author Andy Wilkinson * @author Ali Shahbour * @author Alexey Vinogradov + * @author Moritz Halbritter */ abstract class AbstractLaunchScriptIntegrationTests { + private static final Map 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; @@ -100,8 +109,8 @@ abstract class AbstractLaunchScriptIntegrationTests { private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) { super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version) - .withFileFromFile("Dockerfile", - new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"))); + .withDockerfile(Paths.get("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile")) + .withBuildArg("JAVA_DOWNLOAD_URL", getJavaDownloadUrl())); withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar"); withCopyFileToContainer( MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"), @@ -114,6 +123,16 @@ 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 File findApplication() { String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-launch-script-tests-app"); File jar = new File(name); @@ -123,4 +142,29 @@ 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": + return AMD64; + case "aarch64": + return AARCH64; + default: + return null; + } + } + + } + } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIntegrationTests.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIntegrationTests.java index 26f10fb169a..6fb4b23a4be 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIntegrationTests.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIntegrationTests.java @@ -19,13 +19,10 @@ package org.springframework.boot.launchscript; import java.util.List; import java.util.regex.Pattern; -import org.junit.jupiter.api.Assumptions; -import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import org.springframework.boot.ansi.AnsiColor; -import org.springframework.boot.testsupport.junit.DisabledOnOs; import org.springframework.boot.testsupport.testcontainers.DisabledIfDockerUnavailable; import static org.assertj.core.api.Assertions.assertThat; @@ -36,10 +33,9 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Andy Wilkinson * @author Ali Shahbour * @author Alexey Vinogradov + * @author Moritz Halbritter */ @DisabledIfDockerUnavailable -@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64", - disabledReason = "The docker images have no ARM support") class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrationTests { SysVinitLaunchScriptIntegrationTests() { @@ -47,7 +43,7 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati } static List parameters() { - return filterParameters((file) -> !file.getName().contains("CentOS")); + return filterParameters((file) -> !file.getName().contains("RedHat")); } @ParameterizedTest(name = "{0} {1}") @@ -194,8 +190,6 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception { - // CentOS doesn't have start-stop-daemon - Assumptions.assumeFalse(os.equals("CentOS")); doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh"); } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/CentOS/7.9.2009/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/CentOS/7.9.2009/Dockerfile deleted file mode 100644 index 323bb4cce64..00000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/CentOS/7.9.2009/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM centos:7.9.2009 -RUN mkdir -p /opt/openjdk && \ - cd /opt/openjdk && \ - curl -L https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz | tar zx --strip-components=1 -ENV JAVA_HOME /opt/openjdk -ENV PATH $JAVA_HOME/bin:$PATH diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/RedHat/ubi9-9.2-722/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/RedHat/ubi9-9.2-722/Dockerfile new file mode 100644 index 00000000000..bfb9ceeefb3 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/RedHat/ubi9-9.2-722/Dockerfile @@ -0,0 +1,7 @@ +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 +ENV PATH $JAVA_HOME/bin:$PATH +RUN mkdir -p /opt/openjdk && \ + cd /opt/openjdk && \ + curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1 diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/Ubuntu/jammy-20230624/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/Ubuntu/jammy-20230624/Dockerfile index 4f52307276c..08f1f6b76cc 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/Ubuntu/jammy-20230624/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/intTest/resources/conf/Ubuntu/jammy-20230624/Dockerfile @@ -1,8 +1,9 @@ FROM ubuntu:jammy-20230624 RUN apt-get update && \ apt-get install -y software-properties-common curl && \ - mkdir -p /opt/openjdk && \ - cd /opt/openjdk && \ - curl -L https://github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.1%2B12/OpenJDK17U-jdk_x64_linux_hotspot_17.0.1_12.tar.gz | tar zx --strip-components=1 + 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 ENV PATH $JAVA_HOME/bin:$PATH +RUN cd /opt/openjdk && \ + curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1