Retry occasionally-failing test until we upgrade Artemis (#816)

This commit is contained in:
Andrzej Cichocki 2017-06-08 17:08:56 +01:00 committed by GitHub
parent 58114f817c
commit bc4aed92dc

View File

@ -29,7 +29,7 @@ import java.time.Duration
import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicInteger
import kotlin.concurrent.thread
import kotlin.test.fail
class RPCStabilityTests {
@ -218,10 +218,25 @@ class RPCStabilityTests {
@Test
fun `client reconnects to rebooted server`() {
// Artemis 2.1.0 has a bug that makes this test fail, and 25 trials are needed to make it fail reliably.
// In the success case 25 trials take 2 minutes, so I've disabled them for the known-good Artemis version.
// TODO: Remove multiple trials when we fix the Artemis bug (which should have its own test(s)).
val trials = if (ArtemisConstants::class.java.`package`.implementationVersion == "1.5.3") 1 else 25
if (ArtemisConstants::class.java.`package`.implementationVersion == "1.5.3") {
// The test fails maybe 1 in 100 times, so to stay green until we upgrade Artemis, retry if it fails:
for (i in (1..3)) {
try {
`client reconnects to rebooted server`(1)
} catch (e: TimeoutException) {
continue
}
return
}
fail("Test failed 3 times, which is vanishingly unlikely unless something has changed.")
} else {
// We've upgraded Artemis so make the test fail reliably, in the 2.1.0 case that takes 25 trials:
`client reconnects to rebooted server`(25)
}
}
private fun `client reconnects to rebooted server`(trials: Int) {
rpcDriver {
val coreBurner = thread {
while (!Thread.interrupted()) {