Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase timeout for running launcher command #8486

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class NativeLauncherSpec extends NativeTest {
"display its version" in {
val run = runLauncher(
Seq("version", "--json", "--only-launcher"),
extraJVMProps = Map("ENSO_LOG_TO_FILE" -> "false")
extraJVMProps = Map("ENSO_LOG_TO_FILE" -> "false"),
timeoutSeconds = 30
)
run should returnSuccess

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ trait NativeTest
* @param extraEnv environment variables to override for the launched
* program, do not use these to override PATH
* @param extraJVMProps JVM properties to append to the launcher command
* @param timeoutSeconds timeout (in seconds) to wait for the launcher to finish
*/
def runLauncher(
args: Seq[String],
extraEnv: Map[String, String] = Map.empty,
extraJVMProps: Map[String, String] = Map.empty
extraJVMProps: Map[String, String] = Map.empty,
timeoutSeconds: Long = 15
): RunResult = {
if (extraEnv.contains("PATH")) {
throw new IllegalArgumentException(
Expand All @@ -67,7 +69,8 @@ trait NativeTest
runCommand(
Seq(baseLauncherLocation.toAbsolutePath.toString) ++ args,
extraEnv.toSeq,
extraJVMProps.toSeq
extraJVMProps.toSeq,
timeoutSeconds = timeoutSeconds
)
}

Expand All @@ -79,12 +82,14 @@ trait NativeTest
* @param extraEnv environment variables to override for the launched
* program, do not use these to override PATH
* @param extraJVMProps JVM properties to append to the launcher command
* @param timeoutSeconds timeout (in seconds) to wait for the launcher to finish
*/
def runLauncherAt(
pathToLauncher: Path,
args: Seq[String],
extraEnv: Map[String, String] = Map.empty,
extraJVMProps: Map[String, String] = Map.empty
extraJVMProps: Map[String, String] = Map.empty,
timeoutSeconds: Long = 15
): RunResult = {
if (extraEnv.contains("PATH")) {
throw new IllegalArgumentException(
Expand All @@ -95,7 +100,8 @@ trait NativeTest
runCommand(
Seq(pathToLauncher.toAbsolutePath.toString) ++ args,
extraEnv.toSeq,
extraJVMProps.toSeq
extraJVMProps.toSeq,
timeoutSeconds = timeoutSeconds
)
}

Expand Down Expand Up @@ -134,16 +140,19 @@ trait NativeTest
* @param pathOverride the system PATH that should be set for the launched
* program
* @param extraJVMProps JVM properties to append to the launcher command
* @param timeoutSeconds timeout (in seconds) to wait for the launcher to finish
*/
def runLauncherWithPath(
args: Seq[String],
pathOverride: String,
extraJVMProps: Map[String, String] = Map.empty
extraJVMProps: Map[String, String] = Map.empty,
timeoutSeconds: Long = 15
): RunResult = {
runCommand(
Seq(baseLauncherLocation.toAbsolutePath.toString) ++ args,
Seq(NativeTest.PATH -> pathOverride),
extraJVMProps.toSeq
extraJVMProps.toSeq,
timeoutSeconds = timeoutSeconds
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ class PluginManagerSpec
writePlugin(path, "plugin2")
writePlugin(path, "plugin3", prefixed = false)

val run = runLauncherWithPath(Seq("help"), path.toString, extraJVMProps)
val run = runLauncherWithPath(
Seq("help"),
path.toString,
extraJVMProps,
timeoutSeconds = 30
)
run should returnSuccess
run.stdout should include("Plugin plugin1.")
run.stdout should include("Plugin plugin2.")
Expand All @@ -59,7 +64,12 @@ class PluginManagerSpec
writePlugin(path, "plugin1")

val run =
runLauncherWithPath(Seq("plugin1"), path.toString, extraJVMProps)
runLauncherWithPath(
Seq("plugin1"),
path.toString,
extraJVMProps,
timeoutSeconds = 30
)
run should returnSuccess
run.stdout.trim shouldEqual "Plugin plugin1."
}
Expand All @@ -68,7 +78,12 @@ class PluginManagerSpec
val path = getTestDirectory.toAbsolutePath
writePlugin(path, "plugin1")
val run =
runLauncherWithPath(Seq("plugin2"), path.toString, extraJVMProps)
runLauncherWithPath(
Seq("plugin2"),
path.toString,
extraJVMProps,
timeoutSeconds = 30
)
run.exitCode should not equal 0
run.stdout should include("plugin1")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class UninstallerSpec extends NativeTest with WithTemporaryDirectory {
launcher,
Seq("--auto-confirm", "uninstall", "distribution"),
env,
extraJVMProps
extraJVMProps,
timeoutSeconds = 30
) should returnSuccess

assert(Files.notExists(installedRoot), "Should remove the data root.")
Expand All @@ -81,7 +82,8 @@ class UninstallerSpec extends NativeTest with WithTemporaryDirectory {
launcher,
Seq("--auto-confirm", "uninstall", "distribution"),
env,
extraJVMProps
extraJVMProps,
timeoutSeconds = 30
) should returnSuccess

assert(Files.notExists(installedRoot), "Should remove the data root.")
Expand All @@ -98,7 +100,8 @@ class UninstallerSpec extends NativeTest with WithTemporaryDirectory {
launcher,
Seq("--auto-confirm", "uninstall", "distribution"),
env,
extraJVMProps
extraJVMProps,
timeoutSeconds = 30
) should returnSuccess

assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ trait NativeTestHelper {
* @param extraEnv extra environment properties added to the environment. Care must be taken
* on Windows where environment variables are (mostly) case-insensitive.
* @param extraJVMProps extra JVM properties to be appended to the command
* @param timeoutSeconds timeout (in seconds) to wait for the command to finish
* @param waitForDescendants if true, tries to wait for descendants of the launched process to finish too.
* Especially important on Windows where child processes may run after the launcher
* parent has been terminated.
Expand All @@ -68,8 +69,12 @@ trait NativeTestHelper {
command: Seq[String],
extraEnv: Seq[(String, String)],
extraJVMProps: Seq[(String, String)],
timeoutSeconds: Long,
waitForDescendants: Boolean = true
): RunResult =
start(command, extraEnv, extraJVMProps).join(waitForDescendants)
start(command, extraEnv, extraJVMProps).join(
waitForDescendants,
timeoutSeconds
)

}
Loading