Also dilate the initial delay when testing timeouts in akka-stream-testkit
This commit is contained in:
parent
8ad0b992d6
commit
d22e4becd1
1 changed files with 14 additions and 6 deletions
|
|
@ -8,8 +8,9 @@ import scala.concurrent.duration._
|
||||||
|
|
||||||
import akka.stream.scaladsl.Source
|
import akka.stream.scaladsl.Source
|
||||||
import akka.stream.testkit.scaladsl.TestSink
|
import akka.stream.testkit.scaladsl.TestSink
|
||||||
import akka.testkit.AkkaSpec
|
|
||||||
import akka.testkit.EventFilter
|
import akka.testkit._
|
||||||
|
|
||||||
import akka.testkit.TestEvent.Mute
|
import akka.testkit.TestEvent.Mute
|
||||||
import akka.testkit.TestEvent.UnMute
|
import akka.testkit.TestEvent.UnMute
|
||||||
|
|
||||||
|
|
@ -121,13 +122,17 @@ class StreamTestKitSpec extends AkkaSpec {
|
||||||
"#expectNextWithTimeoutPF should fail after timeout when element delayed" in {
|
"#expectNextWithTimeoutPF should fail after timeout when element delayed" in {
|
||||||
intercept[AssertionError] {
|
intercept[AssertionError] {
|
||||||
val timeout = 100.millis
|
val timeout = 100.millis
|
||||||
val overTimeout = timeout + 50.millis
|
// Initial delay is longer than the timeout so an exception will be thrown.
|
||||||
|
// It also needs to be dilated since the testkit will dilate the timeout
|
||||||
|
// accordingly to `-Dakka.test.timefactor` value.
|
||||||
|
val initialDelay = (timeout * 2).dilated
|
||||||
Source
|
Source
|
||||||
.tick(overTimeout, 1.millis, 1)
|
.tick(initialDelay, 1.millis, 1)
|
||||||
.runWith(TestSink.probe)
|
.runWith(TestSink.probe)
|
||||||
.request(1)
|
.request(1)
|
||||||
.expectNextWithTimeoutPF(timeout, {
|
.expectNextWithTimeoutPF(timeout, {
|
||||||
case 1 =>
|
case 1 =>
|
||||||
|
system.log.info("Message received :(")
|
||||||
})
|
})
|
||||||
|
|
||||||
}.getMessage should include("timeout")
|
}.getMessage should include("timeout")
|
||||||
|
|
@ -160,9 +165,12 @@ class StreamTestKitSpec extends AkkaSpec {
|
||||||
"#expectNextChainingPF should fail after timeout when element delayed" in {
|
"#expectNextChainingPF should fail after timeout when element delayed" in {
|
||||||
intercept[AssertionError] {
|
intercept[AssertionError] {
|
||||||
val timeout = 100.millis
|
val timeout = 100.millis
|
||||||
val overTimeout = timeout + 50.millis
|
// Initial delay is longer than the timeout so an exception will be thrown.
|
||||||
|
// It also needs to be dilated since the testkit will dilate the timeout
|
||||||
|
// accordingly to `-Dakka.test.timefactor` value.
|
||||||
|
val initialDelay = (timeout * 2).dilated
|
||||||
Source
|
Source
|
||||||
.tick(overTimeout, 1.millis, 1)
|
.tick(initialDelay, 1.millis, 1)
|
||||||
.runWith(TestSink.probe)
|
.runWith(TestSink.probe)
|
||||||
.request(1)
|
.request(1)
|
||||||
.expectNextChainingPF(timeout, {
|
.expectNextChainingPF(timeout, {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue