Harden TestProbeSpec: increase short timeouts (#26791)

* Harden TestProbeSpec: increase short timeouts
* Use default timeout for termination in TestProbeSpec
This commit is contained in:
Christopher Batey 2019-04-24 09:11:10 +01:00 committed by Patrik Nordwall
parent dd8c542547
commit 69bf1a7c18

View file

@ -14,9 +14,11 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
import TestProbeSpec._ import TestProbeSpec._
val shortDuration = 400.millis
def compileOnlyApiTest(): Unit = { def compileOnlyApiTest(): Unit = {
val probe = TestProbe[AnyRef]() val probe = TestProbe[AnyRef]()
probe.fishForMessage(100.millis) { probe.fishForMessage(shortDuration) {
case _ => FishingOutcomes.complete case _ => FishingOutcomes.complete
} }
probe.awaitAssert({ probe.awaitAssert({
@ -25,9 +27,9 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
probe.expectMessageType[String] probe.expectMessageType[String]
probe.expectMessage("whoa") probe.expectMessage("whoa")
probe.expectNoMessage() probe.expectNoMessage()
probe.expectNoMessage(300.millis) probe.expectNoMessage(shortDuration)
probe.expectTerminated(system.deadLetters, 100.millis) probe.expectTerminated(system.deadLetters, shortDuration)
probe.within(100.millis) { probe.within(shortDuration) {
"result" "result"
} }
} }
@ -37,7 +39,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
"allow probing for actor stop when actor already stopped" in { "allow probing for actor stop when actor already stopped" in {
val probe = TestProbe() val probe = TestProbe()
val ref = spawn(Behaviors.stopped) val ref = spawn(Behaviors.stopped)
probe.expectTerminated(ref, 100.millis) probe.expectTerminated(ref)
} }
"allow probing for actor stop when actor has not stopped yet" in { "allow probing for actor stop when actor has not stopped yet" in {
@ -61,7 +63,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
probe.ref ! "one" probe.ref ! "one"
probe.ref ! "two" probe.ref ! "two"
val result = probe.fishForMessage(300.millis) { val result = probe.fishForMessage(shortDuration) {
case "one" => FishingOutcomes.continue case "one" => FishingOutcomes.continue
case "two" => FishingOutcomes.complete case "two" => FishingOutcomes.complete
} }
@ -77,7 +79,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
probe.ref ! "two" probe.ref ! "two"
intercept[AssertionError] { intercept[AssertionError] {
probe.fishForMessage(300.millis) { probe.fishForMessage(shortDuration) {
case "one" => FishingOutcomes.continue case "one" => FishingOutcomes.continue
case "two" => FishingOutcomes.fail("not the fish I'm looking for") case "two" => FishingOutcomes.fail("not the fish I'm looking for")
} }
@ -102,7 +104,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
probe.ref ! "two" probe.ref ! "two"
intercept[AssertionError] { intercept[AssertionError] {
probe.fishForMessage(300.millis) { probe.fishForMessage(shortDuration) {
case "one" => FishingOutcomes.continue case "one" => FishingOutcomes.continue
} }
} }
@ -114,7 +116,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with WordSpecLike {
probe.ref ! "one" probe.ref ! "one"
intercept[AssertionError] { intercept[AssertionError] {
probe.fishForMessage(300.millis) { probe.fishForMessage(shortDuration) {
case "one" => FishingOutcomes.continue case "one" => FishingOutcomes.continue
} }
} }