Merge branch '2.7.x' into 3.0.x

Closes gh-37139
pull/37462/head
Moritz Halbritter 1 year ago
commit c749fcb478

@ -17,9 +17,12 @@
package org.springframework.boot.launchscript; package org.springframework.boot.launchscript;
import java.io.File; import java.io.File;
import java.net.URI;
import java.nio.file.Paths;
import java.time.Duration; import java.time.Duration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
import org.assertj.core.api.Condition; import org.assertj.core.api.Condition;
@ -43,9 +46,15 @@ import static org.hamcrest.Matchers.containsString;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Ali Shahbour * @author Ali Shahbour
* @author Alexey Vinogradov * @author Alexey Vinogradov
* @author Moritz Halbritter
*/ */
abstract class AbstractLaunchScriptIntegrationTests { 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; protected static final char ESC = 27;
private final String scriptsDir; private final String scriptsDir;
@ -100,8 +109,8 @@ abstract class AbstractLaunchScriptIntegrationTests {
private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) { private LaunchScriptTestContainer(String os, String version, String scriptsDir, String testScript) {
super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version) super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version)
.withFileFromFile("Dockerfile", .withDockerfile(Paths.get("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"))
new File("src/intTest/resources/conf/" + os + "/" + version + "/Dockerfile"))); .withBuildArg("JAVA_DOWNLOAD_URL", getJavaDownloadUrl()));
withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar"); withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), "/app.jar");
withCopyFileToContainer( withCopyFileToContainer(
MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"), MountableFile.forHostPath("src/intTest/resources/scripts/" + scriptsDir + "test-functions.sh"),
@ -114,6 +123,16 @@ abstract class AbstractLaunchScriptIntegrationTests {
withStartupCheckStrategy(new OneShotStartupCheckStrategy().withTimeout(Duration.ofMinutes(5))); 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() { private static File findApplication() {
String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-launch-script-tests-app"); String name = String.format("build/%1$s/build/libs/%1$s.jar", "spring-boot-launch-script-tests-app");
File jar = new File(name); 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;
}
}
}
} }

@ -19,13 +19,10 @@ package org.springframework.boot.launchscript;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; 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.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.boot.ansi.AnsiColor; import org.springframework.boot.ansi.AnsiColor;
import org.springframework.boot.testsupport.junit.DisabledOnOs;
import org.springframework.boot.testsupport.testcontainers.DisabledIfDockerUnavailable; import org.springframework.boot.testsupport.testcontainers.DisabledIfDockerUnavailable;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -36,10 +33,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Andy Wilkinson * @author Andy Wilkinson
* @author Ali Shahbour * @author Ali Shahbour
* @author Alexey Vinogradov * @author Alexey Vinogradov
* @author Moritz Halbritter
*/ */
@DisabledIfDockerUnavailable @DisabledIfDockerUnavailable
@DisabledOnOs(os = { OS.LINUX, OS.MAC }, architecture = "aarch64",
disabledReason = "The docker images have no ARM support")
class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrationTests { class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrationTests {
SysVinitLaunchScriptIntegrationTests() { SysVinitLaunchScriptIntegrationTests() {
@ -47,7 +43,7 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati
} }
static List<Object[]> parameters() { static List<Object[]> parameters() {
return filterParameters((file) -> !file.getName().contains("CentOS")); return filterParameters((file) -> !file.getName().contains("RedHat"));
} }
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@ -194,8 +190,6 @@ class SysVinitLaunchScriptIntegrationTests extends AbstractLaunchScriptIntegrati
@ParameterizedTest(name = "{0} {1}") @ParameterizedTest(name = "{0} {1}")
@MethodSource("parameters") @MethodSource("parameters")
void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception { 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"); doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh");
} }

@ -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

@ -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

@ -1,8 +1,9 @@
FROM ubuntu:jammy-20230624 FROM ubuntu:jammy-20230624
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y software-properties-common curl && \ apt-get install -y software-properties-common curl && \
mkdir -p /opt/openjdk && \ mkdir -p /opt/openjdk
cd /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
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 JAVA_HOME /opt/openjdk
ENV PATH $JAVA_HOME/bin:$PATH ENV PATH $JAVA_HOME/bin:$PATH
RUN cd /opt/openjdk && \
curl -L $JAVA_DOWNLOAD_URL | tar zx --strip-components=1

Loading…
Cancel
Save