Skip to content

Commit

Permalink
fix: Add attempts to performance test (#1414)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-goral authored Dec 18, 2020
1 parent 541f21c commit 780cf28
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions test_runner/src/test/kotlin/ftl/shard/ShardTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import java.util.concurrent.TimeUnit
import kotlin.system.measureNanoTime
import kotlin.system.measureTimeMillis

@RunWith(FlankTestRunner::class)
class ShardTest {
Expand Down Expand Up @@ -102,13 +101,20 @@ class ShardTest {
copy(commonArgs = commonArgs.copy(maxTestShards = 4))
}

val nano = measureNanoTime {
createShardsByShardCount(testsToRun, JUnitTestResult(null), arg)
}
// The test occasionally fails on GH Actions' machines, we need to retry to exclude flakiness
val maxAttempts = 5
val maxMs = 5000

var attempt = 0
var ms = Long.MAX_VALUE

val ms = TimeUnit.NANOSECONDS.toMillis(nano)
println("Shards calculated in $ms ms")
assertThat(ms).isLessThan(5000)
while (attempt++ < maxAttempts && ms >= maxMs) {
ms = measureTimeMillis {
createShardsByShardCount(testsToRun, JUnitTestResult(null), arg)
}
println("Shards calculated in $ms ms, attempt: $attempt")
}
assertThat(ms).isLessThan(maxMs)
}

@Test(expected = FlankConfigurationError::class)
Expand Down

0 comments on commit 780cf28

Please sign in to comment.