Fix StartEntitySpec instability

The old logic allowed a race condition where the 'StartEntity' from the
test arrived at the ShardRegion before the termination of the actor did,
causing it to ignore the `StartEntity`.
This commit is contained in:
Arnout Engelen 2021-08-13 15:31:58 +00:00
parent 999b0853d5
commit 071a074ccb
No known key found for this signature in database
GPG key ID: 061107B0F74A6DAA

View file

@ -129,11 +129,17 @@ class StartEntitySpec extends AkkaSpec(StartEntitySpec.config) with ImplicitSend
sharding ! EntityEnvelope("1", "ping")
expectMsg("pong")
val entity = lastSender
watch(entity)
// stop without passivation
entity ! "just-stop"
expectTerminated(entity)
// Make sure the shard has processed the termination
awaitAssert({
sharding ! ShardRegion.GetShardRegionState
val state = expectMsgType[ShardRegion.CurrentShardRegionState]
state.shards should have size (1)
state.shards.head.entityIds should ===(Set())
})
// the backoff is 10s by default, so plenty time to
// bypass region and send start entity directly to shard