mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Make JarLaunchScript and SysVinit integration tests ARM64 compatible
Closes gh-36799
This commit is contained in:
parent
d1bf1b3e15
commit
0f6342a882
@ -17,9 +17,14 @@
|
||||
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.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
@ -43,9 +48,20 @@ 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<Architecture, URI> JAVA_DOWNLOAD_URLS;
|
||||
static {
|
||||
Map<Architecture, URI> urls = new HashMap<>();
|
||||
urls.put(Architecture.AMD64,
|
||||
URI.create("https://download.bell-sw.com/java/8u382+6/bellsoft-jdk8u382+6-linux-amd64.tar.gz"));
|
||||
urls.put(Architecture.AARCH64,
|
||||
URI.create("https://download.bell-sw.com/java/8u382+6/bellsoft-jdk8u382+6-linux-aarch64.tar.gz"));
|
||||
JAVA_DOWNLOAD_URLS = Collections.unmodifiableMap(urls);
|
||||
}
|
||||
|
||||
protected static final char ESC = 27;
|
||||
|
||||
private final String scriptsDir;
|
||||
@ -100,8 +116,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 +130,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 +149,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.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<Object[]> parameters() {
|
||||
return parameters((file) -> !file.getName().contains("CentOS"));
|
||||
return parameters((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");
|
||||
}
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
FROM centos:7.9.2009
|
||||
RUN mkdir -p /opt/openjdk && \
|
||||
cd /opt/openjdk && \
|
||||
curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u202b08.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/8u382+6/bellsoft-jdk8u382+6-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
|
||||
RUN apt-get update && \
|
||||
apt-get install -y software-properties-common curl && \
|
||||
mkdir -p /opt/openjdk && \
|
||||
cd /opt/openjdk && \
|
||||
curl -L https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_linux_hotspot_8u202b08.tar.gz | tar zx --strip-components=1
|
||||
mkdir -p /opt/openjdk
|
||||
ARG JAVA_DOWNLOAD_URL=https://download.bell-sw.com/java/8u382+6/bellsoft-jdk8u382+6-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
|
||||
|
Loading…
Reference in New Issue
Block a user