From a14ebd625977c2d3fa7af1ef7b6dfed8bf568c95 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Thu, 7 Dec 2023 16:34:55 +0100 Subject: [PATCH] Increase timeout for running launcher command (#8486) 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. --- .../enso/launcher/NativeLauncherSpec.scala | 3 ++- .../scala/org/enso/launcher/NativeTest.scala | 21 +++++++++++++------ .../org/enso/launcher/PluginManagerSpec.scala | 21 ++++++++++++++++--- .../installation/UninstallerSpec.scala | 9 +++++--- .../test/NativeTestHelper.scala | 7 ++++++- 5 files changed, 47 insertions(+), 14 deletions(-) diff --git a/engine/launcher/src/test/scala/org/enso/launcher/NativeLauncherSpec.scala b/engine/launcher/src/test/scala/org/enso/launcher/NativeLauncherSpec.scala index 69532aefb4e9..ec8a55199333 100644 --- a/engine/launcher/src/test/scala/org/enso/launcher/NativeLauncherSpec.scala +++ b/engine/launcher/src/test/scala/org/enso/launcher/NativeLauncherSpec.scala @@ -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 diff --git a/engine/launcher/src/test/scala/org/enso/launcher/NativeTest.scala b/engine/launcher/src/test/scala/org/enso/launcher/NativeTest.scala index 854c1c052475..5190854d580b 100644 --- a/engine/launcher/src/test/scala/org/enso/launcher/NativeTest.scala +++ b/engine/launcher/src/test/scala/org/enso/launcher/NativeTest.scala @@ -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( @@ -67,7 +69,8 @@ trait NativeTest runCommand( Seq(baseLauncherLocation.toAbsolutePath.toString) ++ args, extraEnv.toSeq, - extraJVMProps.toSeq + extraJVMProps.toSeq, + timeoutSeconds = timeoutSeconds ) } @@ -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( @@ -95,7 +100,8 @@ trait NativeTest runCommand( Seq(pathToLauncher.toAbsolutePath.toString) ++ args, extraEnv.toSeq, - extraJVMProps.toSeq + extraJVMProps.toSeq, + timeoutSeconds = timeoutSeconds ) } @@ -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 ) } } diff --git a/engine/launcher/src/test/scala/org/enso/launcher/PluginManagerSpec.scala b/engine/launcher/src/test/scala/org/enso/launcher/PluginManagerSpec.scala index 2b7d6bafeb97..026e965e9429 100644 --- a/engine/launcher/src/test/scala/org/enso/launcher/PluginManagerSpec.scala +++ b/engine/launcher/src/test/scala/org/enso/launcher/PluginManagerSpec.scala @@ -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.") @@ -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." } @@ -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") } diff --git a/engine/launcher/src/test/scala/org/enso/launcher/installation/UninstallerSpec.scala b/engine/launcher/src/test/scala/org/enso/launcher/installation/UninstallerSpec.scala index 5a2a8274963f..9cd94873adb1 100644 --- a/engine/launcher/src/test/scala/org/enso/launcher/installation/UninstallerSpec.scala +++ b/engine/launcher/src/test/scala/org/enso/launcher/installation/UninstallerSpec.scala @@ -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.") @@ -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.") @@ -98,7 +100,8 @@ class UninstallerSpec extends NativeTest with WithTemporaryDirectory { launcher, Seq("--auto-confirm", "uninstall", "distribution"), env, - extraJVMProps + extraJVMProps, + timeoutSeconds = 30 ) should returnSuccess assert( diff --git a/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/NativeTestHelper.scala b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/NativeTestHelper.scala index f8ce198f924e..dbdb0e326b47 100644 --- a/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/NativeTestHelper.scala +++ b/lib/scala/runtime-version-manager-test/src/main/scala/org/enso/runtimeversionmanager/test/NativeTestHelper.scala @@ -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. @@ -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 + ) }