More specific test timing expectations (#26918)
* More specific test timing expectations (#22098) * Add another retry to justify the wider expectMsg margin
This commit is contained in:
parent
7e31ff719b
commit
dcf61a83c0
1 changed files with 21 additions and 15 deletions
|
|
@ -58,7 +58,7 @@ class BackoffOnRestartSupervisorSpec extends AkkaSpec with ImplicitSender {
|
|||
def supervisorProps(probeRef: ActorRef) = {
|
||||
val options = Backoff
|
||||
.onFailure(TestActor.props(probeRef), "someChildName", 200 millis, 10 seconds, 0.0, maxNrOfRetries = -1)
|
||||
.withSupervisorStrategy(OneForOneStrategy(maxNrOfRetries = 4, withinTimeRange = 30 seconds) {
|
||||
.withSupervisorStrategy(OneForOneStrategy(maxNrOfRetries = 5, withinTimeRange = 30 seconds) {
|
||||
case _: TestActor.StoppingException => SupervisorStrategy.Stop
|
||||
})
|
||||
BackoffSupervisor.props(options)
|
||||
|
|
@ -89,19 +89,25 @@ class BackoffOnRestartSupervisorSpec extends AkkaSpec with ImplicitSender {
|
|||
"restart the child with an exponential back off" in new Setup {
|
||||
filterException[TestActor.TestException] {
|
||||
// Exponential back off restart test
|
||||
probe.within(1.4 seconds, 2 seconds) {
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 0 ~ 200 millis
|
||||
probe.expectMsg(300 millis, "STARTED")
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 0: expected delay ~200 millis
|
||||
probe.expectNoMessage(200 millis)
|
||||
probe.expectMsg(250 millis, "STARTED")
|
||||
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 1 ~ 400 millis
|
||||
probe.expectMsg(500 millis, "STARTED")
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 1: expected delay ~400 millis
|
||||
probe.expectNoMessage(400 millis)
|
||||
probe.expectMsg(250 millis, "STARTED")
|
||||
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 2 ~ 800 millis
|
||||
probe.expectMsg(900 millis, "STARTED")
|
||||
}
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 2: expected delay ~800 millis
|
||||
probe.expectNoMessage(800 millis)
|
||||
probe.expectMsg(250 millis, "STARTED")
|
||||
|
||||
supervisor ! "THROW"
|
||||
// numRestart = 3: expected delay ~1600 millis
|
||||
probe.expectNoMessage(1600 millis)
|
||||
probe.expectMsg(250 millis, "STARTED")
|
||||
|
||||
// Verify that we only have one child at this point by selecting all the children
|
||||
// under the supervisor and broadcasting to them.
|
||||
|
|
@ -192,10 +198,10 @@ class BackoffOnRestartSupervisorSpec extends AkkaSpec with ImplicitSender {
|
|||
"respect maxNrOfRetries property of OneForOneStrategy" in new Setup {
|
||||
filterException[TestActor.TestException] {
|
||||
probe.watch(supervisor)
|
||||
// Have the child throw an exception 5 times, which is more than the max restarts allowed.
|
||||
for (i <- 1 to 5) {
|
||||
// Have the child throw an exception 6 times, which is more than the max restarts allowed.
|
||||
for (i <- 1 to 6) {
|
||||
supervisor ! "THROW"
|
||||
if (i < 5) {
|
||||
if (i < 6) {
|
||||
// Since we should've died on this throw, don't expect to be started.
|
||||
// We're not testing timing, so set a reasonably high timeout.
|
||||
probe.expectMsg(4 seconds, "STARTED")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue