Harden ClusterShardingStatsSpec, #30841 (#31152)

This commit is contained in:
Patrik Nordwall 2022-02-21 17:42:09 +01:00 committed by GitHub
parent 2f57153ee4
commit e4aa3b6efc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,30 +76,26 @@ abstract class ClusterShardingStatsSpec
sharding.init(Entity(typeKey)(_ => Pinger()))
enterBarrier("sharding started")
runOn(first) {
val pongProbe = TestProbe[Pong]()
val pongProbe = TestProbe[Pong]()
val entityRef1 = ClusterSharding(typedSystem).entityRefFor(typeKey, "ping-1")
entityRef1 ! Ping(1, pongProbe.ref)
pongProbe.receiveMessage()
val entityRef1 = ClusterSharding(typedSystem).entityRefFor(typeKey, "ping-1")
entityRef1 ! Ping(1, pongProbe.ref)
pongProbe.receiveMessage()
val entityRef2 = ClusterSharding(typedSystem).entityRefFor(typeKey, "ping-2")
entityRef2 ! Ping(2, pongProbe.ref)
pongProbe.receiveMessage()
}
val entityRef2 = ClusterSharding(typedSystem).entityRefFor(typeKey, "ping-2")
entityRef2 ! Ping(2, pongProbe.ref)
pongProbe.receiveMessage()
enterBarrier("sharding-initialized")
runOn(first, second, third) {
val replyToProbe = TestProbe[ClusterShardingStats]()
sharding.shardState ! GetClusterShardingStats(typeKey, queryTimeout, replyToProbe.ref)
val statsProbe = TestProbe[ClusterShardingStats]()
sharding.shardState ! GetClusterShardingStats(typeKey, queryTimeout, statsProbe.ref)
val stats = statsProbe.receiveMessage(queryTimeout)
stats.regions.size shouldEqual 3 // 3 nodes
stats.regions.values.flatMap(_.stats.values).sum shouldEqual 2 // number of entities
stats.regions.values.forall(_.failed.isEmpty) shouldBe true
val stats = replyToProbe.receiveMessage(queryTimeout)
stats.regions.size shouldEqual 3
stats.regions.values.flatMap(_.stats.values).sum shouldEqual 2
stats.regions.values.forall(_.failed.isEmpty) shouldBe true
}
enterBarrier("done")
}
}