From 02a6a84499da4c20c23733565027466a7d6d5c53 Mon Sep 17 00:00:00 2001 From: Alexey Vinogradov Date: Tue, 28 Apr 2020 20:15:38 +0700 Subject: [PATCH 1/2] Test the launch script when executed directly See gh-21388 --- .../launchscript/AbstractLaunchScriptIT.java | 114 ++++++++++++++ .../launchscript/ShellLaunchScriptIT.java | 66 ++++++++ .../launchscript/SysVinitLaunchScriptIT.java | 142 ++++-------------- .../conf/CentOS/6.9-a23bced6/Dockerfile | 4 +- .../conf/Ubuntu/trusty-20160914/Dockerfile | 4 +- .../conf/Ubuntu/xenial-20160914/Dockerfile | 4 +- .../scripts/{ => init.d}/basic-launch.sh | 1 + .../{ => init.d}/force-stop-when-stopped.sh | 1 + ...launch-with-double-link-single-java-opt.sh | 1 + .../launch-with-missing-log-folder.sh | 1 + .../launch-with-missing-pid-folder.sh | 1 + ...ch-with-multiple-command-line-arguments.sh | 1 + .../launch-with-multiple-java-opts.sh | 1 + .../launch-with-multiple-run-args.sh | 1 + .../launch-with-relative-log-folder.sh | 1 + .../launch-with-relative-pid-folder.sh | 1 + .../launch-with-run-as-invalid-user.sh | 1 + ...with-run-as-user-preferred-to-jar-owner.sh | 1 + .../launch-with-run-as-user-root-required.sh | 1 + .../{ => init.d}/launch-with-run-as-user.sh | 1 + ...aunch-with-single-command-line-argument.sh | 1 + .../launch-with-single-java-opt.sh | 1 + .../launch-with-single-run-arg.sh | 1 + ...-with-use-of-start-stop-daemon-disabled.sh | 1 + ...-file-ownership-is-changed-when-created.sh | 1 + ...file-ownership-is-unchanged-when-exists.sh | 1 + .../{ => init.d}/log-file-ownership.sh | 1 + .../{ => init.d}/pid-file-ownership.sh | 1 + .../{ => init.d}/pid-folder-ownership.sh | 1 + .../{ => init.d}/restart-when-started.sh | 1 + .../{ => init.d}/restart-when-stopped.sh | 1 + .../{ => init.d}/start-when-started.sh | 1 + .../{ => init.d}/start-when-stopped.sh | 1 + .../{ => init.d}/status-when-killed.sh | 1 + .../{ => init.d}/status-when-started.sh | 1 + .../{ => init.d}/status-when-stopped.sh | 1 + .../scripts/{ => init.d}/stop-when-stopped.sh | 1 + .../scripts/init.d/test-functions.sh | 36 +++++ .../resources/scripts/jar/basic-launch.sh | 4 + .../scripts/jar/launch-in-init.d-dir.sh | 5 + .../scripts/jar/launch-with-app-name.sh | 27 ++++ .../scripts/jar/launch-with-debug.sh | 5 + .../scripts/jar/launch-with-jarfile.sh | 6 + .../resources/scripts/jar/test-functions.sh | 3 + .../test/resources/scripts/test-functions.sh | 35 ----- 45 files changed, 338 insertions(+), 148 deletions(-) create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/basic-launch.sh (74%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/force-stop-when-stopped.sh (70%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-double-link-single-java-opt.sh (85%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-missing-log-folder.sh (83%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-missing-pid-folder.sh (83%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-multiple-command-line-arguments.sh (84%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-multiple-java-opts.sh (87%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-multiple-run-args.sh (87%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-relative-log-folder.sh (87%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-relative-pid-folder.sh (89%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-run-as-invalid-user.sh (80%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-run-as-user-preferred-to-jar-owner.sh (87%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-run-as-user-root-required.sh (88%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-run-as-user.sh (84%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-single-command-line-argument.sh (80%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-single-java-opt.sh (85%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-single-run-arg.sh (85%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/launch-with-use-of-start-stop-daemon-disabled.sh (85%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/log-file-ownership-is-changed-when-created.sh (88%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/log-file-ownership-is-unchanged-when-exists.sh (91%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/log-file-ownership.sh (90%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/pid-file-ownership.sh (89%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/pid-folder-ownership.sh (88%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/restart-when-started.sh (86%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/restart-when-stopped.sh (80%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/start-when-started.sh (81%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/start-when-stopped.sh (80%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/status-when-killed.sh (83%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/status-when-started.sh (81%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/status-when-stopped.sh (69%) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/{ => init.d}/stop-when-stopped.sh (68%) create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh create mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java new file mode 100644 index 0000000000..41f02619b3 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java @@ -0,0 +1,114 @@ +/* + * Copyright 2012-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.launchscript; + +import java.io.File; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +import org.assertj.core.api.Condition; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.ToStringConsumer; +import org.testcontainers.images.builder.ImageFromDockerfile; +import org.testcontainers.utility.MountableFile; + +import org.springframework.boot.ansi.AnsiColor; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.hamcrest.Matchers.containsString; + +/** + * Abstract base class for testing the launch script. + * + * @author Alexey Vinogradov + */ +abstract class AbstractLaunchScriptIT { + + protected static final char ESC = 27; + + static List parameters() { + List parameters = new ArrayList<>(); + for (File os : new File("src/test/resources/conf").listFiles()) { + for (File version : os.listFiles()) { + parameters.add(new Object[] { os.getName(), version.getName() }); + } + } + return parameters; + } + + protected Condition coloredString(AnsiColor color, String string) { + String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m"; + return new Condition() { + + @Override + public boolean matches(String value) { + return containsString(colorString).matches(value); + } + + }; + } + + protected void doLaunch(String os, String version, String script) throws Exception { + assertThat(doTest(os, version, script)).contains("Launched"); + } + + protected String doTest(String os, String version, String script) throws Exception { + ToStringConsumer consumer = new ToStringConsumer().withRemoveAnsiCodes(false); + try (LaunchScriptTestContainer container = new LaunchScriptTestContainer(os, version, script)) { + container.withLogConsumer(consumer); + container.start(); + while (container.isRunning()) { + Thread.sleep(100); + } + } + return consumer.toUtf8String(); + } + + private static final class LaunchScriptTestContainer extends GenericContainer { + + private LaunchScriptTestContainer(String os, String version, String testScript) { + super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version) + .withFileFromFile("Dockerfile", + new File("src/test/resources/conf/" + os + "/" + version + "/Dockerfile")) + .withFileFromFile("spring-boot-launch-script-tests.jar", findApplication()) + .withFileFromFile("test-functions.sh", new File("src/test/resources/scripts/test-functions.sh")) + .withFileFromFile("jar/test-functions.sh", + new File("src/test/resources/scripts/jar/test-functions.sh")) + .withFileFromFile("init.d/test-functions.sh", + new File("src/test/resources/scripts/init.d/test-functions.sh"))); + withCopyFileToContainer(MountableFile.forHostPath("src/test/resources/scripts/" + testScript), + "/" + testScript); + withCommand("/bin/bash", "-c", "chmod +x " + testScript + " && ./" + testScript); + withStartupTimeout(Duration.ofMinutes(10)); + } + + private static File findApplication() { + File targetDir = new File("target"); + for (File file : targetDir.listFiles()) { + if (file.getName().startsWith("spring-boot-launch-script-tests") && file.getName().endsWith(".jar") + && !file.getName().endsWith("-sources.jar")) { + return file; + } + } + throw new IllegalStateException( + "Could not find test application in target directory. Have you built it (mvn package)?"); + } + + } + +} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java new file mode 100644 index 0000000000..01265fdc73 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java @@ -0,0 +1,66 @@ +/* + * Copyright 2012-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.launchscript; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration tests of Spring Boot's launch script with launching via shell. + * + * @author Alexey Vinogradov + */ +class ShellLaunchScriptIT extends AbstractLaunchScriptIT { + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void basicLaunch(String os, String version) throws Exception { + doLaunch(os, version, "jar/basic-launch.sh"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithDebugEnv(String os, String version) throws Exception { + final String output = doTest(os, version, "jar/launch-with-debug.sh"); + assertThat(output).contains("++ pwd"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithDifferentJarFileEnv(String os, String version) throws Exception { + final String output = doTest(os, version, "jar/launch-with-jarfile.sh"); + assertThat(output).contains("app-another.jar"); + assertThat(output).doesNotContain("spring-boot-launch-script-tests.jar"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithDifferentAppName(String os, String version) throws Exception { + final String output = doTest(os, version, "jar/launch-with-app-name.sh"); + assertThat(output).contains("All tests are passed."); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchInInitdDir(String os, String version) throws Exception { + final String output = doTest(os, version, "jar/launch-in-init.d-dir.sh"); + assertThat(output).contains("Usage: ./some_app {start|stop|force-stop|restart|force-reload|status|run}"); + } + +} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java index a4014dcb47..82c209b92f 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java @@ -16,25 +16,15 @@ package org.springframework.boot.launchscript; -import java.io.File; -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; import java.util.regex.Pattern; -import org.assertj.core.api.Condition; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.output.ToStringConsumer; -import org.testcontainers.images.builder.ImageFromDockerfile; -import org.testcontainers.utility.MountableFile; import org.springframework.boot.ansi.AnsiColor; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.containsString; /** * Integration tests for Spring Boot's launch script on OSs that use SysVinit. @@ -42,14 +32,12 @@ import static org.hamcrest.Matchers.containsString; * @author Andy Wilkinson * @author Ali Shahbour */ -class SysVinitLaunchScriptIT { - - private static final char ESC = 27; +class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "status-when-stopped.sh"); + String output = doTest(os, version, "init.d/status-when-stopped.sh"); assertThat(output).contains("Status: 3"); assertThat(output).has(coloredString(AnsiColor.RED, "Not running")); } @@ -57,7 +45,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "status-when-started.sh"); + String output = doTest(os, version, "init.d/status-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); } @@ -65,7 +53,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenKilled(String os, String version) throws Exception { - String output = doTest(os, version, "status-when-killed.sh"); + String output = doTest(os, version, "init.d/status-when-killed.sh"); assertThat(output).contains("Status: 1"); assertThat(output) .has(coloredString(AnsiColor.RED, "Not running (process " + extractPid(output) + " not found)")); @@ -74,7 +62,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void stopWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "stop-when-stopped.sh"); + String output = doTest(os, version, "init.d/stop-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); } @@ -82,7 +70,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void forceStopWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "force-stop-when-stopped.sh"); + String output = doTest(os, version, "init.d/force-stop-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); } @@ -90,7 +78,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void startWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "start-when-started.sh"); + String output = doTest(os, version, "init.d/start-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Already running [" + extractPid(output) + "]")); } @@ -98,7 +86,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void restartWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "restart-when-stopped.sh"); + String output = doTest(os, version, "init.d/restart-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); @@ -107,7 +95,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void restartWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "restart-when-started.sh"); + String output = doTest(os, version, "init.d/restart-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extract("PID1", output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Stopped [" + extract("PID1", output) + "]")); @@ -117,7 +105,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void startWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "start-when-stopped.sh"); + String output = doTest(os, version, "init.d/start-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); } @@ -125,14 +113,14 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void basicLaunch(String os, String version) throws Exception { - String output = doTest(os, version, "basic-launch.sh"); + String output = doTest(os, version, "init.d/basic-launch.sh"); assertThat(output).doesNotContain("PID_FOLDER"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-missing-log-folder.sh"); + String output = doTest(os, version, "init.d/launch-with-missing-log-folder.sh"); assertThat(output).has( coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp")); } @@ -140,7 +128,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-missing-pid-folder.sh"); + String output = doTest(os, version, "init.d/launch-with-missing-pid-folder.sh"); assertThat(output).has( coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp")); } @@ -148,43 +136,43 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleCommandLineArgument(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-single-command-line-argument.sh"); + doLaunch(os, version, "init.d/launch-with-single-command-line-argument.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleCommandLineArguments(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh"); + doLaunch(os, version, "init.d/launch-with-multiple-command-line-arguments.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleRunArg(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-single-run-arg.sh"); + doLaunch(os, version, "init.d/launch-with-single-run-arg.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleRunArgs(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-multiple-run-args.sh"); + doLaunch(os, version, "init.d/launch-with-multiple-run-args.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleJavaOpt(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-single-java-opt.sh"); + doLaunch(os, version, "init.d/launch-with-single-java-opt.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-double-link-single-java-opt.sh"); + doLaunch(os, version, "init.d/launch-with-double-link-single-java-opt.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleJavaOpts(String os, String version) throws Exception { - doLaunch(os, version, "launch-with-multiple-java-opts.sh"); + doLaunch(os, version, "init.d/launch-with-multiple-java-opts.sh"); } @ParameterizedTest(name = "{0} {1}") @@ -192,13 +180,13 @@ class SysVinitLaunchScriptIT { 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, "init.d/launch-with-use-of-start-stop-daemon-disabled.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRelativePidFolder(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-relative-pid-folder.sh"); + String output = doTest(os, version, "init.d/launch-with-relative-pid-folder.sh"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Stopped [" + extractPid(output) + "]")); @@ -207,56 +195,56 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void pidFolderOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "pid-folder-ownership.sh"); + String output = doTest(os, version, "init.d/pid-folder-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void pidFileOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "pid-file-ownership.sh"); + String output = doTest(os, version, "init.d/pid-file-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "log-file-ownership.sh"); + String output = doTest(os, version, "init.d/log-file-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception { - String output = doTest(os, version, "log-file-ownership-is-changed-when-created.sh"); + String output = doTest(os, version, "init.d/log-file-ownership-is-changed-when-created.sh"); assertThat(output).contains("andy root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception { - String output = doTest(os, version, "log-file-ownership-is-unchanged-when-exists.sh"); + String output = doTest(os, version, "init.d/log-file-ownership-is-unchanged-when-exists.sh"); assertThat(output).contains("root root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRelativeLogFolder(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-relative-log-folder.sh"); + String output = doTest(os, version, "init.d/launch-with-relative-log-folder.sh"); assertThat(output).contains("Log written"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRunAsUser(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-run-as-user.sh"); + String output = doTest(os, version, "init.d/launch-with-run-as-user.sh"); assertThat(output).contains("wagner root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-run-as-invalid-user.sh"); + String output = doTest(os, version, "init.d/launch-with-run-as-invalid-user.sh"); assertThat(output).contains("Status: 2"); assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user")); } @@ -264,7 +252,7 @@ class SysVinitLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-run-as-user-preferred-to-jar-owner.sh"); + String output = doTest(os, version, "init.d/launch-with-run-as-user-preferred-to-jar-owner.sh"); assertThat(output).contains("wagner root"); } @@ -272,49 +260,11 @@ class SysVinitLaunchScriptIT { @MethodSource("parameters") void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os, String version) throws Exception { - String output = doTest(os, version, "launch-with-run-as-user-root-required.sh"); + String output = doTest(os, version, "init.d/launch-with-run-as-user-root-required.sh"); assertThat(output).contains("Status: 4"); assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'wagner': current user is not root")); } - static List parameters() { - List parameters = new ArrayList<>(); - for (File os : new File("src/test/resources/conf").listFiles()) { - for (File version : os.listFiles()) { - parameters.add(new Object[] { os.getName(), version.getName() }); - } - } - return parameters; - } - - private void doLaunch(String os, String version, String script) throws Exception { - assertThat(doTest(os, version, script)).contains("Launched"); - } - - private String doTest(String os, String version, String script) throws Exception { - ToStringConsumer consumer = new ToStringConsumer().withRemoveAnsiCodes(false); - try (LaunchScriptTestContainer container = new LaunchScriptTestContainer(os, version, script)) { - container.withLogConsumer(consumer); - container.start(); - while (container.isRunning()) { - Thread.sleep(100); - } - } - return consumer.toUtf8String(); - } - - private Condition coloredString(AnsiColor color, String string) { - String colorString = ESC + "[0;" + color + "m" + string + ESC + "[0m"; - return new Condition() { - - @Override - public boolean matches(String value) { - return containsString(colorString).matches(value); - } - - }; - } - private String extractPid(String output) { return extract("PID", output); } @@ -328,32 +278,4 @@ class SysVinitLaunchScriptIT { throw new IllegalArgumentException("Failed to extract " + label + " from output: " + output); } - private static final class LaunchScriptTestContainer extends GenericContainer { - - private LaunchScriptTestContainer(String os, String version, String testScript) { - super(new ImageFromDockerfile("spring-boot-launch-script/" + os.toLowerCase() + "-" + version) - .withFileFromFile("Dockerfile", - new File("src/test/resources/conf/" + os + "/" + version + "/Dockerfile")) - .withFileFromFile("spring-boot-launch-script-tests.jar", findApplication()) - .withFileFromFile("test-functions.sh", new File("src/test/resources/scripts/test-functions.sh"))); - withCopyFileToContainer(MountableFile.forHostPath("src/test/resources/scripts/" + testScript), - "/" + testScript); - withCommand("/bin/bash", "-c", "chmod +x " + testScript + " && ./" + testScript); - withStartupTimeout(Duration.ofMinutes(10)); - } - - private static File findApplication() { - File targetDir = new File("target"); - for (File file : targetDir.listFiles()) { - if (file.getName().startsWith("spring-boot-launch-script-tests") && file.getName().endsWith(".jar") - && !file.getName().endsWith("-sources.jar")) { - return file; - } - } - throw new IllegalStateException( - "Could not find test application in target directory. Have you built it (mvn package)?"); - } - - } - } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile index 70513764d0..8a93884e95 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile @@ -8,4 +8,6 @@ RUN yum install -y wget && \ yum --nogpg localinstall -y jdk.rpm && \ rm -f jdk.rpm ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh \ No newline at end of file +ADD test-functions.sh /test-functions.sh +ADD init.d/test-functions.sh /init.d/test-functions.sh +ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile index cf95d7cacf..f33c6f30f6 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile @@ -7,4 +7,6 @@ RUN apt-get update && \ ENV JAVA_HOME /opt/openjdk ENV PATH $JAVA_HOME/bin:$PATH ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh \ No newline at end of file +ADD test-functions.sh /test-functions.sh +ADD init.d/test-functions.sh /init.d/test-functions.sh +ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile index d1a37468b5..167d142a56 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile @@ -7,4 +7,6 @@ RUN apt-get update && \ ENV JAVA_HOME /opt/openjdk ENV PATH $JAVA_HOME/bin:$PATH ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh \ No newline at end of file +ADD test-functions.sh /test-functions.sh +ADD init.d/test-functions.sh /init.d/test-functions.sh +ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/basic-launch.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh similarity index 74% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/basic-launch.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh index 44f44a856c..2a0501d43c 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/basic-launch.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service await_app diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh similarity index 70% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh index 465b555329..9a90ebd55e 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/force-stop-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service force_stop_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-double-link-single-java-opt.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh similarity index 85% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-double-link-single-java-opt.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh index 6895c0d061..13ee6cbc01 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-double-link-single-java-opt.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_double_link_service echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-log-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh similarity index 83% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-log-folder.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh index 1f3aed3844..25962027a6 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-log-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-pid-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh similarity index 83% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-pid-folder.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh index 83430bea62..5ee6d5d2b5 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-missing-pid-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'PID_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-command-line-arguments.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh similarity index 84% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-command-line-arguments.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh index 7503458301..97011d797f 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-command-line-arguments.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service --server.port=8081 --server.servlet.context-path=/test await_app http://127.0.0.1:8081/test/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-java-opts.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh similarity index 87% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-java-opts.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh index 387ad47dad..9cfc9a0ccb 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-java-opts.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'JAVA_OPTS="-Dserver.port=8081 -Dserver.servlet.context-path=/test"' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-run-args.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh similarity index 87% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-run-args.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh index 76b4c47679..c9942a9953 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-multiple-run-args.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'RUN_ARGS="--server.port=8081 --server.servlet.context-path=/test"' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-log-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh similarity index 87% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-log-folder.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh index da1f7b11c1..44567b41c1 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-log-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh mkdir ./pid install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-pid-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh similarity index 89% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-pid-folder.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh index a46d67b8a2..d129bc2bf7 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-relative-pid-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service mkdir /test-service/pid echo 'PID_FOLDER=pid' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-invalid-user.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh similarity index 80% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-invalid-user.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh index f6384046dc..0e9cda7990 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-invalid-user.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'RUN_AS_USER=johndoe' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-preferred-to-jar-owner.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh similarity index 87% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-preferred-to-jar-owner.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh index 730b8197bb..09beabddda 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-preferred-to-jar-owner.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-root-required.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh similarity index 88% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-root-required.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh index 3cd83374e2..82ecfa697e 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user-root-required.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh similarity index 84% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh index 6be8eee0f0..23d95545d5 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-run-as-user.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-command-line-argument.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh similarity index 80% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-command-line-argument.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh index 2adb76da3f..b327005630 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-command-line-argument.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service --server.port=8081 await_app http://127.0.0.1:8081/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-java-opt.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh similarity index 85% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-java-opt.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh index a0445b8224..16940da02d 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-java-opt.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-run-arg.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh similarity index 85% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-run-arg.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh index 0d61c5d154..2b8297c85c 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-single-run-arg.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'RUN_ARGS=--server.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-use-of-start-stop-daemon-disabled.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh similarity index 85% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-use-of-start-stop-daemon-disabled.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh index 2f2bd3dfad..e4d7f7c18a 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/launch-with-use-of-start-stop-daemon-disabled.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh chmod -x $(type -p start-stop-daemon) install_service echo 'USE_START_STOP_DAEMON=false' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-changed-when-created.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh similarity index 88% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-changed-when-created.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh index 5cc9eb46fc..41ce4a6187 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-changed-when-created.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf mkdir -p /test-service/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-unchanged-when-exists.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh similarity index 91% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-unchanged-when-exists.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh index 685e1e6100..e80d725cb1 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership-is-unchanged-when-exists.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf mkdir -p /test-service/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh similarity index 90% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh index 919c33e380..4a127e10a5 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/log-file-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service chmod o+w /var/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-file-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh similarity index 89% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-file-ownership.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh index 891bb935fa..ec201d076b 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-file-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service useradd phil diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-folder-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh similarity index 88% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-folder-ownership.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh index c6b7d19c09..eadc51f779 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/pid-folder-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service chmod o+w /var/run diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh similarity index 86% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-started.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh index 017b4c18e8..becd1041a1 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service echo "PID1: $(cat /var/run/spring-boot-app/spring-boot-app.pid)" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh similarity index 80% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-stopped.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh index 95fd91c3b4..9cbc8f5cfa 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/restart-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service restart_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh similarity index 81% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-started.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh index fd9e4f2f6b..e2366afffe 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh similarity index 80% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-stopped.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh index 427fff4406..4146795351 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/start-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-killed.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh similarity index 83% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-killed.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh index 4a9c5f6fe1..36b4ae77d6 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-killed.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service pid=$(cat /var/run/spring-boot-app/spring-boot-app.pid) diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh similarity index 81% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-started.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh index 89c1ccc1fb..f378483d23 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service start_service status_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh similarity index 69% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-stopped.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh index 24ca225344..0cf7356642 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/status-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service status_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/stop-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh similarity index 68% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/stop-when-stopped.sh rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh index b74faddbaf..90437663eb 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/stop-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh @@ -1,4 +1,5 @@ source ./test-functions.sh +source ./init.d/test-functions.sh install_service stop_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh new file mode 100644 index 0000000000..122bbf3512 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh @@ -0,0 +1,36 @@ +source ../test-functions.sh + +install_service() { + mkdir /test-service + mv /spring-boot-launch-script-tests.jar /test-service/spring-boot-app.jar + chmod +x /test-service/spring-boot-app.jar + ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app +} + +install_double_link_service() { + mkdir /test-service + mv /spring-boot-launch-script-tests.jar /test-service/ + chmod +x /test-service/spring-boot-launch-script-tests.jar + ln -s /test-service/spring-boot-launch-script-tests.jar /test-service/spring-boot-app.jar + ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app +} + +start_service() { + service spring-boot-app start $@ +} + +restart_service() { + service spring-boot-app restart +} + +status_service() { + service spring-boot-app status +} + +stop_service() { + service spring-boot-app stop +} + +force_stop_service() { + service spring-boot-app force-stop +} \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh new file mode 100644 index 0000000000..d49ce450d2 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh @@ -0,0 +1,4 @@ +source ./test-functions.sh +source ./jar/test-functions.sh +launch_jar & await_app +curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh new file mode 100644 index 0000000000..9a4d7a231e --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh @@ -0,0 +1,5 @@ +source ./test-functions.sh +source ./jar/test-functions.sh +cd "init.d" || exit 1 +ln -s ../spring-boot-launch-script-tests.jar some_app +./some_app diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh new file mode 100644 index 0000000000..d0c3d849c9 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh @@ -0,0 +1,27 @@ +source ./test-functions.sh +source ./jar/test-functions.sh +export APP_NAME="my-new-app" +export MODE=service +./spring-boot-launch-script-tests.jar start +TEST_LOG_FILE="/var/log/$APP_NAME.log" +if [[ (! (-e "$TEST_LOG_FILE")) || (! (-f "$TEST_LOG_FILE")) ]]; then + echo Log file "$TEST_LOG_FILE" doesn\'t exists. + exit 2 +else + echo Test for a log file is passed. +fi +TEST_PID_FOLDER="/var/run/$APP_NAME" +if [[ (! (-e "$TEST_PID_FOLDER")) || (! (-d "$TEST_PID_FOLDER")) ]]; then + echo PID folder "$TEST_PID_FOLDER" doesn\'t exists. + exit 2 +else + echo Test for a PID folder is passed. +fi +TEST_PID_FILE="$TEST_PID_FOLDER/$APP_NAME.pid" +if [[ (! (-e "$TEST_PID_FILE")) || (! (-f "$TEST_PID_FILE"))]]; then + echo PID file "$TEST_PID_FILE" doesn\'t exists. + exit 2 +else + echo Test for a PID file is passed. +fi +echo All tests are passed. diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh new file mode 100644 index 0000000000..c4fc45d04c --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh @@ -0,0 +1,5 @@ +export DEBUG=true +source ./test-functions.sh +source ./jar/test-functions.sh +launch_jar & await_app +curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh new file mode 100644 index 0000000000..105c0a4486 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh @@ -0,0 +1,6 @@ +source ./test-functions.sh +source ./jar/test-functions.sh +cp spring-boot-launch-script-tests.jar app-another.jar +export JARFILE=app-another.jar +launch_jar & await_app +curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh new file mode 100644 index 0000000000..a10049ef43 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh @@ -0,0 +1,3 @@ +launch_jar() { + ./spring-boot-launch-script-tests.jar +} diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh index 903713b888..c9fc2efa19 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh @@ -1,38 +1,3 @@ -install_service() { - mkdir /test-service - mv /spring-boot-launch-script-tests.jar /test-service/spring-boot-app.jar - chmod +x /test-service/spring-boot-app.jar - ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app -} - -install_double_link_service() { - mkdir /test-service - mv /spring-boot-launch-script-tests.jar /test-service/ - chmod +x /test-service/spring-boot-launch-script-tests.jar - ln -s /test-service/spring-boot-launch-script-tests.jar /test-service/spring-boot-app.jar - ln -s /test-service/spring-boot-app.jar /etc/init.d/spring-boot-app -} - -start_service() { - service spring-boot-app start $@ -} - -restart_service() { - service spring-boot-app restart -} - -status_service() { - service spring-boot-app status -} - -stop_service() { - service spring-boot-app stop -} - -force_stop_service() { - service spring-boot-app force-stop -} - await_app() { if [ -z $1 ] then From 84ff233590027b0ad0221fa0ccbab294b1de3828 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 3 Aug 2020 15:03:24 +0100 Subject: [PATCH 2/2] Polish "Test the launch script when executed directly" See gh-21388 --- .../launchscript/AbstractLaunchScriptIT.java | 28 +++++--- ...chScriptIT.java => JarLaunchScriptIT.java} | 49 ++++++++++--- .../launchscript/SysVinitLaunchScriptIT.java | 69 ++++++++++--------- .../conf/CentOS/6.9-a23bced6/Dockerfile | 4 -- .../conf/Ubuntu/trusty-20160914/Dockerfile | 4 -- .../conf/Ubuntu/xenial-20160914/Dockerfile | 4 -- .../resources/scripts/init.d/basic-launch.sh | 1 - .../scripts/init.d/force-stop-when-stopped.sh | 1 - ...launch-with-double-link-single-java-opt.sh | 1 - .../init.d/launch-with-missing-log-folder.sh | 1 - .../init.d/launch-with-missing-pid-folder.sh | 1 - ...ch-with-multiple-command-line-arguments.sh | 1 - .../init.d/launch-with-multiple-java-opts.sh | 1 - .../init.d/launch-with-multiple-run-args.sh | 1 - .../init.d/launch-with-relative-log-folder.sh | 1 - .../init.d/launch-with-relative-pid-folder.sh | 1 - .../init.d/launch-with-run-as-invalid-user.sh | 1 - ...with-run-as-user-preferred-to-jar-owner.sh | 1 - .../launch-with-run-as-user-root-required.sh | 1 - .../scripts/init.d/launch-with-run-as-user.sh | 1 - ...aunch-with-single-command-line-argument.sh | 1 - .../init.d/launch-with-single-java-opt.sh | 1 - .../init.d/launch-with-single-run-arg.sh | 1 - ...-with-use-of-start-stop-daemon-disabled.sh | 1 - ...-file-ownership-is-changed-when-created.sh | 1 - ...file-ownership-is-unchanged-when-exists.sh | 1 - .../scripts/init.d/log-file-ownership.sh | 1 - .../scripts/init.d/pid-file-ownership.sh | 1 - .../scripts/init.d/pid-folder-ownership.sh | 1 - .../scripts/init.d/restart-when-started.sh | 1 - .../scripts/init.d/restart-when-stopped.sh | 1 - .../scripts/init.d/start-when-started.sh | 1 - .../scripts/init.d/start-when-stopped.sh | 1 - .../scripts/init.d/status-when-killed.sh | 1 - .../scripts/init.d/status-when-started.sh | 1 - .../scripts/init.d/status-when-stopped.sh | 1 - .../scripts/init.d/stop-when-stopped.sh | 1 - .../scripts/init.d/test-functions.sh | 19 ++++- .../resources/scripts/jar/basic-launch.sh | 4 +- .../scripts/jar/launch-in-init.d-dir.sh | 5 -- .../scripts/jar/launch-with-app-name.sh | 27 -------- .../scripts/jar/launch-with-debug.sh | 4 +- .../scripts/jar/launch-with-jarfile.sh | 4 +- ...ch-with-multiple-command-line-arguments.sh | 4 ++ .../jar/launch-with-multiple-java-opts.sh | 5 ++ .../jar/launch-with-multiple-run-args.sh | 5 ++ ...aunch-with-single-command-line-argument.sh | 4 ++ .../jar/launch-with-single-java-opt.sh | 5 ++ .../scripts/jar/launch-with-single-run-arg.sh | 5 ++ .../resources/scripts/jar/test-functions.sh | 21 +++++- .../test/resources/scripts/test-functions.sh | 18 ----- 51 files changed, 165 insertions(+), 154 deletions(-) rename spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/{ShellLaunchScriptIT.java => JarLaunchScriptIT.java} (51%) delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-command-line-arguments.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-java-opts.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-run-args.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-command-line-argument.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-java-opt.sh create mode 100755 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-run-arg.sh delete mode 100644 spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java index 41f02619b3..b1470c176c 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/AbstractLaunchScriptIT.java @@ -35,12 +35,20 @@ import static org.hamcrest.Matchers.containsString; /** * Abstract base class for testing the launch script. * + * @author Andy Wilkinson + * @author Ali Shahbour * @author Alexey Vinogradov */ abstract class AbstractLaunchScriptIT { protected static final char ESC = 27; + private final String scriptsDir; + + protected AbstractLaunchScriptIT(String scriptsDir) { + this.scriptsDir = scriptsDir; + } + static List parameters() { List parameters = new ArrayList<>(); for (File os : new File("src/test/resources/conf").listFiles()) { @@ -69,7 +77,8 @@ abstract class AbstractLaunchScriptIT { protected String doTest(String os, String version, String script) throws Exception { ToStringConsumer consumer = new ToStringConsumer().withRemoveAnsiCodes(false); - try (LaunchScriptTestContainer container = new LaunchScriptTestContainer(os, version, script)) { + try (LaunchScriptTestContainer container = new LaunchScriptTestContainer(os, version, this.scriptsDir, + script)) { container.withLogConsumer(consumer); container.start(); while (container.isRunning()) { @@ -81,17 +90,16 @@ abstract class AbstractLaunchScriptIT { private static final class LaunchScriptTestContainer extends GenericContainer { - private LaunchScriptTestContainer(String os, String version, String testScript) { + 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/test/resources/conf/" + os + "/" + version + "/Dockerfile")) - .withFileFromFile("spring-boot-launch-script-tests.jar", findApplication()) - .withFileFromFile("test-functions.sh", new File("src/test/resources/scripts/test-functions.sh")) - .withFileFromFile("jar/test-functions.sh", - new File("src/test/resources/scripts/jar/test-functions.sh")) - .withFileFromFile("init.d/test-functions.sh", - new File("src/test/resources/scripts/init.d/test-functions.sh"))); - withCopyFileToContainer(MountableFile.forHostPath("src/test/resources/scripts/" + testScript), + new File("src/test/resources/conf/" + os + "/" + version + "/Dockerfile"))); + withCopyFileToContainer(MountableFile.forHostPath(findApplication().getAbsolutePath()), + "/spring-boot-launch-script-tests.jar"); + withCopyFileToContainer( + MountableFile.forHostPath("src/test/resources/scripts/" + scriptsDir + "test-functions.sh"), + "/test-functions.sh"); + withCopyFileToContainer(MountableFile.forHostPath("src/test/resources/scripts/" + scriptsDir + testScript), "/" + testScript); withCommand("/bin/bash", "-c", "chmod +x " + testScript + " && ./" + testScript); withStartupTimeout(Duration.ofMinutes(10)); diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/JarLaunchScriptIT.java similarity index 51% rename from spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java rename to spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/JarLaunchScriptIT.java index 01265fdc73..fa80a2498b 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/ShellLaunchScriptIT.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/JarLaunchScriptIT.java @@ -22,45 +22,72 @@ import org.junit.jupiter.params.provider.MethodSource; import static org.assertj.core.api.Assertions.assertThat; /** - * Integration tests of Spring Boot's launch script with launching via shell. + * Integration tests of Spring Boot's launch script when executing the jar directly. * * @author Alexey Vinogradov + * @author Andy Wilkinson */ -class ShellLaunchScriptIT extends AbstractLaunchScriptIT { +class JarLaunchScriptIT extends AbstractLaunchScriptIT { + + JarLaunchScriptIT() { + super("jar/"); + } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void basicLaunch(String os, String version) throws Exception { - doLaunch(os, version, "jar/basic-launch.sh"); + doLaunch(os, version, "basic-launch.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithDebugEnv(String os, String version) throws Exception { - final String output = doTest(os, version, "jar/launch-with-debug.sh"); + final String output = doTest(os, version, "launch-with-debug.sh"); assertThat(output).contains("++ pwd"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithDifferentJarFileEnv(String os, String version) throws Exception { - final String output = doTest(os, version, "jar/launch-with-jarfile.sh"); + final String output = doTest(os, version, "launch-with-jarfile.sh"); assertThat(output).contains("app-another.jar"); assertThat(output).doesNotContain("spring-boot-launch-script-tests.jar"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") - void launchWithDifferentAppName(String os, String version) throws Exception { - final String output = doTest(os, version, "jar/launch-with-app-name.sh"); - assertThat(output).contains("All tests are passed."); + void launchWithSingleCommandLineArgument(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-single-command-line-argument.sh"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithMultipleCommandLineArguments(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithSingleRunArg(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-single-run-arg.sh"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithMultipleRunArgs(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-multiple-run-args.sh"); + } + + @ParameterizedTest(name = "{0} {1}") + @MethodSource("parameters") + void launchWithSingleJavaOpt(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-single-java-opt.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") - void launchInInitdDir(String os, String version) throws Exception { - final String output = doTest(os, version, "jar/launch-in-init.d-dir.sh"); - assertThat(output).contains("Usage: ./some_app {start|stop|force-stop|restart|force-reload|status|run}"); + void launchWithMultipleJavaOpts(String os, String version) throws Exception { + doLaunch(os, version, "launch-with-multiple-java-opts.sh"); } } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java index 82c209b92f..7a624354b6 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/java/org/springframework/boot/launchscript/SysVinitLaunchScriptIT.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +31,18 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Andy Wilkinson * @author Ali Shahbour + * @author Alexey Vinogradov */ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { + SysVinitLaunchScriptIT() { + super("init.d/"); + } + @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/status-when-stopped.sh"); + String output = doTest(os, version, "status-when-stopped.sh"); assertThat(output).contains("Status: 3"); assertThat(output).has(coloredString(AnsiColor.RED, "Not running")); } @@ -45,7 +50,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/status-when-started.sh"); + String output = doTest(os, version, "status-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); } @@ -53,7 +58,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void statusWhenKilled(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/status-when-killed.sh"); + String output = doTest(os, version, "status-when-killed.sh"); assertThat(output).contains("Status: 1"); assertThat(output) .has(coloredString(AnsiColor.RED, "Not running (process " + extractPid(output) + " not found)")); @@ -62,7 +67,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void stopWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/stop-when-stopped.sh"); + String output = doTest(os, version, "stop-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); } @@ -70,7 +75,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void forceStopWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/force-stop-when-stopped.sh"); + String output = doTest(os, version, "force-stop-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); } @@ -78,7 +83,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void startWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/start-when-started.sh"); + String output = doTest(os, version, "start-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Already running [" + extractPid(output) + "]")); } @@ -86,7 +91,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void restartWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/restart-when-stopped.sh"); + String output = doTest(os, version, "restart-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.YELLOW, "Not running (pidfile not found)")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); @@ -95,7 +100,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void restartWhenStarted(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/restart-when-started.sh"); + String output = doTest(os, version, "restart-when-started.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extract("PID1", output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Stopped [" + extract("PID1", output) + "]")); @@ -105,7 +110,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void startWhenStopped(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/start-when-stopped.sh"); + String output = doTest(os, version, "start-when-stopped.sh"); assertThat(output).contains("Status: 0"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); } @@ -113,14 +118,14 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void basicLaunch(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/basic-launch.sh"); + String output = doTest(os, version, "basic-launch.sh"); assertThat(output).doesNotContain("PID_FOLDER"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMissingLogFolderGeneratesAWarning(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-missing-log-folder.sh"); + String output = doTest(os, version, "launch-with-missing-log-folder.sh"); assertThat(output).has( coloredString(AnsiColor.YELLOW, "LOG_FOLDER /does/not/exist does not exist. Falling back to /tmp")); } @@ -128,7 +133,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMissingPidFolderGeneratesAWarning(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-missing-pid-folder.sh"); + String output = doTest(os, version, "launch-with-missing-pid-folder.sh"); assertThat(output).has( coloredString(AnsiColor.YELLOW, "PID_FOLDER /does/not/exist does not exist. Falling back to /tmp")); } @@ -136,43 +141,43 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleCommandLineArgument(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-single-command-line-argument.sh"); + doLaunch(os, version, "launch-with-single-command-line-argument.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleCommandLineArguments(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-multiple-command-line-arguments.sh"); + doLaunch(os, version, "launch-with-multiple-command-line-arguments.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleRunArg(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-single-run-arg.sh"); + doLaunch(os, version, "launch-with-single-run-arg.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleRunArgs(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-multiple-run-args.sh"); + doLaunch(os, version, "launch-with-multiple-run-args.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithSingleJavaOpt(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-single-java-opt.sh"); + doLaunch(os, version, "launch-with-single-java-opt.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithDoubleLinkSingleJavaOpt(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-double-link-single-java-opt.sh"); + doLaunch(os, version, "launch-with-double-link-single-java-opt.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithMultipleJavaOpts(String os, String version) throws Exception { - doLaunch(os, version, "init.d/launch-with-multiple-java-opts.sh"); + doLaunch(os, version, "launch-with-multiple-java-opts.sh"); } @ParameterizedTest(name = "{0} {1}") @@ -180,13 +185,13 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { void launchWithUseOfStartStopDaemonDisabled(String os, String version) throws Exception { // CentOS doesn't have start-stop-daemon Assumptions.assumeFalse(os.equals("CentOS")); - doLaunch(os, version, "init.d/launch-with-use-of-start-stop-daemon-disabled.sh"); + doLaunch(os, version, "launch-with-use-of-start-stop-daemon-disabled.sh"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRelativePidFolder(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-relative-pid-folder.sh"); + String output = doTest(os, version, "launch-with-relative-pid-folder.sh"); assertThat(output).has(coloredString(AnsiColor.GREEN, "Started [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Running [" + extractPid(output) + "]")); assertThat(output).has(coloredString(AnsiColor.GREEN, "Stopped [" + extractPid(output) + "]")); @@ -195,56 +200,56 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void pidFolderOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/pid-folder-ownership.sh"); + String output = doTest(os, version, "pid-folder-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void pidFileOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/pid-file-ownership.sh"); + String output = doTest(os, version, "pid-file-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnership(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/log-file-ownership.sh"); + String output = doTest(os, version, "log-file-ownership.sh"); assertThat(output).contains("phil root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnershipIsChangedWhenCreated(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/log-file-ownership-is-changed-when-created.sh"); + String output = doTest(os, version, "log-file-ownership-is-changed-when-created.sh"); assertThat(output).contains("andy root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void logFileOwnershipIsUnchangedWhenExists(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/log-file-ownership-is-unchanged-when-exists.sh"); + String output = doTest(os, version, "log-file-ownership-is-unchanged-when-exists.sh"); assertThat(output).contains("root root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRelativeLogFolder(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-relative-log-folder.sh"); + String output = doTest(os, version, "launch-with-relative-log-folder.sh"); assertThat(output).contains("Log written"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void launchWithRunAsUser(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-run-as-user.sh"); + String output = doTest(os, version, "launch-with-run-as-user.sh"); assertThat(output).contains("wagner root"); } @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void whenRunAsUserDoesNotExistLaunchFailsWithInvalidArgument(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-run-as-invalid-user.sh"); + String output = doTest(os, version, "launch-with-run-as-invalid-user.sh"); assertThat(output).contains("Status: 2"); assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'johndoe': no such user")); } @@ -252,7 +257,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @ParameterizedTest(name = "{0} {1}") @MethodSource("parameters") void whenJarOwnerAndRunAsUserAreBothSpecifiedRunAsUserTakesPrecedence(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-run-as-user-preferred-to-jar-owner.sh"); + String output = doTest(os, version, "launch-with-run-as-user-preferred-to-jar-owner.sh"); assertThat(output).contains("wagner root"); } @@ -260,7 +265,7 @@ class SysVinitLaunchScriptIT extends AbstractLaunchScriptIT { @MethodSource("parameters") void whenLaunchedUsingNonRootUserWithRunAsUserSpecifiedLaunchFailsWithInsufficientPrivilege(String os, String version) throws Exception { - String output = doTest(os, version, "init.d/launch-with-run-as-user-root-required.sh"); + String output = doTest(os, version, "launch-with-run-as-user-root-required.sh"); assertThat(output).contains("Status: 4"); assertThat(output).has(coloredString(AnsiColor.RED, "Cannot run as 'wagner': current user is not root")); } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile index 8a93884e95..f4856452b6 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/CentOS/6.9-a23bced6/Dockerfile @@ -7,7 +7,3 @@ RUN yum install -y wget && \ https://cdn.azul.com/zulu/bin/zulu8.21.0.1-jdk8.0.131-linux.x86_64.rpm && \ yum --nogpg localinstall -y jdk.rpm && \ rm -f jdk.rpm -ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh -ADD init.d/test-functions.sh /init.d/test-functions.sh -ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile index f33c6f30f6..0e4cc372d5 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/trusty-20160914/Dockerfile @@ -6,7 +6,3 @@ RUN apt-get update && \ 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 -ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh -ADD init.d/test-functions.sh /init.d/test-functions.sh -ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile index 167d142a56..e8e84e0c47 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/conf/Ubuntu/xenial-20160914/Dockerfile @@ -6,7 +6,3 @@ RUN apt-get update && \ 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 -ADD spring-boot-launch-script-tests.jar /spring-boot-launch-script-tests.jar -ADD test-functions.sh /test-functions.sh -ADD init.d/test-functions.sh /init.d/test-functions.sh -ADD jar/test-functions.sh /jar/test-functions.sh diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh index 2a0501d43c..44f44a856c 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/basic-launch.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service await_app diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh index 9a90ebd55e..465b555329 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/force-stop-when-stopped.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service force_stop_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh index 13ee6cbc01..6895c0d061 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-double-link-single-java-opt.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_double_link_service echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh index 25962027a6..1f3aed3844 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-log-folder.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh index 5ee6d5d2b5..83430bea62 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-missing-pid-folder.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'PID_FOLDER=/does/not/exist' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh index 97011d797f..7503458301 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-command-line-arguments.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service --server.port=8081 --server.servlet.context-path=/test await_app http://127.0.0.1:8081/test/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh index 9cfc9a0ccb..387ad47dad 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-java-opts.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'JAVA_OPTS="-Dserver.port=8081 -Dserver.servlet.context-path=/test"' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh index c9942a9953..76b4c47679 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-multiple-run-args.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'RUN_ARGS="--server.port=8081 --server.servlet.context-path=/test"' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh index 44567b41c1..da1f7b11c1 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-log-folder.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh mkdir ./pid install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh index d129bc2bf7..a46d67b8a2 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-relative-pid-folder.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service mkdir /test-service/pid echo 'PID_FOLDER=pid' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh index 0e9cda7990..f6384046dc 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-invalid-user.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'RUN_AS_USER=johndoe' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh index 09beabddda..730b8197bb 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-preferred-to-jar-owner.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh index 82ecfa697e..3cd83374e2 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user-root-required.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh index 23d95545d5..6be8eee0f0 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-run-as-user.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service useradd wagner diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh index b327005630..2adb76da3f 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-command-line-argument.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service --server.port=8081 await_app http://127.0.0.1:8081/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh index 16940da02d..a0445b8224 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-java-opt.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'JAVA_OPTS=-Dserver.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh index 2b8297c85c..0d61c5d154 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-single-run-arg.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'RUN_ARGS=--server.port=8081' > /test-service/spring-boot-app.conf start_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh index e4d7f7c18a..2f2bd3dfad 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/launch-with-use-of-start-stop-daemon-disabled.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh chmod -x $(type -p start-stop-daemon) install_service echo 'USE_START_STOP_DAEMON=false' > /test-service/spring-boot-app.conf diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh index 41ce4a6187..5cc9eb46fc 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-changed-when-created.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf mkdir -p /test-service/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh index e80d725cb1..685e1e6100 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership-is-unchanged-when-exists.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service echo 'LOG_FOLDER=log' > /test-service/spring-boot-app.conf mkdir -p /test-service/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh index 4a127e10a5..919c33e380 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/log-file-ownership.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service chmod o+w /var/log diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh index ec201d076b..891bb935fa 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-file-ownership.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service useradd phil diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh index eadc51f779..c6b7d19c09 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/pid-folder-ownership.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service chmod o+w /var/run diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh index becd1041a1..017b4c18e8 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-started.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service echo "PID1: $(cat /var/run/spring-boot-app/spring-boot-app.pid)" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh index 9cbc8f5cfa..95fd91c3b4 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/restart-when-stopped.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service restart_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh index e2366afffe..fd9e4f2f6b 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-started.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service echo "PID: $(cat /var/run/spring-boot-app/spring-boot-app.pid)" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh index 4146795351..427fff4406 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/start-when-stopped.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh index 36b4ae77d6..4a9c5f6fe1 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-killed.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service pid=$(cat /var/run/spring-boot-app/spring-boot-app.pid) diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh index f378483d23..89c1ccc1fb 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-started.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service start_service status_service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh index 0cf7356642..24ca225344 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/status-when-stopped.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service status_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh index 90437663eb..b74faddbaf 100755 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/stop-when-stopped.sh @@ -1,5 +1,4 @@ source ./test-functions.sh -source ./init.d/test-functions.sh install_service stop_service echo "Status: $?" diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh index 122bbf3512..f1ee4a1d98 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/init.d/test-functions.sh @@ -1,4 +1,21 @@ -source ../test-functions.sh +await_app() { + if [ -z $1 ] + then + url=http://127.0.0.1:8080 + else + url=$1 + fi + end=$(date +%s) + let "end+=30" + until curl -s $url > /dev/null + do + now=$(date +%s) + if [[ $now -ge $end ]]; then + break + fi + sleep 1 + done +} install_service() { mkdir /test-service diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh index d49ce450d2..cf6be88597 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/basic-launch.sh @@ -1,4 +1,4 @@ source ./test-functions.sh -source ./jar/test-functions.sh -launch_jar & await_app +launch_jar +await_app curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh deleted file mode 100644 index 9a4d7a231e..0000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-in-init.d-dir.sh +++ /dev/null @@ -1,5 +0,0 @@ -source ./test-functions.sh -source ./jar/test-functions.sh -cd "init.d" || exit 1 -ln -s ../spring-boot-launch-script-tests.jar some_app -./some_app diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh deleted file mode 100644 index d0c3d849c9..0000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-app-name.sh +++ /dev/null @@ -1,27 +0,0 @@ -source ./test-functions.sh -source ./jar/test-functions.sh -export APP_NAME="my-new-app" -export MODE=service -./spring-boot-launch-script-tests.jar start -TEST_LOG_FILE="/var/log/$APP_NAME.log" -if [[ (! (-e "$TEST_LOG_FILE")) || (! (-f "$TEST_LOG_FILE")) ]]; then - echo Log file "$TEST_LOG_FILE" doesn\'t exists. - exit 2 -else - echo Test for a log file is passed. -fi -TEST_PID_FOLDER="/var/run/$APP_NAME" -if [[ (! (-e "$TEST_PID_FOLDER")) || (! (-d "$TEST_PID_FOLDER")) ]]; then - echo PID folder "$TEST_PID_FOLDER" doesn\'t exists. - exit 2 -else - echo Test for a PID folder is passed. -fi -TEST_PID_FILE="$TEST_PID_FOLDER/$APP_NAME.pid" -if [[ (! (-e "$TEST_PID_FILE")) || (! (-f "$TEST_PID_FILE"))]]; then - echo PID file "$TEST_PID_FILE" doesn\'t exists. - exit 2 -else - echo Test for a PID file is passed. -fi -echo All tests are passed. diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh index c4fc45d04c..b9d1f6fc85 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-debug.sh @@ -1,5 +1,5 @@ export DEBUG=true source ./test-functions.sh -source ./jar/test-functions.sh -launch_jar & await_app +launch_jar +await_app curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh index 105c0a4486..ccb8a28830 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-jarfile.sh @@ -1,6 +1,6 @@ source ./test-functions.sh -source ./jar/test-functions.sh cp spring-boot-launch-script-tests.jar app-another.jar export JARFILE=app-another.jar -launch_jar & await_app +launch_jar +await_app curl -s http://127.0.0.1:8080/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-command-line-arguments.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-command-line-arguments.sh new file mode 100755 index 0000000000..6a97eab32a --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-command-line-arguments.sh @@ -0,0 +1,4 @@ +source ./test-functions.sh +launch_jar --server.port=8081 --server.servlet.context-path=/test +await_app http://127.0.0.1:8081/test/ +curl -s http://127.0.0.1:8081/test/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-java-opts.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-java-opts.sh new file mode 100755 index 0000000000..f490ac6daf --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-java-opts.sh @@ -0,0 +1,5 @@ +source ./test-functions.sh +echo 'JAVA_OPTS="-Dserver.port=8081 -Dserver.servlet.context-path=/test"' > spring-boot-launch-script-tests.conf +launch_jar +await_app http://127.0.0.1:8081/test/ +curl -s http://127.0.0.1:8081/test/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-run-args.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-run-args.sh new file mode 100755 index 0000000000..dcdfbbb375 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-multiple-run-args.sh @@ -0,0 +1,5 @@ +source ./test-functions.sh +echo 'RUN_ARGS="--server.port=8081 --server.servlet.context-path=/test"' > spring-boot-launch-script-tests.conf +launch_jar +await_app http://127.0.0.1:8081/test/ +curl -s http://127.0.0.1:8081/test/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-command-line-argument.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-command-line-argument.sh new file mode 100755 index 0000000000..d1be39e849 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-command-line-argument.sh @@ -0,0 +1,4 @@ +source ./test-functions.sh +launch_jar --server.port=8081 +await_app http://127.0.0.1:8081/ +curl -s http://127.0.0.1:8081/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-java-opt.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-java-opt.sh new file mode 100755 index 0000000000..6d57862ff9 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-java-opt.sh @@ -0,0 +1,5 @@ +source ./test-functions.sh +echo 'JAVA_OPTS=-Dserver.port=8081' > spring-boot-launch-script-tests.conf +launch_jar +await_app http://127.0.0.1:8081/ +curl -s http://127.0.0.1:8081/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-run-arg.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-run-arg.sh new file mode 100755 index 0000000000..c1916a2e28 --- /dev/null +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/launch-with-single-run-arg.sh @@ -0,0 +1,5 @@ +source ./test-functions.sh +echo 'RUN_ARGS=--server.port=8081' > /spring-boot-launch-script-tests.conf +launch_jar +await_app http://127.0.0.1:8081/ +curl -s http://127.0.0.1:8081/ diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh index a10049ef43..e627af1caf 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/jar/test-functions.sh @@ -1,3 +1,22 @@ +await_app() { + if [ -z $1 ] + then + url=http://127.0.0.1:8080 + else + url=$1 + fi + end=$(date +%s) + let "end+=30" + until curl -s $url > /dev/null + do + now=$(date +%s) + if [[ $now -ge $end ]]; then + break + fi + sleep 1 + done +} + launch_jar() { - ./spring-boot-launch-script-tests.jar + ./spring-boot-launch-script-tests.jar $@ & } diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh deleted file mode 100644 index c9fc2efa19..0000000000 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/src/test/resources/scripts/test-functions.sh +++ /dev/null @@ -1,18 +0,0 @@ -await_app() { - if [ -z $1 ] - then - url=http://127.0.0.1:8080 - else - url=$1 - fi - end=$(date +%s) - let "end+=30" - until curl -s $url > /dev/null - do - now=$(date +%s) - if [[ $now -ge $end ]]; then - break - fi - sleep 1 - done -}