Skip to content

Commit

Permalink
Increase timeout for running launcher command (#8486)
Browse files Browse the repository at this point in the history
We've been experiencing consistently failures on MacOS due to timeouts.
Doubling the timeout, hoping this will be sufficient to eliminate such
false failures. Will seek alternative solutions if that does not rememdy
the problem on CI.
  • Loading branch information
hubertp authored Dec 7, 2023
1 parent e562f65 commit a14ebd6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
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
21 changes: 15 additions & 6 deletions engine/launcher/src/test/scala/org/enso/launcher/NativeTest.scala
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
)

}

0 comments on commit a14ebd6

Please sign in to comment.