|
|
|
@ -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"));
|
|
|
|
|
}
|
|
|
|
|