Skip to content

Commit

Permalink
Disable flaky test
Browse files Browse the repository at this point in the history
Despite all attempts to reduce resource usage, the test continues to be
stubborn like a mule and randomly timeouts on CI. Adding an option to print
stacktraces and maybe someone will be struck by lighting and be able to
figure it out. Adding the stracktrace in all cases pollutes the output
from CI.

Closes  #8806.
  • Loading branch information
hubertp committed Feb 5, 2024
1 parent 7bba021 commit 4db9269
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LibrariesTest
)

"LocalLibraryManager" should {
"create a library project and include it on the list of local projects" taggedAs Flaky in {
"create a library project and include it on the list of local projects" taggedAs SkipOnFailure in {
val client = getInitialisedWsClient()
val testLibraryName = LibraryName("user", "My_Local_Lib")

Expand Down Expand Up @@ -95,7 +95,10 @@ class LibrariesTest
} yield libraryNames

// The resolver may find the current project and other test projects on the path.
val msg1 = client.expectSomeJson(timeout = defaultTimeout)
val msg1 = client.expectSomeJson(
timeout = defaultTimeout,
printStackTracesOnFailure = true
)
inside(findLibraryNamesInResponse(msg1)) { case Some(libs) =>
// Ensure that before running this test, the library did not exist.
libs should not contain testLibraryName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ abstract class JsonRpcServerTestKit

def send(json: Json): Unit = send(json.noSpaces)

def expectMessage(timeout: FiniteDuration = 5.seconds.dilated): String = {
def expectMessage(
timeout: FiniteDuration = 5.seconds.dilated,
printStackTracesOnFailure: Boolean = false
): String = {
val message =
try {
outActor.expectMsgClass[String](timeout, classOf[String])
} catch {
case e: AssertionError if e.getMessage.contains("timeout") =>
case e: AssertionError
if e.getMessage.contains(
"timeout"
) && printStackTracesOnFailure =>
val sb = new StringBuilder(
"Thread dump when timeout is reached while waiting for the message:\n"
)
Expand All @@ -142,7 +148,7 @@ abstract class JsonRpcServerTestKit
.append(")\n")
}
}
//println(sb.toString())
println(sb.toString())
throw e
}
if (debugMessages) println(message)
Expand All @@ -158,9 +164,10 @@ abstract class JsonRpcServerTestKit
}

def expectSomeJson(
timeout: FiniteDuration = 10.seconds.dilated
timeout: FiniteDuration = 10.seconds.dilated,
printStackTracesOnFailure: Boolean = false
)(implicit pos: Position): Json = {
val parsed = parse(expectMessage(timeout))
val parsed = parse(expectMessage(timeout, printStackTracesOnFailure))
inside(parsed) { case Right(json) => json }
}

Expand Down

0 comments on commit 4db9269

Please sign in to comment.